Re: Bad selectivity estimate when using a sub query to determine WHERE condition

2020-02-12 Thread Chris Borckholder
Using a column to mark rolled up rows might have been a better choice, but there are unfortunately some regulatory requirements that require that table to be immutable. I'm not sure about the implications w.r.t. auto vacuum, which is already a consideration for us due to the sheer size of the table

Re: Bad selectivity estimate when using a sub query to determine WHERE condition

2020-02-12 Thread Chris Borckholder
On Mon, Feb 10, 2020 at 4:39 PM Tom Lane wrote: > > Well, it's not that hard to get rid of that scalar sub-select: since > you're already relying on current_rollup to produce exactly one row, > you could write a plain join instead, something like > Using a join instead of the sub-select did alrea