Re: When does a check constraint execute?

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: When does a check constraint execute?
Дата
Msg-id 20060327115239.GX80726@pervasive.com
обсуждение исходный текст
Ответ на When does a check constraint execute?  (<Edmund.Bacon@elb_lx.onesystem.ca>, ebacon@onesystem.com)
Ответы Re: Pet-peevishness (When does a check constraint execute?)  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
On Fri, Mar 24, 2006 at 11:25:35AM -0700, Edmund.Bacon@elb_lx.onesystem.ca wrote:
> test-# $$ select not exists
> test$#     (select * from test_dates t1
> test$#       where 1 < ( select count(*) from test_dates t2
> test$#                   where (t1.from_date, t1.to_date) overlaps
> test$#                            (t2.from_date, t2.to_date)) )$$;

<pet-peeve>
If you only want to know if something exists, do NOT use count!

> test$#     (select * from test_dates t1
> test$#       where EXISTS ( select * from test_dates t2
> test$#                   where (t1.from_date, t1.to_date) overlaps
> test$#                            (t2.from_date, t2.to_date)) )$$;

On a small dataset you may not notice much difference, but you'll
certainly see it on a large dataset.
</pet-peeve>
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Converting a database from LATIN1 to UTF-8
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: PostgreSQL support on Redhat Advance Server 2.1