Postgres, MVCC, and you or, Why COUNT(*) is slow (David Wolever)
Vložit
- čas přidán 4. 07. 2024
- It's hard to be a developer today without using a database… but they're often surrounded by an air of reverent mystery.
One of those mysteries is why it's so slow to count all the rows in a table using COUNT(*). After all, it's just a matter of walking a b-tree and counting leaves… and that should be trivial to optimize!
In this talk I'll answer the question of "why COUNT(*) is slow" by taking a deep dive into the the internals of Postgres' MVCC implementation, looking at:
The question of "why COUNT(*) is slow"
The on-disk storage layout and why, under the hood, it's not a b-tree
What Postgres means by MVCC, with examples of the utility of transactions
Introduce xid, xmin, xmax
Discuss tuple visibility
Explain VACUUM and xid wraparound
Show off transaction isolation levels
This talk is accessible to anyone who's used an SQL database, with enough depth that experienced developers will find some interesting tidbits.
Presentation page -- 2017.pycon.ca/schedule/25/ - Věda a technologie
I think my life has slightly changed to the better after watching this :D Thank you !
Great presentation David, very understandable.
Introduction level talk..
This was really informative, thanks David!
This is a great talk, thanks for posting it!
This is a great and informative lecture!
Thank you for awesome presentations, it was really useful and informative.
Amazing video, must watch again
Amazing explaination
excellent presentation.
great session!!
Great breakdown
Dude great explanation! 👍
Great informative
I love it, thanx man, it was interesting
best explanation ever!
david thanks for your presentation.....however if i really need to count the total number of rows of a table which has over 10 million records, what should i do?
maintain it as single value in another table ;)
If you semi recently performed "analyze" you probably have count number saved somewhere in statistics of that table
This was really informative... The sound and picture were not synced!
cool
From the video blog.sentry.io/2015/07/23/transaction-id-wraparound-in-postgres.html