Re: Pet-peevishness (When does a check constraint execute?)
От | Alban Hertroys |
---|---|
Тема | Re: Pet-peevishness (When does a check constraint execute?) |
Дата | |
Msg-id | 4427ECA9.8040701@magproductions.nl обсуждение исходный текст |
Ответ на | Re: When does a check constraint execute? ("Jim C. Nasby" <jnasby@pervasive.com>) |
Ответы |
Re: Pet-peevishness (When does a check constraint execute?)
|
Список | pgsql-general |
Jim C. Nasby wrote: > On Fri, Mar 24, 2006 at 11:25:35AM -0700, Edmund.Bacon@elb_lx.onesystem.ca wrote: > <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> Certainly true, I keep telling people here at work. But I was kind of wondering why you'd "select * from" inside "exists", if you're not going to use those values. I tend to write "where exists (select 1 from", but now I'm curious whether the planner handles this for you or if there's actually a difference in meaning? I assume it's always better to not let the planner decide these kind of things. Try to write what you really want, instead of waving hands in the general direction and make the planner decide what you mean ;) Well, this is getting awfully pet-peevish, of course... -- Alban Hertroys alban@magproductions.nl magproductions b.v. T: ++31(0)534346874 F: ++31(0)534346876 M: I: www.magproductions.nl A: Postbus 416 7500 AK Enschede // Integrate Your World //
В списке pgsql-general по дате отправления: