QUERY PLAN
Result (cost=74.16..74.17 rows=1 width=1)
InitPlan 1 (returns $1)
-> Nested Loop Left Join (cost=0.28..74.16 rows=1 width=0)
Filter: ((client.sales_rep = 5495) OR (r.created_by = ANY ('{5493,5495,5495}'::integer[])) OR (rccr.user_id = 5495) OR (rvr.user_id = 5495))
-> Nested Loop Left Join (cost=0.14..65.98 rows=1 width=16)
Join Filter: (rccr.erp_sales_outbound_id = r.id)
-> Nested Loop Left Join (cost=0.14..30.36 rows=1 width=16)
Join Filter: (rvr.erp_sales_outbound_id = r.id)
-> Index Scan using tbl_erp_sales_outbounds_pkey on tbl_erp_sales_outbounds r (cost=0.14..8.17 rows=1 width=12)
Index Cond: (id = 1)
Filter: ((status <> 0) OR ((status = 0) AND (created_by = 5495)))
-> Seq Scan on tbl_erp_sales_outbound_verify_rels rvr (cost=0.00..22.12 rows=5 width=8)
Filter: (erp_sales_outbound_id = 1)
-> Seq Scan on tbl_erp_sales_outbound_carbon_copy_rels rccr (cost=0.00..35.50 rows=10 width=8)
Filter: (erp_sales_outbound_id = 1)
-> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.14..8.15 rows=1 width=8)
Index Cond: (id = r.client_id)