Re: Query Cost

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: Query Cost
Дата
Msg-id 20050918220149.GX7630@pervasive.com
обсуждение исходный текст
Ответ на Query Cost  (ShepherdHill DB Subscriptions <db.subscriptions@shepherdhill.biz>)
Ответы plperl function to return nulls  (Brent Wood <b.wood@niwa.co.nz>)
Список pgsql-general
On Sun, Sep 18, 2005 at 07:40:26PM +0100, ShepherdHill DB Subscriptions wrote:
> Hi,
>
> I have a table with this schema:
>
> CREATE TABLE billing.bill
> (
>   sno serial NOT NULL,
>   billno int4,
>   det date NOT NULL,
>  .
>  .
>  .
>   CONSTRAINT bill_pkey PRIMARY KEY (sno)
> )
>
> I want to execute a query that will not return any record. Which of
> these queries is cheaper please?
>
> 1.   Select * from billing.bill where 1=0
> 2.   Select * from billing.bill where sno=0

Do an explain analyze and see. :)

1 will be faster because the optimizer can discard it right off the bat.
--
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 по дате отправления:

Предыдущее
От: Devrim GUNDUZ
Дата:
Сообщение: 8.1 beta2 RPMs
Следующее
От: Michael Schuerig
Дата:
Сообщение: Implementing a change log