pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Priya G <sreepriya@hotmail.com>
To: chris@psychofx.com
To: 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
Message-ID: <BAY2-F122wn9Wgtc2S600007f3b@hotmail.com> (raw)

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



view thread (7+ messages)  latest in thread

Message-ID: <BAY2-F122wn9Wgtc2S600007f3b@hotmail.com>
Permalink:  ../BAY2-F122wn9Wgtc2S600007f3b@hotmail.com/
Also on:    postgresql.org/message-id/BAY2-F122wn9Wgtc2S600007f3b@hotmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sreepriya@hotmail.com, chris@psychofx.com
  Subject: Re: This table won't use INDEX until I DUMP/RESTORE it ?
  In-Reply-To: <BAY2-F122wn9Wgtc2S600007f3b@hotmail.com>
  References: <BAY2-F122wn9Wgtc2S600007f3b@hotmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox