Re: Underestimated number of output rows with an aggregate function

2023-10-16 Thread Philippe BEAUDOIN
Le 15/10/2023 à 18:37, Tom Lane a écrit : Philippe BEAUDOIN writes: During my analysis, I realized that the output rows estimate of the second CTE is really bad, leading to a bad plan for the next CTE. I reproduced the issue in a very small test case with a simplified query. Attached is a shell

Re: Underestimated number of output rows with an aggregate function

2023-10-15 Thread Tom Lane
Philippe BEAUDOIN writes: > During my analysis, I realized that the output rows estimate of the > second CTE is really bad, leading to a bad plan for the next CTE. > I reproduced the issue in a very small test case with a simplified > query. Attached is a shell script and its output. Yeah. If

Underestimated number of output rows with an aggregate function

2023-10-15 Thread Philippe BEAUDOIN
Hi all, Working on the emaj extension (for the curious ones, https://emaj.readthedocs.io/en/latest/ and https://github.com/dalibo/emaj), I recently faced a performance problem when querying and aggregating data changes. A query with 3 CTE has a O^2 behavior (https://explain.dalibo.com/plan/1d