sql - How to check every Nth entry in a mysql database? -
I am trying to find the first entry in my huge database where "FU" first began to appear, but this question too Slow:
Choose from mytable minimum (ID) where '% foo%' data such as;
I will be happy to count on millions of people, but this question does not seem to run any faster:
choose the least Id) mytable where data like mod (id, 1000000) = 0 and '% foo%';
Any ideas how mysql needs to check only every million entries? The only thing I can think of is that there is a floating table with the first integer and to join it, multiplying each integer by 1000000.
Added mod (id, 1000000) = 0
due to your The second query is most likely going to slow which gets every code
To move it fast, you should have an index on the In addition, use the data column.
LIMIT
you might like:
This will only search for the first 0 - 100000 rows. If you can not do whatever you like, increase the limit - 1000000, 2000000
See only 1000000 - 2000000 rows.
Comments
Post a Comment