X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8367AD1B899 for ; Wed, 20 Aug 2003 19:44:37 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33719-10 for ; Wed, 20 Aug 2003 19:44:29 -0300 (ADT) Received: from hotmail.com (bay2-f122.bay2.hotmail.com [65.54.247.122]) by svr1.postgresql.org (Postfix) with ESMTP id 253B1D1BAC7 for ; Wed, 20 Aug 2003 19:44:26 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 20 Aug 2003 15:44:28 -0700 Received: from 65.207.145.30 by by2fd.bay2.hotmail.msn.com with HTTP; Wed, 20 Aug 2003 22:44:28 GMT X-Originating-IP: [65.207.145.30] X-Originating-Email: [sreepriya@hotmail.com] From: "Priya G" To: chris@psychofx.com, pgsql-admin@postgresql.org Subject: Re: This table won't use INDEX until I DUMP/RESTORE it ? Date: Wed, 20 Aug 2003 18:44:28 -0400 Mime-Version: 1.0 Content-Type: text/html Message-ID: X-OriginalArrivalTime: 20 Aug 2003 22:44:28.0576 (UTC) FILETIME=[9D10D200:01C3676C] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/242 X-Sequence-Number: 9963

try to analyze the table. That may help to use the index

>From: Chris Miles
>To: pgsql-admin@postgresql.org
>CC: Chris Miles
>Subject: [ADMIN] This table won't use INDEX until I DUMP/RESTORE it ?
>Date: Tue, 19 Aug 2003 17:46:16 +0100
>
>I have a DB that appears to perform badly. A test of one table
>with one of the typical queries gives me a query plan indicating
>a Seq Scan;
>
>DB=# EXPLAIN select pcref,pcseqnbr from catrecrel where
>pcbsref='something' and (pccaref is null or pccaref='') and pcpar
>is null order by pcseqnbr ;
>NOTICE: QUERY PLAN:
>
>Sort (cost=38266.65..38266.65 rows=4 width=58)
> -> Seq Scan on catrecrel (cost=0.00..38266.61 rows=4 width=58)
>
>Ok, that's no good, but it _should_ be using an index instead, and
>if I dump this table, restore it onto a different (non-live) DB, and
>try again, I see that it does indeed plan to use the index:
>
>DB=# EXPLAIN select pcref,pcseqnbr from catrecrel where
>pcbsref='something' and (pccaref is null or pccaref='') and pcpar
>is null order by pcseqnbr ;
>NOTICE: QUERY PLAN:
>
>Sort (cost=469.92..469.92 rows=1 width=58)
> -> Index Scan using ind_pcbsref on catrecrel (cost=0.00..469.91
>rows=1 width=58)
>
>Now, why is this? The first (live) DB is VACUUM ANALYSEd nightly,
>and
>was done so again just before this test. Data, schema and indexes
>should
>be the same in both (well it was dumped/restored directly from one
>to the
>other).
>
>The only fix I can think of is to dump and restore the whole DB,
>based on
>the fact that a newly restored DB appears to work much better, but
>surely
>I shouldn't have to do this? What else can i do to fix it?
>
>Cheers,
>CM
>
>--
>Chris Miles
>http://chrismiles.info/
>
>
>---------------------------(end of
>broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html


MSN 8: Get 6 months for $9.95/month.