Database command runs glacially in my PHP script, quickly in phpMyAdmin -


I have a huge MySQL database (approximately 1 million items) and a fairly complex query is going on that database. When I enter the SQL command in phpMyAdmin, it takes about 2 seconds, but using PHP code takes about 1-2 minutes to generate the same output.

Why would such a time be different? If this was a poorly executed query, would not it take long time to appear in phpMyAdmin?

Are you really getting the same output?

If you have tons of data in your database, how many lines do your query return?

When you launch a query with PhpMyAdmin, it automatically adds the pagination.

Then, with this preliminary query:

  select from test  

PhpMyAdmin actually executes this one: < / P>

  Choose from test range * 0, 30  

If your range is not in your query (while executing it from your PHP script), it The difference can be understood: obtaining 30 lines and achieving hundreds / thousands / more rows does not take the same amount (to provide them the same chi Z).

If you are not using the range and / or trying to get too many lines in your query, can you post your code?

(Another possible son query will be cached: first time the query is running, it takes a lot of time; next time, MySQL has cached the results)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -