Re: Should the optimiser convert a CASE into a WHERE if it can?

From: Віталій Тимчишин <tivv00(at)gmail(dot)com>
To:
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Should the optimiser convert a CASE into a WHERE if it can?
Date: 2010-01-27 17:09:59
Message-ID: 331e40661001270909q3f6cdb5et17c9819b29d26b54@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

27 січня 2010 р. 19:01 Matthew Wakeling <matthew(at)flymine(dot)org> написав:

> On Wed, 27 Jan 2010, Віталій Тимчишин wrote:
>
>> How about SELECT SUM (case when id > 1200000 and id < 1210000 then 1 end)
>> from tbl_tracker;
>>
>
> That is very interesting.
>
>
> * All the functions should be noop for null input
>>
>
> Alas, not true for COUNT(*), AVG(), etc.
>
> select avg(b), count(b), count(*) from (values (2),(null))a(b)
gives (2.0, 1, 2) for me, so AVG is in game. Sure, it won't work for
count(*), but optimizer already knows which aggregates are strict and which
are not, so no new information is needed.

Best regards, Vitalii Tymchyshyn

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message James Mansion 2010-01-27 21:19:13 Re: Benchmark shows very slow bulk delete
Previous Message Matthew Wakeling 2010-01-27 17:01:30 Re: Should the optimiser convert a CASE into a WHERE if it can?