explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 3xrY

Settings
# exclusive inclusive rows x rows loops node
1. 4,076.724 132,735.806 ↓ 2.1 10,019,768 1

Hash Left Join (cost=3,339,142.44..6,957,764.06 rows=4,697,571 width=481) (actual time=36,920.624..132,735.806 rows=10,019,768 loops=1)

  • Hash Cond: ((first(mouvementswithpool.id_account ORDER BY mouvementswithpool.montant_absolu DESC, mouvementswithpool.montant_signe DESC)) = plan_comptable.auto_id)
2. 1,453.692 128,658.692 ↓ 2.1 10,019,768 1

Merge Left Join (cost=3,339,072.51..6,834,382.90 rows=4,697,571 width=459) (actual time=36,920.216..128,658.692 rows=10,019,768 loops=1)

  • Merge Cond: (ecrituresallinfo0digitfacture.id_ecritures = gap_order_invoice2.ecritures_id)
3. 2,438.008 106,192.676 ↓ 2.1 10,019,768 1

Merge Left Join (cost=1,812,661.08..5,294,210.78 rows=4,697,571 width=395) (actual time=15,907.889..106,192.676 rows=10,019,768 loops=1)

  • Merge Cond: (ecrituresallinfo0digitfacture.id_ecritures = entriessumpooltva.ecritures_autoid)
4. 2,247.970 98,463.226 ↓ 2.1 10,019,768 1

Merge Left Join (cost=1,361,007.92..4,800,414.10 rows=4,697,571 width=363) (actual time=11,489.484..98,463.226 rows=10,019,768 loops=1)

  • Merge Cond: (ecrituresallinfo0digitfacture.id_ecritures = mouvementswithpool_1.ecritures_id)
5. 3,055.329 91,392.911 ↓ 2.1 10,019,768 1

Merge Left Join (cost=1,159,967.60..4,517,715.47 rows=4,697,571 width=263) (actual time=10,950.768..91,392.911 rows=10,019,768 loops=1)

  • Merge Cond: (ecrituresallinfo0digitfacture.id_ecritures = mouvementswithpool.ecritures_id)
6. 3,849.182 12,045.326 ↑ 1.0 4,697,489 1

Sort (cost=1,159,967.04..1,171,710.96 rows=4,697,571 width=187) (actual time=10,950.657..12,045.326 rows=4,697,489 loops=1)

  • Sort Key: ecrituresallinfo0digitfacture.id_ecritures
  • Sort Method: external merge Disk: 733,176kB
7. 417.255 8,196.144 ↑ 1.0 4,697,489 1

Subquery Scan on ecrituresallinfo0digitfacture (cost=0.00..205,877.35 rows=4,697,571 width=187) (actual time=0.037..8,196.144 rows=4,697,489 loops=1)

8. 7,778.889 7,778.889 ↑ 1.0 4,697,489 1

Seq Scan on ecrituresallinfo0 (cost=0.00..158,901.64 rows=4,697,571 width=187) (actual time=0.035..7,778.889 rows=4,697,489 loops=1)

9. 1,819.745 76,292.256 ↓ 3.7 10,006,584 1

Materialize (cost=0.56..3,300,159.36 rows=2,728,098 width=80) (actual time=0.107..76,292.256 rows=10,006,584 loops=1)

10. 63,485.182 74,472.511 ↓ 3.7 10,006,584 1

GroupAggregate (cost=0.56..3,266,058.13 rows=2,728,098 width=120) (actual time=0.103..74,472.511 rows=10,006,584 loops=1)

  • Group Key: mouvementswithpool.ecritures_id, mouvementswithpool.pool_name
11. 10,987.329 10,987.329 ↑ 1.0 25,909,859 1

Index Scan using text_index2 on mouvementswithpool (cost=0.56..2,784,785.28 rows=25,942,393 width=36) (actual time=0.077..10,987.329 rows=25,909,859 loops=1)

  • Filter: (pool_name IS DISTINCT FROM 'Accounts payable'::text)
  • Rows Removed by Filter: 1,371,121
12. 299.956 4,822.345 ↓ 1.9 2,098,550 1

Materialize (cost=201,040.32..257,472.62 rows=1,078,566 width=104) (actual time=538.713..4,822.345 rows=2,098,550 loops=1)

13. 3,798.549 4,522.389 ↓ 1.2 1,311,931 1

GroupAggregate (cost=201,040.32..243,990.55 rows=1,078,566 width=144) (actual time=538.712..4,522.389 rows=1,311,931 loops=1)

  • Group Key: mouvementswithpool_1.ecritures_id, mouvementswithpool_1.pool_name
14. 375.580 723.840 ↓ 1.0 1,371,121 1

Sort (cost=201,040.32..204,386.79 rows=1,338,587 width=33) (actual time=538.682..723.840 rows=1,371,121 loops=1)

  • Sort Key: mouvementswithpool_1.ecritures_id
  • Sort Method: quicksort Memory: 156,271kB
15. 348.260 348.260 ↓ 1.0 1,371,121 1

Index Scan using test_index on mouvementswithpool mouvementswithpool_1 (cost=0.56..64,823.83 rows=1,338,587 width=33) (actual time=0.017..348.260 rows=1,371,121 loops=1)

  • Index Cond: (pool_name = 'Accounts payable'::text)
16. 1,490.072 5,291.442 ↓ 3.2 6,399,642 1

Sort (cost=451,653.16..456,719.76 rows=2,026,639 width=36) (actual time=4,418.400..5,291.442 rows=6,399,642 loops=1)

  • Sort Key: entriessumpooltva.ecritures_autoid
  • Sort Method: quicksort Memory: 217,323kB
17. 170.828 3,801.370 ↓ 1.3 2,539,058 1

Subquery Scan on entriessumpooltva (cost=193,756.69..239,356.07 rows=2,026,639 width=36) (actual time=2,498.778..3,801.370 rows=2,539,058 loops=1)

18. 2,997.097 3,630.542 ↓ 1.3 2,539,058 1

HashAggregate (cost=193,756.69..219,089.67 rows=2,026,639 width=44) (actual time=2,498.778..3,630.542 rows=2,539,058 loops=1)

  • Group Key: mouvementswithpool_2.ecritures_id, mouvementswithpool_2.pool_name
19. 633.445 633.445 ↓ 1.0 3,507,276 1

Index Scan using test_index on mouvementswithpool mouvementswithpool_2 (cost=0.56..167,771.55 rows=3,464,685 width=18) (actual time=0.019..633.445 rows=3,507,276 loops=1)

  • Index Cond: (pool_name = 'VAT'::text)
20. 0.010 21,012.324 ↓ 0.0 0 1

Sort (cost=1,526,411.43..1,526,747.56 rows=134,451 width=68) (actual time=21,012.324..21,012.324 rows=0 loops=1)

  • Sort Key: gap_order_invoice2.ecritures_id
  • Sort Method: quicksort Memory: 25kB
21. 0.002 21,012.314 ↓ 0.0 0 1

Subquery Scan on gap_order_invoice2 (cost=1,510,588.75..1,514,958.41 rows=134,451 width=68) (actual time=21,012.314..21,012.314 rows=0 loops=1)

22. 18,761.533 21,012.312 ↓ 0.0 0 1

HashAggregate (cost=1,510,588.75..1,513,613.90 rows=134,451 width=100) (actual time=21,012.312..21,012.312 rows=0 loops=1)

  • Group Key: mouvementswithpool_3.ecritures_id
  • Filter: ((COALESCE(sum(CASE WHEN (mouvementswithpool_3.pool_name = 'Accounts payable'::text) THEN mouvementswithpool_3.montant_signe ELSE NULL::numeric END), '0'::numeric) IS DISTINCT FROM '0'::numeric) AND (COALESCE(sum(CASE WHEN (mouvementswithpool_3.pool_name = 'Suppliers - Accrued invoices'::text) THEN mouvementswithpool_3.montant_signe ELSE NULL::numeric END), '0'::numeric) IS DISTINCT FROM '0'::numeric) AND (COALESCE(sum(CASE WHEN (mouvementswithpool_3.pool_name = 'VAT'::text) THEN mouvementswithpool_3.montant_signe ELSE NULL::numeric END), '0'::numeric) = '0'::numeric))
  • Rows Removed by Filter: 4,697,489
23. 2,250.779 2,250.779 ↑ 1.0 27,280,980 1

Seq Scan on mouvementswithpool mouvementswithpool_3 (cost=0.00..760,361.80 rows=27,280,980 width=18) (actual time=0.011..2,250.779 rows=27,280,980 loops=1)

24. 0.192 0.390 ↑ 1.0 1,819 1

Hash (cost=47.19..47.19 rows=1,819 width=26) (actual time=0.390..0.390 rows=1,819 loops=1)

  • Buckets: 2,048 Batches: 1 Memory Usage: 125kB
25. 0.198 0.198 ↑ 1.0 1,819 1

Seq Scan on plan_comptable (cost=0.00..47.19 rows=1,819 width=26) (actual time=0.012..0.198 rows=1,819 loops=1)