Re: This table won't use INDEX until I DUMP/RESTORE it ?

From: "Priya G" <sreepriya(at)hotmail(dot)com>
To: chris(at)psychofx(dot)com, pgsql-admin(at)postgresql(dot)org
Subject: Re: This table won't use INDEX until I DUMP/RESTORE it ?
Date: 2003-08-20 22:44:28
Message-ID: BAY2-F122wn9Wgtc2S600007f3b@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

<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(at)PSYCHOFX(dot)COM>
<DIV></DIV>&gt;To: pgsql-admin(at)postgresql(dot)org
<DIV></DIV>&gt;CC: Chris Miles <CHRIS(at)PSYCHOFX(dot)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>

Attachment Content-Type Size
unknown_filename text/html 2.9 KB

Browse pgsql-admin by date

  From Date Subject
Next Message Stephan Szabo 2003-08-20 23:03:24 Re: This table won't use INDEX until I DUMP/RESTORE it ?
Previous Message Tom Lane 2003-08-20 22:00:40 Re: Help with pg_restore