Re: Index not used ! Why? + Little graphical client ...

From: "Nicolas Verger" <nicolas(at)verger(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Index not used ! Why? + Little graphical client ...
Date: 2001-10-25 13:31:50
Message-ID: OBEKKEAKKLKKGIEBIPICIEDPCBAA.nicolas@verger.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> my database server has very high load in this morning.
> I've found the problem. One of my index was not used so far!
> it's interesting:
> ...
> addb=> CREATE INDEX banners_b_no_key ON banners (b_no);
> CREATE
> addb=> EXPLAIN SELECT b_link FROM banners WHERE b_no = 3;
> NOTICE: QUERY PLAN:
>
> Index Scan using banners_b_no_key on banners (cost=0.00..4.43
> rows=1 width=12)
>
> EXPLAIN
> addb=>
>
> Why index wasn't used ?
> postgresql-7.1.2, redhat 7.0, kernel:2.2.19

Try to create a unique index :
CREATE UNIQUE INDEX banners_b_no_key ON banners (b_no);
or specify a primary key :
ALTER TABLE banners ADD CONSTRAINT pk_banners PRIMARY KEY (b_no);

then ANALYZE your table ....

-- Nicolas --

We ( me and my teammate ) try to create a little graphical client for
PostgreSQL in Java. If someone want to try it :
http://pgInhaler.ifrance.com. It's an alpha version with lots of bugs... Try
it and send us your feedback to pginhaler(at)ifrance(dot)com(dot)(dot)(dot) Thanx...

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-10-25 13:39:27 Re: pgindent run
Previous Message Tom Lane 2001-10-25 13:19:00 Re: Index of a table is not used (in any case)