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

From Kevin Grittner
Subject Re: slow count in window query
Date
Msg-id 4A6045910200002500028902@gw.wicourts.gov
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
Pavel Stehule <pavel.stehule@gmail.com> wrote:
> postgres=# explain select count(*) over () from x;
>  WindowAgg  (cost=0.00..265.00 rows=10000 width=0)
>    ->  Seq Scan on x  (cost=0.00..140.00 rows=10000 width=0)
> postgres=# explain select count(*) over (order by a) from x;
>  WindowAgg  (cost=0.00..556.25 rows=10000 width=4)
>    ->  Index Scan using gg on x  (cost=0.00..406.25 rows=10000
width=4)
> query1: 160ms
> query2: 72ms
EXPLAIN ANALYZE is more telling than just EXPLAIN.
Did you run both several times or flush caches carefully between the
runs to eliminate caching effects?
Is it possible that there are a lot of dead rows in the table (from
UPDATEs or DELETEs), and the table has been vacuumed?  (Output from
VACUUM VERBOSE on the table would show that.)
-Kevin


pgsql-hackers by date:

Previous
From: Boszormenyi Zoltan
Date:
Subject: Re: ECPG support for struct in INTO list
Next
From: Pavel Stehule
Date:
Subject: Re: slow count in window query