Eric Bergen wrote:

in() can take millions of arguments. Up to max packet size. Try it :)

True, but several past threads have suggested that performance drops dramatically when the size of the IN list gets too large. As IN is equivalent to an equality check for each value in the list, separated by ORs, this is not surprising.


Dan Bolser wrote:

On Fri, 13 May 2005, Eric Bergen wrote:



Even better is if you have an integer primary key (think auto_increment) and use in()

So if you want 10 random rows in your app generate 20 or so random numbers and do something like
select col1, from t where x in (1, 5, 3, 2...) limit 10


check num rows and if you don't get enough generate more random numbers and try again.

in() is blazing fast even with thousands of numbers so don't be afraid to kick a few extra in.

I heard about a 255 'in' limit. When you say 'thousands of numbers' do you mean in the IN or in the column?


-Eric


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to