Limit (cost=1934.60..1934.65 rows=20 width=550) |
-> Sort (cost=1934.60..1934.65 rows=20 width=550) |
Sort Key: sub.last_contact, c.created_at DESC |
-> Nested Loop Left Join (cost=1845.93..1934.17 rows=20 width=550) |
Join Filter: (c.client_class = cc.id) |
Filter: ((sub.lost_contact_days >= ((cc.notice_days - 1))::double precision) OR (sub.lost_contact_days IS NULL)) |
-> Hash Left Join (cost=1845.93..1928.39 rows=58 width=550) |
Hash Cond: (c.id = sub.id) |
-> Bitmap Heap Scan on tbl_clients c (cost=4.73..87.03 rows=58 width=534) |
Recheck Cond: (sales_rep = 1001) |
Filter: (NOT deleted) |
-> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.71 rows=58 width=0) |
Index Cond: (sales_rep = 1001) |
-> Hash (cost=1840.47..1840.47 rows=58 width=20) |
-> Subquery Scan on sub (cost=1838.73..1840.47 rows=58 width=20) |
-> HashAggregate (cost=1838.73..1839.89 rows=58 width=20) |
Group Key: sub_c.id |
-> Hash Right Join (cost=87.76..1831.05 rows=1025 width=12) |
Hash Cond: (sl.client_id = sub_c.id) |
-> Seq Scan on tbl_work_logs sl (cost=0.00..1652.65 rows=34465 width=12) |
-> Hash (cost=87.03..87.03 rows=58 width=4) |
-> Bitmap Heap Scan on tbl_clients sub_c (cost=4.73..87.03 rows=58 width=4) |
Recheck Cond: (sales_rep = 1001) |
Filter: (NOT deleted) |
-> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.71 rows=58 width=0) |
Index Cond: (sales_rep = 1001) |
-> Materialize (cost=0.00..1.06 rows=4 width=6) |
-> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=6) |