Postgresql tricks | Lanre Adelowo
I was recently caught up in a Twitter thread where someone suggested using a materialized view for calculating some value from another table. I suggested using a TRIGGER instead as it happens in the same transaction. Someone DM'd me saying it solved a problem he has been having at work with poor performance while they are trying to update another table as they were doing it via code, fetching all data, then iterating to calcualate the difference. Asides that, it meant the table was out of sync when they get concurrent requests. I then decided to list some of my favorite and useful postgresql features. Might find them useful. Might not :) but here is a tiny list: weird bug, links to sections do not work, so you might need to scroll. Currently fixing as soon as i can find time. apologies :))) please don't do this in production lmao so as not to make people start thinking silly data is still stored. I really hope you hate nulls as much as I do. But sometimes we just need to keep them arou
back May 11, 2023 Postgresql tricks 10 min read Tags database I was recently caught up in a Twitter thread where someone suggested using a materialized view for calculating some value from another table. I suggested using a TRIGGER instead as it happens in the same transaction. Someone DM'd me saying it solved a problem he has been having at work with poor performance while they are trying to update another table as they were doing it via code, fetching all data, then iterating to calcualate the difference. Asides that, it meant the table was out of sync when they get concurrent requests. I th
related reading
- Nine ways to shoot yourself in the foot with PostgreSQLphilbooth.me
- The only scalable delete in Postgres is DROP TABLE — PlanetScaleplanetscale.com
- An Overview of Distributed PostgreSQL... | Crunchy Data Blogcrunchydata.com
- The startup's Postgres survival guidehatchet.run
- Databases are Fucking Stupid | Probably Danceprobablydance.com
- Making Postgres 42,000x slower because I am unemployedbyteofdev.com
- Patching the PostgreSQL JDBC Driverengineering.zalando.com
- Blog — PlanetScaleplanetscale.com
- you won't forget how postgres works after thisyoutube.com
- Just Use Postgres for Everything | Amazing CTOamazingcto.com
- GitHub - jorzel/concurrency-control: In this repo I would like to show 4 strategies of concurrency control for writing data using Python SQLAlchemy ORM and PostgresSQL (however this examples could be easily transformed to plain SQL).github.com
- PostgreSQL rocks, except when it blocks: Understanding locks - Citus Datacitusdata.com