Re: Bad query plan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



=?KOI8-R?B?5M3J1NLJyiD3wdPJzNjF1w==?= <dmitry.vasil@xxxxxxxxx> writes:
> explain analyze insert into large(id) select id from small where id
> not in(select id from large);
> [ crummy plan ]
> explain analyze insert into large(id) select id from small where not
> exists (select id from large l where small.id=l.id);
> [ better plan ]
> Both queries are semantically the same.

No, they are not.  NOT IN is hard to optimize because it has strange
behaviors with nulls in the data.  Use the NOT EXISTS formulation.

			regards, tom lane

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux