| Aggregate (cost=69.12..69.13 rows=1 width=8) |
| -> Append (cost=37.77..69.11 rows=3 width=0) |
| -> Subquery Scan on "*SELECT* 1" (cost=37.77..37.83 rows=2 width=0) |
| -> Unique (cost=37.77..37.81 rows=2 width=198) |
| -> Sort (cost=37.77..37.77 rows=2 width=198) |
| Sort Key: ((((c.serial_no)::text || ' '::text) || (c.title)::text)), ((c.direction)::integer), (CASE WHEN (c.direction = 1) THEN '借'::text WHEN (c.direction = 2) THEN '贷'::text ELSE ''::text END), ((COALESCE(c.amount, '0'::numeric))::text), ((COALESCE(ca.debit_amount, '0'::numeric))::text), ((COALESCE(ca.credit_amount, '0'::numeric))::text), c.id, c.serial_no |
| -> Nested Loop Anti Join (cost=7.56..37.76 rows=2 width=198) |
| -> Hash Left Join (cost=7.29..26.85 rows=2 width=101) |
| Hash Cond: (c.id = ca.ledger_account_caption_id) |
| -> Nested Loop Left Join (cost=0.14..19.70 rows=2 width=37) |
| Join Filter: ((a.ledger_id = c.ledger_id) AND ((c.is_auxiliary_customer AND (a.type = 1)) OR (c.is_auxiliary_supplier AND (a.type = 2)))) |
| Filter: (((c.serial_no)::text ~~ '%1221%'::text) OR ((c.title)::text ~~ '%1221%'::text) OR ((a.serial_no)::text ~~ '%1221%'::text) OR ((a.title)::text ~~ '%1221%'::text)) |
| -> Seq Scan on tbl_ledger_account_captions c (cost=0.00..10.21 rows=44 width=39) |
| Filter: ((NOT is_delete) AND (NOT COALESCE(is_auxiliary_customer, false)) AND (NOT COALESCE(is_auxiliary_supplier, false)) AND (ledger_id = 1)) |
| -> Materialize (cost=0.14..8.17 rows=1 width=308) |
| -> Index Scan using idx_tbl_ledger_auxiliary_items_ledger_serial_no on tbl_ledger_auxiliary_items a (cost=0.14..8.17 rows=1 width=308) |
| Index Cond: (ledger_id = 1) |
| Filter: ((NOT is_delete) AND ((type = 1) OR (type = 2))) |
| -> Hash (cost=6.87..6.87 rows=22 width=68) |
| -> Subquery Scan on ca (cost=6.32..6.87 rows=22 width=68) |
| -> HashAggregate (cost=6.32..6.65 rows=22 width=68) |
| Group Key: i.ledger_account_caption_id |
| -> Hash Join (cost=2.04..5.48 rows=112 width=12) |
| Hash Cond: (i.ledger_ticket_id = t.id) |
| -> Seq Scan on tbl_ledger_ticket_items i (cost=0.00..3.12 rows=112 width=16) |
| Filter: (ledger_account_caption_id IS NOT NULL) |
| -> Hash (cost=1.57..1.57 rows=38 width=4) |
| -> Seq Scan on tbl_ledger_tickets t (cost=0.00..1.57 rows=38 width=4) |
| Filter: ((ledger_id = 1) AND (status = 1)) |
| -> Index Scan using idx_tbl_ledger_account_captions_ledger_id on tbl_ledger_account_captions child (cost=0.27..5.34 rows=8 width=8) |
| Index Cond: ((ledger_id = c.ledger_id) AND (ledger_id = 1)) |
| Filter: ((NOT is_delete) AND (parent_id = c.id)) |
| -> Subquery Scan on "*SELECT* 2" (cost=0.14..31.28 rows=1 width=0) |
| -> Nested Loop Anti Join (cost=0.14..31.27 rows=1 width=274) |
| Join Filter: ((child_1.ledger_id = c_1.ledger_id) AND (child_1.parent_id = c_1.id)) |
| -> Nested Loop (cost=0.14..18.40 rows=1 width=8) |
| Join Filter: (((c_1.is_auxiliary_customer AND (a_1.type = 1)) OR (c_1.is_auxiliary_supplier AND (a_1.type = 2))) AND (((c_1.serial_no)::text ~~ '%1221%'::text) OR ((c_1.title)::text ~~ '%1221%'::text) OR ((a_1.serial_no)::text ~~ '%1221%'::text) OR ((a_1.title)::text ~~ '%1221%'::text))) |
| -> Seq Scan on tbl_ledger_account_captions c_1 (cost=0.00..10.21 rows=1 width=34) |
| Filter: ((NOT is_delete) AND (is_auxiliary_customer OR is_auxiliary_supplier) AND (ledger_id = 1)) |
| -> Index Scan using idx_tbl_ledger_auxiliary_items_ledger_serial_no on tbl_ledger_auxiliary_items a_1 (cost=0.14..8.17 rows=1 width=312) |
| Index Cond: (ledger_id = 1) |
| Filter: ((NOT is_delete) AND ((type = 1) OR (type = 2))) |
| -> Seq Scan on tbl_ledger_account_captions child_1 (cost=0.00..10.21 rows=177 width=8) |
| Filter: ((NOT is_delete) AND (ledger_id = 1)) |