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

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

2020-02-12 Thread Chris Borckholder
f the table. I'm planning to partition the table as soon as we finish upgrading to v11. Thanks for your insight! Best Regards Chris On Mon, Feb 10, 2020 at 8:13 PM Justin Pryzby wrote: > On Mon, Feb 10, 2020 at 11:34:01AM +0100, Chris Borckholder wrote: > > I have a large table of im

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

2020-02-10 Thread Chris Borckholder
Hi, I have a large table of immutable events that need to be aggregated regularly to derive statistics. To improve the performance, that table is rolled up every 15minutes, so that online checks can aggregate rolled up data and combine it with latest events created after the last roll up. To impl