I have more than 10 million rows. Counting the number of rows is too slow. I want to estimate the number of rows.
Current query is like this:
SELECT count(*) FROM `database` WHERE `location` LIKE '%New York%'
This gives me the exact number and its too slow. What I want is something like this:
ESTIMATE count(*) FROM `database` WHERE `location` LIKE '%New York%'
Maybe this can be done by limiting the query to a subset of the table (every nth row or something). Maybe there is a built-in function that can be used.
Edit: Perhaps I can limit the query to every nth row? and then multiple by n.
Edit2: I just tried counting every 10th row and then multiplying the count by ten, but there was no increase in speed, despite the fact that the auto-incrementing 'counter' is a primary key.
SELECT count(*) FROM database WHERE `location` LIKE '%Los Angeles%' and counter%10 = 0