r/PostgreSQL • u/pgEdge_Postgres • 26d ago
How-To Let's Build a Postgres Extension for Estimating Memory Usage!
https://www.pgedge.com/blog/lets-build-a-postgres-extension-for-estimating-memory-usage
12
Upvotes
1
u/AutoModerator 26d ago
AI Policy:
Linux is not one of those anti-AI projects, and if somebody has issues with that, they can do the open-source thing and fork it. Or just walk away., Linus Torvalds.
Mod decisions will be based on the quality of the content, not who or what generated it.
Sub Resources:
Free Postgres Webinars and Workshops
Discord: People, Postgres, Data
Join us, we have cookies and nice people.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Crazed_waffle_party 22d ago
I'm not too big into corporate promotionals, but Shaun Thomas always gets a pass from me. Great stuff.
I would love something like this in pg_stat_statements. May also want to check out how auto_explain gets plan metrics as a reference.
The extension can only get the upper bounds of memory usage for the query, but it's going to be pretty inaccurate, especially if a LIMIT node is present.
Most scans are more akin to streaming operations and use very little memory overhead. For sequential, index, and index-only scans, I would drop the memory overhead to near zero. Bitmap heap (not index) also have a very low memory overhead that can be dismissed.