Re: Slow recursive CTE query questions, with row estimate and n_distinct issues

2020-12-28 Thread Greg Spiegelberg
On Mon, Dec 28, 2020 at 7:51 AM Christopher Baines wrote: > Hi, > > I have a performance problem with a query. I've uploaded it, along with > the EXPLAIN ANALYZE output here [1]. > > 1: https://explain.depesz.com/s/w5vP > > I think the query is taking longer than I'd like, as PostgreSQL is not >

Re: Slow recursive CTE query questions, with row estimate and n_distinct issues

2020-12-28 Thread Michael Lewis
On Mon, Dec 28, 2020 at 7:51 AM Christopher Baines wrote: > derivation_inputs: > COUNT(*): 285422539 > reltuples: 285422528 > > derivation_id: > COUNT(DISTINCT): 7508610 > n_distinct: 4336644 (~57% of the true value) > > derivation_output_id: > COUNT(DISTINCT): 5539406 >

Slow recursive CTE query questions, with row estimate and n_distinct issues

2020-12-28 Thread Christopher Baines
Hi, I have a performance problem with a query. I've uploaded it, along with the EXPLAIN ANALYZE output here [1]. 1: https://explain.depesz.com/s/w5vP I think the query is taking longer than I'd like, as PostgreSQL is not generating a great plan, in particular the estimated rows in parts of the p