What can be done to identify the reason for DB slowness?
When i ran the query in the morning it ran quickly & i got the output.
When i run the same query after 1 hr, it took more than 2mins.
What can be checked to identify this slowness?
All the tables are properly indexed.
If it’s just a single query which is running slowly,
EXPLAIN SELECT...as mentioned by arex1337 may help you see the reason.It would also be worth looking at the output of e.g.
vmstaton the box whilst running the query to see what it’s doing – you should be able to get a feel for whether the machine is swapping, IO-bound, CPU-bound etc.Check also with
topto look for any rogue processes hogging CPU time.Finally, if the machine is using RAID, it’s possible that, if a drive has failed, the RAID array could be in a degraded state, which could make disc access slower (this is only applicable in certain RAID configurations, but worth considering and ruling out).