Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show heap fetches as percent % #589

Closed
pgiraud opened this issue Mar 23, 2023 · 3 comments
Closed

Show heap fetches as percent % #589

pgiraud opened this issue Mar 23, 2023 · 3 comments

Comments

@pgiraud
Copy link
Member

pgiraud commented Mar 23, 2023

It would be nice to get the percentage of rows that are read from the heap.
https://explain.dalibo.com/plan/da11bg7302g59e03#plan/node/11

Plan comes from https://twitter.com/pgMustard/status/1636800885320712216

Also, the warning level may need some adjustments.

@Krysztophe
Copy link

The % of blocks is perhaps more important, but you can't have that.

The threshold should be rather low. A rather small proportion is already the sign that you need a VACUUM.

I hope to find time to test soon.

@Krysztophe
Copy link

I confirm: a few percent of heap fetches is already a disaster.

Examples (in the worst case: old computer, default configuration, not enough RAM, slow HDD) :

  • clean table after an INSERT, vacuumed:
                                                     QUERY PLAN                                                      
═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
 Index Only Scan using demoheapfetches_i_j_idx on demoheapfetches (actual time=0.984..1477.217 rows=1000000 loops=1)
   Heap Fetches: 0
   Buffers: shared hit=601242 read=2735
 Planning:
   Buffers: shared hit=6
 Planning Time: 0.273 ms
 Execution Time: 1751.430 ms
  • 10% new lines, autovacuum is lagging: execution time +100 %
                                                     QUERY PLAN                                                      
═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
 Index Only Scan using demoheapfetches_i_j_idx on demoheapfetches (actual time=0.066..2935.111 rows=1100000 loops=1)
   Heap Fetches: 100001
   Buffers: shared hit=745883 read=2486
 Planning Time: 0.186 ms
 Execution Time: 3365.290 ms
  • 30% new lines, autovacuum still lagging: execution time × 78 !!
                                                      QUERY PLAN                                                       
═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
 Index Only Scan using demoheapfetches_i_j_idx on demoheapfetches (actual time=0.069..136461.243 rows=1300000 loops=1)
   Heap Fetches: 300001
   Buffers: shared hit=894764 read=112141
 Planning Time: 0.205 ms
 Execution Time: 136901.507 ms
  • after a vacuum: almost back to normal
                                                     QUERY PLAN                                                      
═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
 Index Only Scan using demoheapfetches_i_j_idx on demoheapfetches (actual time=0.112..2040.199 rows=1300000 loops=1)
   Heap Fetches: 0
   Buffers: shared hit=811331 read=2857
 Planning:
   Buffers: shared hit=15 read=2
 Planning Time: 349.595 ms
 Execution Time: 2405.755 ms

pgiraud added a commit that referenced this issue Aug 22, 2024
This helps highlighting heap fetches when there's only a few, which
can already have significant impact on performance.

See #589
pgiraud added a commit that referenced this issue Aug 22, 2024
This helps highlighting heap fetches when there's only a few, which
can already have significant impact on performance.

See #589
@pgiraud
Copy link
Member Author

pgiraud commented Aug 22, 2024

Won't fix. This doesn't seem very relevant. Instead a warning is displayed each times there's at least one heap fetch.

@pgiraud pgiraud closed this as completed Aug 22, 2024
@pgiraud pgiraud closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants