Reputation: 159
I'm using PDO to get the results from my MySQL db.
If I'm only doing the execute statement it takes about 8 seconds
. (doing the same thing 350 times in a row.)
When adding a fetchAll()
statement it goes up to 28 seconds. Is this normal behavior?
I did a network test speed between the web server and the db server, its around 87 Mbits/sec
so that cannot be the problem. Any ideas?
Upvotes: 0
Views: 567
Reputation: 17710
8 seconds for the execute is also ridiculously long - and the indicates that you don't have the table correctly indexed. As a result, it's taking a very long time to get the data from the table. It's possibly also using a temporary table.
Make sure that you have any fields used in a "search" or that are used as a search key in joined tables indexed. Indexes are a bit tricky to get right - but to test, add "EXPLAIN" before your query and print out the results from that - you'll get a row per table. If you have any "using WHERE" or "create temporary tables" then these are probably what you need to remove by adding indexes on those tables.
Upvotes: 1