On Sat, Feb 2, 2019 at 02:01:01PM -0500, Tom Lane wrote: > I wrote: > > I propose that we implement and document this as > > WITH ctename AS [ MATERIALIZE { ON | OFF } ] ( query ) > > which is maybe a bit clunky but not awful, and it would leave room > > to generalize it to "AS [ optionname optionvalue [ , ... ] ]" if we > > ever need to. Looking at the precedent of e.g. EXPLAIN, we could > > probably allow just "MATERIALIZE" as well, with the boolean value > > defaulting to true. > > In hopes of moving things along, here's a version of the patch that > does it like that. This demonstrates that, in fact, we can accept > "keyword [value] [, ...]" style options without any parens and > there's no syntax conflict. We'd have to work a bit harder on the > actual code in gram.y if we wanted to handle multiple options, > but the Bison productions will work. > > There's nothing particularly stopping us from accepting > "materialized" with a D in this syntax, instead of or in addition > to "materialize"; though I hesitate to mention it for fear of > another round of bikeshedding.
I think "materialize" is the right word since "materialized" would be past tense. > After further reflection I really don't like Andrew's suggestion > that we not document the rule that multiply-referenced CTEs won't > be inlined by default. That would be giving up the principle > that WITH calculations are not done multiple times by default, > and I draw the line at that. It's an often-useful behavior as > well as one that's been documented from day one, so I do not accept > the argument that we might someday override it on the basis of > nothing but planner cost estimates. Thinking of the history of documenting optimizer issues, I think we should document when CTEs are inlined by default, because the user will want to know when they should override the default behavior. When we didn't document how PREPARED queries worked, we got many questions about odd query performance until we finally documented it in 2016 in commit fab9d1da4a213fab08fe2d263eedf2408bc4a27a. If we change the inlining behavior later, we can update the docs. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +