I would like to measure the query execution time.
My database is Amazon Aurora MySQL3 (with MySQL 8.0 compatibility).
I tried two ways of measuring:
- EXPLAIN ANALYZE
- see slow query log in cloudwatch.
However, I found that 1 and 2 returned different results for the same SQL statement.
the result from 1:
# Query_time: 7.719750 Lock_time: 0.000121 Rows_sent: XXX Rows_examined: XXX
the result from 2:
-> Filter: (XXX like XXX) (cost=6258.00 rows=XXX) (actual time=0.046..132.199 rows=XXX loops=1)
-> Table scan on XXXX (cost=6258.00 rows=XXX) (actual time=0.036..71.230 rows=XXX loops=1)
From my understanding...
1 says that my query takes about 7.7 seconds to execute.
2 says that my query takes about 0.132 seconds to execute.
My Questions are:
・Is my understanding of query execution time correct?
・Why are their execution times different?
・Which is more reliable?
Thank you in advance.