Why the query is slow, drawn as a tree.

Explain Analyze is a small set of notes on Postgres performance: reading plans, choosing indexes, spotting N+1 queries, pooling connections, keeping bloat in check and changing schemas while traffic keeps flowing.

Read the notes

Fig. 1 — EXPLAIN ANALYZE, read from the leaves up. The coral node is where the time goes.
  • Limit

    cost
    9131.0
    rows est / act
    50 / 50
    time
    143.9 ms
    • Hash Join o.customer_id = c.id

      cost
      9120.5
      rows est / act
      212 / 4871
      time
      142.4 ms
      • Index Scan orders o, filter status = 'paid'

        cost
        7018.1
        rows est / act
        212 / 4871
        time
        118.6 ms

        46,091 rows removed by filter

      • Hash

        cost
        1204.0
        rows est / act
        51200 / 51200
        time
        18.5 ms
        • Seq Scan customers c

          cost
          1204.0
          rows est / act
          51200 / 51200
          time
          9.9 ms

Notes