Re: How to find entries missing in 2nd table?

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: How to find entries missing in 2nd table?
Дата
Msg-id 20060713163352.65195.qmail@web31801.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: How to find entries missing in 2nd table?  ("Aaron Bono" <postgresql@aranya.com>)
Список pgsql-sql
> > > > SELECT controller_id FROM control
> > > > WHERE controller_id NOT IN
> > > > (SELECT DISTINCT controller_id FROM datapack);
> > > The DISTINCT is not necessary.  I have heard with Oracle that DISTINCT
> > is a
> > > huge performance problem.  Is that true on PostgreSQL also?
> >
> > From my experience, it does not preform as well as the standard group by
> > clause. I noticed a ~20%
> > increase in query run times.
> 
> 
> 
> So in that case this would be better:
> 
> SELECT controller_id FROM control
> WHERE controller_id NOT IN
> (SELECT controller_id FROM datapack);
> 
> or
> 
> SELECT controller_id FROM control
> WHERE controller_id NOT IN
> (SELECT controller_id FROM datapack GROUP BY controller_id);


Well in this case,  the group by or distinct is simple not needed for the query to preform
correctly.  The additional group by clause in the second query could cause it to preform
additional processing which "may" cause it to preform slower.

Regards,

Richard Broersma Jr.


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Aaron Bono"
Дата:
Сообщение: Re: How to find entries missing in 2nd table?
Следующее
От: "Daniel Caune"
Дата:
Сообщение: Trigger, record "old" is not assigned yet