X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96204D1B243 for ; Tue, 29 Jun 2004 05:45:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07412-05 for ; Tue, 29 Jun 2004 08:45:39 +0000 (GMT) Received: from pc7.berlin.powerweb.de (pc7.berlin.powerweb.de [62.67.228.13]) by svr1.postgresql.org (Postfix) with ESMTP id C1A7ED1B232 for ; Tue, 29 Jun 2004 05:45:35 -0300 (ADT) Received: from spock (p508409B6.dip0.t-ipconnect.de [80.132.9.182]) by pc7.berlin.powerweb.de (8.9.3p3/8.9.3) with SMTP id KAA18793 for ; Tue, 29 Jun 2004 10:45:36 +0200 Message-ID: <00b801c45db5$914330e0$6602a8c0@spock> From: "Harald Lau (Sector-X)" To: References: <007d01c45da4$3726dcd0$6602a8c0@spock> <40E11BF0.3020109@familyhealth.com.au> Subject: Re: no index-usage on aggregate-functions? Date: Tue, 29 Jun 2004 10:46:27 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200406/288 X-Sequence-Number: 7346 @Chris: > > SELECT count(*) FROM the_table > > =3D> Seq scan -> takes about 12 sec > This cannot be made O(1) in postgres due to MVCC. You just have to live= =20 > with it. bad news BTW: in this case you could workaround select reltuples from pg_class where relname=3D'the_table' (yes, I know: presumes a regular vacuum analyse) > Average and sum can never use an index AFAIK, in any db server. You=20 > 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 pe= rforming extensive statistics/calculations/reportings on large tables, is i= t? Greetings Harald