27 січня 2010 р. 19:01 Matthew Wakeling написав:
> On Wed, 27 Jan 2010, Віталій Тимчишин wrote:
>
>> How about SELECT SUM (case when id > 120 and id < 121 then 1 end)
>> from tbl_tracker;
>>
>
> That is very interesting.
>
>
> * All the functions should be noop for null input
>>
>
> Ala
On Wed, 27 Jan 2010, Віталій Тимчишин wrote:
How about SELECT SUM (case when id > 120 and id < 121 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.
Matthew
--
An optimist sees the gl
2010/1/26 Matthew Wakeling
> On Tue, 26 Jan 2010, Richard Neill wrote:
>
>> SELECT SUM (case when id > 120 and id < 121 then 1 else 0 end)
>> from tbl_tracker;
>>
>> Explain shows that this does a sequential scan.
>>
>
> I'd defer to Tom on this one, but really, for Postgres to work this
On Jan 26, 2010, at 9:41 AM, Richard Neill wrote:
> Thanks for your answers.
>
>
> David Wilson wrote:
>
>> Why not simply add the where clause to the original query?
>>
>> SELECT
>> SUM (case when id > 120 and id < 121 then 1 else 0 end) AS c1,
>> SUM (case when id > 121 and id <
Thanks for your answers.
David Wilson wrote:
> Why not simply add the where clause to the original query?
>
> SELECT
> SUM (case when id > 120 and id < 121 then 1 else 0 end) AS c1,
> SUM (case when id > 121 and id < 122 then 1 else 0 end) AS c2,
> SUM (case when id > 122 an
On Tue, 26 Jan 2010, Richard Neill wrote:
SELECT SUM (case when id > 120 and id < 121 then 1 else 0 end) from
tbl_tracker;
Explain shows that this does a sequential scan.
I'd defer to Tom on this one, but really, for Postgres to work this out,
it would have to peer deep into the myst
Richard Neill writes:
> SELECT
>SUM (case when id > 120 and id < 121 then 1 else 0 end) AS c1,
>SUM (case when id > 121 and id < 122 then 1 else 0 end) AS c2,
>...
> FROM tbl_tracker;
> This can be manually optimised into a far uglier (but much much faster)
> query:
Dear All,
Just wondering whether there is a missing scope for the query planner
(on 8.4.2) to be cleverer than it currently is.
Specifically, I wonder whether the optimiser should know that by
converting a CASE condition into a WHERE condition, it can use an index.
Have I found a possible e