QUERY PLAN
Sort (cost=938.39..938.79 rows=159 width=112)
Sort Key: sub.id DESC
-> Subquery Scan on sub (cost=376.17..932.58 rows=159 width=112)
-> Append (cost=376.17..930.99 rows=159 width=124)
-> Subquery Scan on "*SELECT* 1" (cost=376.17..484.51 rows=157 width=83)
-> Hash Join (cost=376.17..482.54 rows=157 width=79)
Hash Cond: (t.id = r.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets t (cost=0.00..95.42 rows=2187 width=37)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Hash (cost=374.19..374.19 rows=158 width=18)
-> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..374.19 rows=158 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4486,4349,3916,4480,4481,4484,4433,4248,4235,4257,4291,4285,3598,1756,4324,4323,4373,4055,2534,4112,4106,4144,4016,2739,2765,2777,2742,2776,2737,1186,529,2647,2472,2225,3101,786,2589,2672,2662,3112,3151,3250,3235,3232,3247,2658,3249,3300,3327,3363,3392,3364,3348,3388,3415,3384,2865,3470,3502,3525,3537,3549,3550,3493,3620,3661,3703,3725,3853,3755,3746,3763,3803,3935,3857,3997,3967,3900,2599,2812,2878,2783,2981,2756,2963,2708,2817,1842,1843,1558,2141,26,1692,1697,1734,1872,655,1930,1934,1946,616,656,1091,653,2542,798,1177,1702,2340,2349,3724,522,4388,4455,2148,4446,4453,4399,4467,4476,4462,4479,4478,4457}'::integer[])))
-> Nested Loop (cost=0.29..9.48 rows=1 width=122)
-> Seq Scan on tbl_erp_cash_cost_ticket_sales_contract_settles r_1 (cost=0.00..1.17 rows=1 width=44)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4486,4349,3916,4480,4481,4484,4433,4248,4235,4257,4291,4285,3598,1756,4324,4323,4373,4055,2534,4112,4106,4144,4016,2739,2765,2777,2742,2776,2737,1186,529,2647,2472,2225,3101,786,2589,2672,2662,3112,3151,3250,3235,3232,3247,2658,3249,3300,3327,3363,3392,3364,3348,3388,3415,3384,2865,3470,3502,3525,3537,3549,3550,3493,3620,3661,3703,3725,3853,3755,3746,3763,3803,3935,3857,3997,3967,3900,2599,2812,2878,2783,2981,2756,2963,2708,2817,1842,1843,1558,2141,26,1692,1697,1734,1872,655,1930,1934,1946,616,656,1091,653,2542,798,1177,1702,2340,2349,3724,522,4388,4455,2148,4446,4453,4399,4467,4476,4462,4479,4478,4457}'::integer[])))
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_1 (cost=0.29..8.30 rows=1 width=46)
Index Cond: (id = r_1.erp_cash_cost_ticket_id)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))
-> Nested Loop (cost=0.28..436.98 rows=1 width=116)
-> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..428.67 rows=1 width=18)
Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = ANY ('{4486,4349,3916,4480,4481,4484,4433,4248,4235,4257,4291,4285,3598,1756,4324,4323,4373,4055,2534,4112,4106,4144,4016,2739,2765,2777,2742,2776,2737,1186,529,2647,2472,2225,3101,786,2589,2672,2662,3112,3151,3250,3235,3232,3247,2658,3249,3300,3327,3363,3392,3364,3348,3388,3415,3384,2865,3470,3502,3525,3537,3549,3550,3493,3620,3661,3703,3725,3853,3755,3746,3763,3803,3935,3857,3997,3967,3900,2599,2812,2878,2783,2981,2756,2963,2708,2817,1842,1843,1558,2141,26,1692,1697,1734,1872,655,1930,1934,1946,616,656,1091,653,2542,798,1177,1702,2340,2349,3724,522,4388,4455,2148,4446,4453,4399,4467,4476,4462,4479,4478,4457}'::integer[])))
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t_2 (cost=0.28..8.30 rows=1 width=40)
Index Cond: (id = r_2.erp_payment_ticket_id)
Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[])))