explain.depesz.com

PostgreSQL's explain analyze made readable

Result: xxki : Optimization for: plan #7H0p

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.005 50.590 ↑ 1.0 1 1

Limit (cost=3,470.07..3,470.08 rows=1 width=61) (actual time=50.586..50.590 rows=1 loops=1)

2. 0.284 50.585 ↑ 1.0 1 1

Sort (cost=3,470.07..3,470.08 rows=1 width=61) (actual time=50.585..50.585 rows=1 loops=1)

  • Sort Key: tb_bond_custody_external.dt_reference DESC
  • Sort Method: top-N heapsort Memory: 25kB
3. 0.639 50.301 ↓ 554.0 554 1

Nested Loop Left Join (cost=1.27..3,470.06 rows=1 width=61) (actual time=40.669..50.301 rows=554 loops=1)

4. 0.114 48.000 ↓ 554.0 554 1

Nested Loop (cost=0.98..3,469.74 rows=1 width=38) (actual time=40.616..48.000 rows=554 loops=1)

5. 0.126 0.126 ↑ 1.0 1 1

Index Scan using tb_core_customer_broker_accounts_con_uk on tb_core_customer_broker_accounts (cost=0.42..8.44 rows=1 width=8) (actual time=0.124..0.126 rows=1 loops=1)

  • Index Cond: ((id_contract = 8) AND (vl_account_number = '743071'::bigint))
6. 0.408 47.760 ↓ 554.0 554 1

Nested Loop (cost=0.56..3,461.30 rows=1 width=42) (actual time=40.489..47.760 rows=554 loops=1)

7. 42.460 42.460 ↑ 1.0 1 1

Seq Scan on tb_bond_custody_external_instrument (cost=0.00..3,367.50 rows=1 width=12) (actual time=40.334..42.460 rows=1 loops=1)

  • Filter: ((id_contract = 8) AND (id_instrument = '791130'::bigint))
  • Rows Removed by Filter: 115034
8. 4.892 4.892 ↓ 554.0 554 1

Index Scan using tb_bond_custody_external_test on tb_bond_custody_external (cost=0.56..93.79 rows=1 width=50) (actual time=0.148..4.892 rows=554 loops=1)

  • Index Cond: ((id_contract = 8) AND (id_customer = tb_core_customer_broker_accounts.id_customer) AND (id_operation_external = tb_bond_custody_external_instrument.id_operation_external))
9. 1.662 1.662 ↑ 1.0 1 554

Index Scan using tb_bond_stock_external_id_contract_numero_estoque_idx on tb_bond_stock_external (cost=0.29..0.31 rows=1 width=41) (actual time=0.003..0.003 rows=1 loops=554)

  • Index Cond: ((id_contract = tb_bond_custody_external.id_contract) AND (id_contract = 8) AND ((numero_estoque)::text = (tb_bond_custody_external.id_estoque_external)::text))
Planning time : 4.063 ms
Execution time : 50.722 ms