Re: Plan selection based on worst case scenario

2024-05-29 Thread Chema
Hey Darwin, you don't mention your version or config, but it's always good to go through https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server I used to notice huge improvements in plans when increasing statistics in relevant columns, as already suggested by David, and also by lowering r

Re: Plan selection based on worst case scenario

2024-05-29 Thread David Rowley
On Thu, 30 May 2024 at 13:03, Darwin O'Connor wrote: > Is there a PostgreSQL setting that can control how it judges plans? There's nothing like that, unfortunately. > Here is a recent example of a query that finds the last time at a stop > filtered for a certain route it has to look up another

Plan selection based on worst case scenario

2024-05-29 Thread Darwin O'Connor
I have been having an ongoing problem for years with PostgreSQL selecting very poor plans when running queries. It does things like doing a table scan of gigabyte size tables to generate a hash table rather than use a suitable index. When I disable enough features that it generates a sensible plan