Re:Nine ways to shoot yourself in the foot with PostgreSQL
by bakuninsbart on Tuesday April 25, 2023 @04:50AM
(#35698036)
Can you point to some good resources on how to write better postgres queries? Or give examples of common pitfalls?
[ Parent
| on HN ]
Re:Nine ways to shoot yourself in the foot with PostgreSQL
by Zanfa on Tuesday April 25, 2023 @05:23AM
(#35698204)
I don't have any other good recommendations other than learning how to read and use EXPLAIN [1]. This should typically be the first tool when you have a slow query.
[1] https://www.postgresql.org/docs/current/sql-explain.html
Re:Nine ways to shoot yourself in the foot with PostgreSQL
by bbojan on Tuesday April 25, 2023 @05:28AM
(#35698232)
Start with EXPLAIN ANALYZE then work from there. You can use tools where you paste the output of it and it shows you the data in a more easy to understand format.
Re:Nine ways to shoot yourself in the foot with PostgreSQL
by vberg on Tuesday April 25, 2023 @08:25AM
(#35699502)
I am using https://explain.dalibo.com/ for that exact purpose and it does a great job highlighting the perfs issues.
Re:Nine ways to shoot yourself in the foot with PostgreSQL
by lordnacho on Tuesday April 25, 2023 @04:55AM
(#35698066)
I would guess the most common pitfall is either not having indices or having the wrong kind of index for your query.
Re:Nine ways to shoot yourself in the foot with PostgreSQL
by Ialdaboth on Tuesday April 25, 2023 @05:00AM
(#35698079)
An old classic but too many indices can be harmful too.