QUERY PLAN
HashAggregate (cost=7.88..8.78 rows=33 width=44)
Group Key: CASE WHEN ((r.status = 2) AND (r.bank_settle_at IS NULL)) THEN 20 WHEN ((r.status = 2) AND (r.bank_settle_at IS NOT NULL) AND (r.settle_amount < r.amount)) THEN 21 WHEN ((r.status = 2) AND (r.bank_settle_at IS NOT NULL) AND (r.settle_amount >= r.amount)) THEN 22 ELSE (r.status)::integer END
-> HashAggregate (cost=6.14..6.97 rows=33 width=17)
Group Key: r.id
-> Hash Left Join (cost=4.33..6.06 rows=33 width=23)
Hash Cond: (r.id = rsvr.erp_other_collect_ticket_id)
-> Hash Right Join (cost=3.31..4.91 rows=33 width=23)
Hash Cond: (rvr.erp_other_collect_ticket_id = r.id)
Filter: ((r.created_by = 1013) OR (rvr.user_id = 1013) OR (r.created_by = ANY ('{5030,5351,5026,5203,5025,5072,5105,1004,5299,1001,5037,5446,1027,5045,5087,5094,5123,1008,1029,5048,5043,1025,1003,5208,5305,5078,1015,5449,5358,1023,5064,1026,5089,5027,1007,5258,5135,5076,5071,5209,1028,5083,5081,5033,5440,5229,5104,5359,5393,5412,5409,5062,5360,5247,5015,5023,5126,5124,1022,5022,5311,5248,5128,1000,5333,1006,1014,5093,5297,5249,5095,5082,1012,5070,5096,5420,5063,5102,5028,5259,5445,5448,5298,5075,5388,5230,5073,5404,1021,1030,5069,5066,5079,1020,5252,5364,5309,5411,5301,5049,5419,5044,1018,5088,5031,1013,1013,5074,5413,5125,5101,5024,5300,1016,5293,5250,5047,5029,5304,5296,1005,1017,5050,1019,5080,5032,5085,5332,1011,5086,1002,5065,5294,5357,5329,1010,5356,5016,5295,1009,5302,5303}'::integer[])))
-> Seq Scan on tbl_erp_other_collect_ticket_verify_rels rvr (cost=0.00..1.32 rows=32 width=8)
-> Hash (cost=2.77..2.77 rows=43 width=27)
-> Seq Scan on tbl_erp_other_collect_tickets r (cost=0.00..2.77 rows=43 width=27)
Filter: ((status <> 0) OR ((status = 0) AND (created_by = 1013)))
-> Hash (cost=1.01..1.01 rows=1 width=4)
-> Seq Scan on tbl_erp_other_collect_ticket_stop_verify_rels rsvr (cost=0.00..1.01 rows=1 width=4)