QUERY PLAN
Result (cost=78.18..78.19 rows=1 width=1)
InitPlan 2 (returns $2)
-> Nested Loop Left Join (cost=35.66..78.18 rows=1 width=0)
Filter: ((client.sales_rep = ANY ('{5495,5493}'::integer[])) OR (client.sales_rep IS NULL) OR (hashed SubPlan 1) OR (pcr.id IS NULL))
-> Nested Loop Left Join (cost=0.00..34.31 rows=2 width=8)
Join Filter: (pcr.contract_id = c.id)
-> Seq Scan on tbl_purchase_contracts c (cost=0.00..1.07 rows=1 width=4)
Filter: (id = 1)
-> Seq Scan on tbl_purchase_client_rels pcr (cost=0.00..33.12 rows=9 width=12)
Filter: (contract_id = 1)
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.14..4.16 rows=1 width=8)
Index Cond: (pcr.client_id = id)
SubPlan 1
-> Seq Scan on tbl_user_visit_clients (cost=0.00..35.50 rows=10 width=4)
Filter: (user_id = 5495)