Re: Adding missing FROM clause - thanks or no thanks? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Adding missing FROM clause - thanks or no thanks?
Date
Msg-id 200401271834.i0RIY3Q09540@candle.pha.pa.us
Whole thread Raw
In response to Adding missing FROM clause - thanks or no thanks?  (John Siracusa <siracusa@mindspring.com>)
Responses Re: Adding missing FROM clause - thanks or no thanks?
List pgsql-general
John Siracusa wrote:
> I recently had a problem where a bunch of postgres backends were taking up
> huge amounts of CPU time.  I found a bunch of log messages like this:
>
> NOTICE:  adding missing FROM-clause entry for table "b"
>
> Which I eventually tracked to an improperly constructed query that reduced
> to something like this:
>
> select a1, a2 FROM a WHERE a1 = '...' AND b.b1 = '...';
>
> Table b is pretty big and the conditions were such that it was (apparently)
> doing a join of every row in a with every possible row of b.  That's
> certainly now what I wanted.
>
> Anyway, I fixed the query construction bug, but I have a question: is this
> "adding missing FROM-clause entry" behavior part of the SQL standard(s) or a
> "feature" of Postgres?  Prior to seeing this, I'd have expected a query like
> the above to cause a fatal error in the parsing stage.  Put another way, can
> someone give me an example of when this behavior is useful or desirable?

It is a PostgreSQL extension and can be turned off with a
postgresql.conf variable or via SET:

    add_missing_from = false

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Adding missing FROM clause - thanks or no thanks?
Next
From: John Siracusa
Date:
Subject: Re: Adding missing FROM clause - thanks or no thanks?