I concur.

The SELECT time is going to resemble something like:

K_1 * F_1(number_of_records_in_database) + K_2 *
F_2(number_of_records_selected)

If the indices are effective, F_1 = log(N), but if the indices are not
effective, F_1 = N.

One thing you may want to try to narrow down the problem is just
retrieving 100 records (the COUNT clause of a query) and see how that
affects the speed, then try the full set and see how it is different.

If they aren't very different, then it is a F_1 problem.

But if they are different, then it is a K_2 / F_2 problem.

As far as K_2 or F_2 problems ...

Another possibility is that you are using ORDER BY on a large result set
that isn't indexed for an effective sort.  Try dropping the ORDER BY and see
what happens.

My view of how MySQL might work internally is perhaps naive.  But sorting
can be worst case O(N**2).

Dave.
----

Addendum:  I misremembered the SQL keywords.  It isn't COUNT.  It is (I
think) LIMIT.

Also, ORDER BY might be GROUP BY.

Oopsie.

Reply via email to