Diagnosing Long-Running Queries

Any tips on how to diagnose long-running queries? And specifically, not queries that always run long (that’s pretty easily done using EXPLAIN and understanding how the query optimizer handles a particular operation). But cases where 99% of the time a particular query runs in a few milliseconds, but then occasionally takes several seconds (sometimes over a minute). It’s likely due to the total instantaneous workload on the server at that time, but it’s often very difficult to troubleshoot.