3 ms·
Can you point to some good resources on how to write better postgres queries? Or give examples of common pitfalls?
by bakuninsbart 3y ago
Can you point to some good resources on how to write better postgres queries? Or give examples of common pitfalls?
- lordnacho 3y agoI would guess the most common pitfall is either not having indices or having the wrong kind of index for your query.
- Ialdaboth 3y agoAn old classic but too many indices can be harmful too.
- Zanfa 3y agoI 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 https://www.postgresql.org/docs/current/sql-explain.html
- bbojan 3y agoStart 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.
- vberg 3y agoI am using https://explain.dalibo.com/ https://explain.dalibo.com/ for that exact purpose and it does a great job highlighting the perfs issues.
- deleted 3y ago[deleted]
- branko_d 3y agohttps://use-the-index-luke.com/ https://use-the-index-luke.com/