Re: no index-usage on aggregate-functions?

From: "Harald Lau (Sector-X)" <harald(at)sector-x(dot)de>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: no index-usage on aggregate-functions?
Date: 2004-06-29 08:46:27
Message-ID: 00b801c45db5$914330e0$6602a8c0@spock
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

@Chris:

> > SELECT count(*) FROM the_table
> > => Seq scan -> takes about 12 sec
> This cannot be made O(1) in postgres due to MVCC. You just have to live
> with it.

bad news
BTW: in this case you could workaround
select reltuples from pg_class where relname='the_table'
(yes, I know: presumes a regular vacuum analyse)

> Average and sum can never use an index AFAIK, in any db server. You
> need information from every row.

Take a look at the SQLSrv-pendant:
create index x_1 on the_table (num_found)
select avg(num_found) from the_table
-> Index Scan(OBJECT:([midata].[dbo].[THE_TABLE].[x_1])

(I'm not sure what Oracle does - have to re-install it first ...)

@Scott:
> Yes, you're expecting an MVCC database to behave like a row locking
> database.

hmmmm...
So, it seems that PG is not soooo well suited for a datawarehouse and/or performing extensive statistics/calculations/reportings on large tables, is it?

Greetings Harald

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dennis Bjorklund 2004-06-29 11:49:52 Re: no index-usage on aggregate-functions?
Previous Message Richard Huxton 2004-06-29 08:37:49 Re: Query performance