Initially I'm trying to find slow queries among my scripts. And one of the things that bothering me is INSERT
queries as I have couple of indexes in the table (as I can understand insert will not be instantaneous in this case as the indexes should be recalculated each time).
My hoster company (siteground) is limiting me to access to MySQL logs to investigate real situation with slow queries. So I need to search any bypass way to find the problems.
Now I am simply executing suspicious query in phpmyadmin and check if the time taken by the query is OK or not.
However I see some weak points of this approach:
I will get execution time basing on the current server load. So if the server was busy at the time I will get overstated time.
If the query was cached I will get underestimated time.
I need to change DB data for real to check the query. It is OK for queries like
SELECT
, but it is getting tricky forDELETE
andUPDATE
.
So it is much better to use another approach. EXPLAIN
can be a good solution unless:
EXPLAIN
will work only forSELECT
query on my DB server (I have version 5.5.32 of MySQL server, citation from the DOCs: Before MySQL 5.6.3, SELECT is the only explainable statement). I could EXPLAINUPDATE
andDELETE
byEXPLAIN SELECT
substitution (is that correct?) butEXPLAIN INSERT
is still a big question.
So the questions are:
Am I right that
INSERT
can be slow if there is at least one index?Can I
EXPLAIN UPDATE
andDELETE
byEXPLAIN SELECT
substitution?Which approaches can be used to investigate query speed in addition to mentioned phpmyadmin execution and EXPLAIN?
I'm using InnoDB
engine.