Normalising two years of slow queries into eleven shapes

Two years of a rotating slow query log, aggregated for the first time.

$ zcat /var/log/mysql/slow-*.log.gz | pt-query-digest 
    --limit 20 --order-by Query_time:sum

  Rank  Response time   Calls    R/Call  Item
  ====  =============  =======  =======  ==========
     1  41208s 22.1%   412884    0.0998  SELECT orders
     2  38104s 20.4%       11 3464.0000  SELECT orders JOIN
     3  22884s 12.3%    88204    0.2594  SELECT customers
  ...
  eleven shapes account for 80% of the total.

Ranking by total time rather than by per-call time is what makes the list actionable, and it puts a hundred-millisecond query called four hundred thousand times above a fifty-minute report run eleven times. Both need fixing and for different reasons, which is why the same list sorted the other way would have produced a different afternoon.