Re: WITH clause in CREATE STATISTICS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Subject: Re: WITH clause in CREATE STATISTICS
Date: 2017-05-04 21:13:37
Message-ID: 30288.1493932417@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> Here's a patch implementing this idea. From gram.y's comment, the
> support syntax is now:

> /*****************************************************************************
> *
> * QUERY :
> ! * CREATE STATISTICS stats_name [(stat types)] arguments
> !
> ! * where 'arguments' can be one or more of:
> ! * { ON (columns)
> ! * | FROM relations
> ! * | WITH (options)
> ! * | WHERE expression }

> Note that I removed the USING keyword in the stat types list, and also
> made it mandatory that that list appears immediately after the new stats
> name. This should make it possible to have USING in the relation list
> (the FROM clause), if we allow explicit multiple relations with join
> syntax there. The other options can appear in any order.

Hmm ... I'm not sure that I buy that particular argument. If you're
concerned that the grammar could not handle "FROM x JOIN y USING (z)",
wouldn't it also have a problem with "FROM x JOIN y ON (z)"?

It might work anyway, since the grammar should know whether ON or USING
is needed to complete the JOIN clause. But I think you'd better check
whether the complete join syntax works there, even if we're not going
to support it now.

I'm not against what you've done here, because I had no love for USING
in this context anyway; it conveys approximately nothing to the mind
about what is in the list it's introducing. But I'm concerned whether
we're boxing ourselves in by using ON.

Actually, "ON" doesn't seem all that mnemonic either. Maybe "FOR"
would be a good substitute, if it turns out that "ON" has a problem?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sven R. Kunze 2017-05-04 21:23:56 Re: Missing feature in Phrase Search?
Previous Message Robert Haas 2017-05-04 21:10:58 Re: what's up with IDENTIFIER_LOOKUP_EXPR?