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

2020-12-29 Thread Christopher Baines
Greg Spiegelberg writes: > 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.depe

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

2020-12-29 Thread Christopher Baines
Michael Lewis writes: > On Mon, Dec 28, 2020 at 7:51 AM Christopher Baines wrote: > >> derivation_inputs: >> COUNT(*): 285422539 >> reltuples: 285422528 >> >> derivation_id: >> COUNT(DISTINCT): 7508610 >>

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