explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1ji6

Settings
# exclusive inclusive rows x rows loops node
1. 0.141 854.241 ↑ 1.0 200 1

Sort (cost=51,999.62..52,000.12 rows=200 width=82) (actual time=854.223..854.241 rows=200 loops=1)

  • Sort Key: (rank() OVER (?))
  • Sort Method: quicksort Memory: 51kB
2. 0.607 854.100 ↑ 1.0 200 1

Hash Right Join (cost=51,943.41..51,991.98 rows=200 width=82) (actual time=853.162..854.100 rows=200 loops=1)

  • Hash Cond: (m.id = d.id_medicamento)
3. 0.821 0.821 ↑ 1.0 2,183 1

Seq Scan on medicamentos m (cost=0.00..42.83 rows=2,183 width=34) (actual time=0.468..0.821 rows=2,183 loops=1)

4. 0.151 852.672 ↑ 1.0 200 1

Hash (cost=51,940.91..51,940.91 rows=200 width=52) (actual time=852.672..852.672 rows=200 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 21kB
5. 0.517 852.521 ↑ 1.0 200 1

Limit (cost=51,935.41..51,938.91 rows=200 width=52) (actual time=851.506..852.521 rows=200 loops=1)

6. 0.429 852.004 ↑ 10.9 200 1

WindowAgg (cost=51,935.41..51,973.61 rows=2,183 width=52) (actual time=851.504..852.004 rows=200 loops=1)

7. 2.347 851.575 ↑ 10.9 200 1

Sort (cost=51,935.41..51,940.86 rows=2,183 width=44) (actual time=851.475..851.575 rows=200 loops=1)

  • Sort Key: (sum(d.dispensaciones)) DESC
  • Sort Method: quicksort Memory: 267kB
8. 8.374 849.228 ↑ 1.0 2,183 1

Finalize GroupAggregate (cost=51,721.56..51,814.33 rows=2,183 width=44) (actual time=839.782..849.228 rows=2,183 loops=1)

  • Group Key: d.id_medicamento
9. 6.564 840.854 ↓ 1.5 6,549 1

Sort (cost=51,721.56..51,732.47 rows=4,366 width=44) (actual time=839.756..840.854 rows=6,549 loops=1)

  • Sort Key: d.id_medicamento
  • Sort Method: quicksort Memory: 704kB
10. 20.099 834.290 ↓ 1.5 6,549 1

Gather (cost=50,993.70..51,457.59 rows=4,366 width=44) (actual time=818.530..834.290 rows=6,549 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
11. 315.205 814.191 ↑ 1.0 2,183 3 / 3

Partial HashAggregate (cost=49,993.70..50,020.99 rows=2,183 width=44) (actual time=810.425..814.191 rows=2,183 loops=3)

  • Group Key: d.id_medicamento
12. 498.986 498.986 ↑ 1.2 298,598 3 / 3

Parallel Seq Scan on dispensaciones_cache d (cost=0.00..46,386.66 rows=360,704 width=20) (actual time=117.481..498.986 rows=298,598 loops=3)

  • Filter: ((administraciond_normalizada >= 20180101) AND (administraciond_normalizada <= 20181231) AND (id_hospital = 290))
  • Rows Removed by Filter: 287230
Planning time : 0.323 ms
Execution time : 854.444 ms