skip to Main Content

When I run this query on phpmyadmin, it takes about 30 seconds to fetch the results, but once the results have successfully loaded, it says “Query took 0.5029 seconds”.

Why does it say ‘Query took 0.50 seconds’ if the results take 30 seconds to load?

My Query:

SELECT * FROM `documents` WHERE disable=0 AND author=7 AND MATCH(text) AGAINST('"chocolate"')

The field I am searching (named “text”) has a field type of “mediumtext”, and each text row contains about 200kb of text. The total size of the table is 15,000 rows and 1.5GB of text.

Does anyone know what causes this to happen?

2

Answers


  1. I am going to expand on my comment.

    When a database reports on the time to complete a query, that is generally the time only within the database. It might or might not include the time to compile the query. It does not include the time to return the results.

    Your data rows are quite wide, because of the text column on the data. So, you have a situation where running the query in the database is quite fast. But the resulting rows are very big — so it takes lots of time to return them to the user.

    Perhaps further complicating the timing is that you might be looking at when all the rows are returned rather than just for the first row to return (that is also a confusion with timings sometimes).

    In any case, if you don’t need the wide columns, just select the columns that you do need. That has little effect on the query processing time, but it could have a big impact on the time to return the results.

    Login or Signup to reply.
  2. Rule #1 Select * from anytable is a BAD idea.
    Just ask @supercoolville for clarification.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search