@Максим *********
visas DO have preference on entry. That's because you get (essentially) permission to enter from an Embassy. The embassy weighs your travel history, the way IOs do if you enter on exemption. Embassies may decide to not give you a visa, for instance based on your recent travel history to Thailand. But if they decide to give you one, immigrations is not supposed, although technically allowed, to overrule that and still deny entry. They'll be reluctant to do so.
Note that many immigrations officers also tell people with extensive travel history to Thailand (as tourist) to get a tourist visa instead of coming exempt, as that's safer. You know earlier on if you'd (normally, in principle, etc.) make it in.