explain.depesz.com

PostgreSQL's explain analyze made readable

Result: yhT2

Settings
# exclusive inclusive rows x rows loops node
1. 6,482.967 61,636.472 ↑ 26.4 22,737 1

GroupAggregate (cost=1,349,702.68..1,885,732.23 rows=601,339 width=16) (actual time=44,802.017..61,636.472 rows=22,737 loops=1)

  • Group Key: headcounts.company_id
2. 3,142.702 55,153.505 ↑ 3.7 1,114,930 1

Merge Join (cost=1,349,702.68..1,424,904.85 rows=4,146,920 width=16) (actual time=44,801.448..55,153.505 rows=1,114,930 loops=1)

  • Merge Cond: (audit_log_entries.company_id = headcounts.company_id)
3. 312.339 30,634.864 ↑ 4.8 151,702 1

Sort (cost=706,667.61..708,490.07 rows=728,986 width=4) (actual time=30,509.836..30,634.864 rows=151,702 loops=1)

  • Sort Key: audit_log_entries.company_id
  • Sort Method: external merge Disk: 2072kB
4. 30,322.525 30,322.525 ↑ 4.8 151,704 1

Seq Scan on audit_log_entries (cost=0.00..625,712.66 rows=728,986 width=4) (actual time=20,534.649..30,322.525 rows=151,704 loops=1)

  • Filter: ((user_id <> 532) AND (created_at >= (now() - '3 mons'::interval)))
  • Rows Removed by Filter: 20474969
5. 3,467.175 21,375.939 ↓ 1.2 4,666,706 1

Materialize (cost=643,034.84..661,751.39 rows=3,743,311 width=16) (actual time=14,291.587..21,375.939 rows=4,666,706 loops=1)

6. 11,699.594 17,908.764 ↑ 1.0 3,733,208 1

Sort (cost=643,034.84..652,393.11 rows=3,743,311 width=16) (actual time=14,291.581..17,908.764 rows=3,733,208 loops=1)

  • Sort Key: headcounts.company_id
  • Sort Method: external merge Disk: 109528kB
7. 6,209.170 6,209.170 ↑ 1.0 3,733,208 1

Seq Scan on headcounts (cost=0.00..106,396.32 rows=3,743,311 width=16) (actual time=9.019..6,209.170 rows=3,733,208 loops=1)

  • Filter: (created_at >= (now() - '1 year 3 mons'::interval))
  • Rows Removed by Filter: 85109