Most common one I’ve seen in the last 5-10 years: using a JSON column instead of putting in a lookup table, or instead of properly analyzing and normalizing your data. That’s a mistake that you’ll be paying for for a while.
How much slower is it in your experience?
Ways to shoot yourself in the foot with Postgres
321–329 of 329 posts
Re: Ways to shoot yourself in the foot with Postgres
#322Earlier quoted context omitted.
> it has many caveats and shouldn't be used often I’d argue it isn’t used enough given its isolation advantages
Serializable mode is only useful in low throughput cases. You take a big performance hit and can easily have a bunch of queries waiting one each other until the queue fills up. I haven't used it in forever, I just make sure my stuff works with the default isolation mode. You also can't slap it on like a band-aid for unsure users. The DB client has to implement retry logic, which most Postgres libs don't seem to have,…
I’m not sure how you could detect such anomalies though without running the same serialization checking logic within postgres
Re: Ways to shoot yourself in the foot with Postgres
#323Earlier quoted context omitted.
This is ancient knowledge and I would have agreed with you 15 years ago, today the only reason to not use an ORM is analytical queries. Since the Postgres planner doesn't really allow you to tune your query there aren't many ways to construct your query in a way which would to a much worse execution plan. Over the years we have migrated most raw SQL back to using the ORM without taking performance hits, pretty much t…
Do CTEs actually force an order of execution? I thought the point was that they are declarative
Re: Ways to shoot yourself in the foot with Postgres
#324Earlier quoted context omitted.
How much SQL Server costs?
You can google it, but the short answer is Enterprise Edition is on the order of tens of thousands of dollars per CPU.
Re: Ways to shoot yourself in the foot with Postgres
#325Earlier quoted context omitted.
What do you do if you need to check index ideas, or new table design?
Generally indexes are cheap, if built concurrently, so I often build all the possible indexes (for relatively modest sized data types, load, and tables) and look at the planner statistics in production to validate which indexes are useful for the query load. That only works if you have a read-heavy usage pattern, for write-heavy usage patterns it can sometimes be better not to have an index at all (one of the things…
Re: Ways to shoot yourself in the foot with Postgres
#326Earlier quoted context omitted.
Serializable mode is only useful in low throughput cases. You take a big performance hit and can easily have a bunch of queries waiting one each other until the queue fills up. I haven't used it in forever, I just make sure my stuff works with the default isolation mode. You also can't slap it on like a band-aid for unsure users. The DB client has to implement retry logic, which most Postgres libs don't seem to have,…
Yes you take the performance hit, but many workloads are low enough throughput for it to be completely fine. I’m not sure how you could detect such anomalies though without running the same serialization checking logic within postgres
For the sampling, you'd have to run the same logic. The idea is just to do it infrequently as to not totally ruin your overall performance. Idk if this would work.
Re: Ways to shoot yourself in the foot with Postgres
#327The main tip I learned from using PostgreSQL (or relational databases in general) is never use an ORM . They cause far more trouble than they are worth and it's far easier to see what is going on when you're writing SQL queries directly.
It's not just the fact that it hides the queries. ORMs are all-around cancerous. I've been on several teams that's tried to use one, and there were regrets every time.
Re: Ways to shoot yourself in the foot with Postgres
#328Earlier quoted context omitted.
Yes you take the performance hit, but many workloads are low enough throughput for it to be completely fine. I’m not sure how you could detect such anomalies though without running the same serialization checking logic within postgres
Actually I agree. There are probably lots of low-throughput, high-consequence things like that. For the sampling, you'd have to run the same logic. The idea is just to do it infrequently as to not totally ruin your overall performance. Idk if this would work.
Re: Ways to shoot yourself in the foot with Postgres
#329Earlier quoted context omitted.
There are some good business process management tools that could manage that mapping instead of the clever SP, but you have me intrigued. Are there any links that could be helpful to work through the programs and caveats of such a SP? Part of it for me is creating a table that can store the process in the database to be able to traverse it reasonably.
It was basically a more complicated version of this: https://stackoverflow.com/questions/68809885/how-to-select-f...