Re: Query does not use index

From: Martin Hampl <Martin(dot)Hampl(at)gmx(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Query does not use index
Date: 2004-05-01 10:16:35
Message-ID: A00A118A-9B58-11D8-91C4-000393674318@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Am 30.04.2004 um 17:52 schrieb Tom Lane:

> It could be that this table has a lot of empty pages near the front,
> which is a condition that's known to lead to underestimated row count
> from ANALYZE. (Manfred is working on a better ANALYZE sampling method
> that should avoid such errors in future.) Try doing a straight VACUUM
> and see if the row count estimate gets better.

It did! Thanks! Explain analyze now yields the following result:

Explain analyze now
QUERY PLAN
------------------------------------------------------------------------
----------------------------------------------------------
Nested Loop (cost=0.00..70650.10 rows=12 width=32) (actual
time=170.449..181.663 rows=3 loops=1)
-> Index Scan using word_idx on token (cost=0.00..30403.79
rows=7621 width=16) (actual time=158.237..179.105 rows=5 loops=1)
Index Cond: ((word)::text = 'FACTSHEET'::text)
-> Index Scan using s_begin_idx on s (cost=0.00..5.27 rows=1
width=16) (actual time=0.429..0.434 rows=1 loops=5)
Index Cond: ((s.text_id = "outer".text_id) AND (s."start" =
"outer"."position"))
Total runtime: 182.207 ms

I never deleted anything from this database, but it might be that I
dropped some of the tables a couple of times when populating the
database. Also 'copy from' failed a couple of times. Can that have the
same effect?

Thanks again,
Martin

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Hochhaus 2004-05-01 11:32:43 Setting up pgsql for ODBC
Previous Message Tom Lane 2004-05-01 04:08:00 Re: postmaster does not shut down