QUERY PLAN
GroupAggregate (cost=35.45..35.67 rows=1 width=3862)
Group Key: c.id, cc.id
-> Sort (cost=35.45..35.45 rows=1 width=3870)
Sort Key: cc.id
-> Nested Loop Left Join (cost=8.61..35.44 rows=1 width=3870)
-> Nested Loop Left Join (cost=8.47..27.21 rows=1 width=3824)
Join Filter: (sl.client_id = c.id)
-> Nested Loop Left Join (cost=4.31..17.68 rows=1 width=3816)
Join Filter: (arrive.client_id = c.id)
-> Index Scan using tbl_clients_pkey on tbl_clients c (cost=0.14..8.15 rows=1 width=3808)
Index Cond: (id = 1)
Filter: (NOT deleted)
-> Bitmap Heap Scan on tbl_work_logs arrive (cost=4.17..9.51 rows=1 width=12)
Recheck Cond: ((client_id IS NOT NULL) AND (client_id = 1))
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..4.17 rows=2 width=0)
Index Cond: ((client_id IS NOT NULL) AND (client_id = 1))
-> Bitmap Heap Scan on tbl_work_logs sl (cost=4.16..9.50 rows=2 width=12)
Recheck Cond: (client_id = 1)
-> Bitmap Index Scan on tbl_work_logs_client_id_idx (cost=0.00..4.16 rows=2 width=0)
Index Cond: (client_id = 1)
-> Index Scan using tbl_client_classes_pkey on tbl_client_classes cc (cost=0.14..8.16 rows=1 width=46)
Index Cond: (id = c.client_class)