News for hackers. Stuff that matters.
Re:The Many Faces of Distinct in PostgreSQL by paulddraper on Monday May 22, 2023 @11:13AM (#36032505)
It's true.

Fortunately the records are locked, so a second query will pick them up. Still sad tho.

Prepared statements work fine with CTEs.

Re:The Many Faces of Distinct in PostgreSQL by inferiorhuman on Monday May 22, 2023 @07:11PM (#36037885)

  Prepared statements work fine with CTEs.
My experience was that this was not the case. Basically the CTE was materialized and the variables were resolved as part of PREPARE, so each invocation got the same values. I couldn't find the blurb I'd read previously but I did a little digging today and it looks like maybe NOT MATERIALIZED would fix the problem?
Re:The Many Faces of Distinct in PostgreSQL by paulddraper on Monday May 22, 2023 @10:09PM (#36038973)
CTEs used to be an optimization fence, with or without prepared statements.

PG 14 or something changed that.