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 data column.

In addition, use the LIMIT you might like:

Select min (id) from mytable where '% foo' Data ID range such as% '100000000

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

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -