| Aggregate (cost=2485.75..2485.76 rows=1 width=8) |
| -> HashAggregate (cost=2350.42..2433.70 rows=4164 width=22) |
| Group Key: c.id, c.client_class, cc.notice_days, (date_part('epoch'::text, (now() - max(sl.end_at))) / '86400'::double precision) |
| -> HashAggregate (cost=2225.50..2308.78 rows=4164 width=22) |
| Group Key: c.id, cc.id |
| Filter: ((date_part('epoch'::text, (now() - max(sl.end_at))) / '86400'::double precision) > (cc.notice_days)::double precision) |
| -> Hash Left Join (cost=154.43..2040.96 rows=18454 width=22) |
| Hash Cond: (c.client_class = cc.id) |
| -> Hash Right Join (cost=153.34..1960.49 rows=18454 width=16) |
| Hash Cond: (sl.client_id = c.id) |
| -> Seq Scan on tbl_work_logs sl (cost=0.00..1713.31 rows=35685 width=12) |
| Filter: (NOT is_draft) |
| -> Hash (cost=140.32..140.32 rows=1041 width=8) |
| -> Seq Scan on tbl_clients c (cost=0.00..140.32 rows=1041 width=8) |
| Filter: ((NOT deleted) AND (sales_rep = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5332,5449,5467,5476}'::integer[]))) |
| -> Hash (cost=1.04..1.04 rows=4 width=6) |
| -> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=6) |