Re: using NOLOCK cause Cartesian joins

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Roger Gordon <Roger(at)emojo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: using NOLOCK cause Cartesian joins
Date: 2003-11-12 20:13:45
Message-ID: 20031112120720.B15835@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 12 Nov 2003, Roger Gordon wrote:

> When we use WITH (NOLOCK) at the end of table list in a SELECT query, a
> Cartesian join is returned (i.e. approximately 6,500 records instead of
> 57, which is distressing.

I'm guessing you mean something like:
select *
from table1, table2 WITH (NOLOCK)
where table1.foo=table2.bar;
?

If so, it should be giving you a notice like:
adding missing FROM-clause entry for table "table2"
because you've aliased table2 as the name WITH and the first column
of said table as NOLOCK (if I'm remembering the details correctly)
so table2 isn't in scope in the where clause.

As far as we can tell a query like the above is technically illegal in
SQL but 7.3 and earlier will always add an extra entry as if you had
done from table1, table2 WITH (NOLOCK), table2. 7.4 has an option to
instead error.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adam Ruth 2003-11-12 20:13:52 Re: Column Sizes
Previous Message Greg Stark 2003-11-12 20:13:39 Re: using NOLOCK cause Cartesian joins