QUERY PLAN
GroupAggregate (cost=1384.40..1384.62 rows=1 width=558)
Group Key: c.id, cc.id
-> Sort (cost=1384.40..1384.40 rows=1 width=566)
Sort Key: cc.id
-> Nested Loop Left Join (cost=13.67..1384.39 rows=1 width=566)
Join Filter: (cc.id = c.client_class)
-> Nested Loop Left Join (cost=13.67..1383.30 rows=1 width=520)
Join Filter: (sl.client_id = c.id)
-> Nested Loop Left Join (cost=7.08..654.71 rows=1 width=512)
Join Filter: (arrive.client_id = c.id)
-> Index Scan using tbl_clients_pkey on tbl_clients c (cost=0.28..8.29 rows=1 width=504)
Index Cond: (id = 149)
Filter: (NOT deleted)
-> Bitmap Heap Scan on tbl_work_logs arrive (cost=6.80..646.39 rows=2 width=12)
Recheck Cond: ((client_id IS NOT NULL) AND (client_id = 149))
Filter: ((NOT is_draft) AND (location_in_id IS NOT NULL) AND (location_out_id IS NOT NULL) AND (scenario_id = 1))
-> Bitmap Index Scan on tbl_work_logs_client_id_idx (cost=0.00..6.80 rows=251 width=0)
Index Cond: ((client_id IS NOT NULL) AND (client_id = 149))
-> Bitmap Heap Scan on tbl_work_logs sl (cost=6.59..724.87 rows=297 width=12)
Recheck Cond: (client_id = 149)
-> Bitmap Index Scan on tbl_work_logs_client_id_idx (cost=0.00..6.52 rows=297 width=0)
Index Cond: (client_id = 149)
-> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=46)