Re: slow count in window query

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: slow count in window query
Date: 2009-07-17 07:19:53
Message-ID: e08cc0400907170019l2bf9fdbdj328ea0ddd669def@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/7/17 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> Hello
>
> look on:
> postgres=# explain select count(*) over () from x;
>                         QUERY PLAN
> -------------------------------------------------------------
>  WindowAgg  (cost=0.00..265.00 rows=10000 width=0)
>   ->  Seq Scan on x  (cost=0.00..140.00 rows=10000 width=0)
> (2 rows)
>
> Time: 1,473 ms
> postgres=# explain select count(*) over (order by a) from x;
>                               QUERY PLAN
> ------------------------------------------------------------------------
>  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)
> (2 rows)
>
> but
> query1: 160ms
> query2: 72ms

Well, how about "select a from x order by a"?
I wonder if index scan affects more than windowagg.

--
Hitoshi Harada

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2009-07-17 07:42:02 Re: Using results from INSERT ... RETURNING
Previous Message David E. Wheeler 2009-07-17 06:20:46 Re: navigation menu for documents