Re: slow count in window query - Mailing list pgsql-hackers

From Hitoshi Harada
Subject Re: slow count in window query
Date
Msg-id e08cc0400907160640s358187cj4fc156eef190784b@mail.gmail.com
Whole thread Raw
In response to Re: slow count in window query  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: slow count in window query
List pgsql-hackers
2009/7/16 Pavel Stehule <pavel.stehule@gmail.com>:
>> I'm also not sure how to handle this if the set has to be spooled to
>> disk. Quicksort and Quickselect do a lot of scans throught he data and
>> wouldn't perform well on disk.
>
> I thing, so problem is in aggregate func used as window func - or some
> missing optimalisation.
>
> when I replaced count(*) over () by subselect (SELECT count(*) FROM
> ...) then I got expected speed.
>

WindowAgg always spools its input in the buffer though (in your case)
it throws away row by row, so compared with pure aggregate it has
overhead. I think this is reasonable approach for large data situation
and different type of window. But yes, we must improve the current
model.

1) There should be some kind of lightweight approach for such
small-data/simple-window situations.

2) tuplestore_puttupleslot() seems to me heavy (copy, check, etc) even
if the data fits in the memory by triming rows. We want to have more
flexible temporary storage on the fly.


Regards,

-- 
Hitoshi Harada


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: boolean in C
Next
From: Peter Eisentraut
Date:
Subject: Re: [PATCH] Psql List Languages