Skip site navigation (1) Skip section navigation (2)

PG does not use my index

From: Rickard Sjöström <rickard(dot)sjostrom(at)bluebottle(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: PG does not use my index
Date: 2007-04-02 11:26:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
This post is related to the post "Performance of views" but this is another problem now. 

Problem: PostgreSQL seems to not use my index.

My postgres is 7.4.

I started all over again and got my query really fast on one database (~40 seconds became 150 ms). BUT when trying on another db (same postgres server but with approx. 4 times as much data) it was really slow again (say 10 seconds). 

Then I run the EXPLAIN ANALYSE of a sub-query of my query which I realize was the problem. 

It seems that it does not make use of the index in the slower database!?

fast db:
 ->  Index Scan using testcase_b_bid_index on testcase  (cost=0.00..1656.82 rows=426 width=38) (never executed)"

slow db:
->  Seq Scan on testcase  (cost=0.00..2896.42 rows=33242 width=64) (actual time=77.027..791.014 rows=37093 loops=1)"

rows=37093 is all of the existing rows of table testcase!
(why does it say "never executed"?)

Any ideas why it does not use my index??? How can I convince it to do so?


Citerar Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> Rickard =?iso-8859-1?b?U2r2c3Ry9m0=?=
> <rickard(dot)sjostrom(at)bluebottle(dot)com> writes:
> > I have a view that is really slow and I ca easily work around the
> slowness by bypassing the view and query the real table directly.
> Let's see the exact definition of the view and EXPLAIN ANALYZE
> results
> for doing it both ways.  Also, what PG version is this?
> 			regards, tom lane

Need cash? Click to get an emergency loan, bad credit ok

In response to


pgsql-admin by date

Next:From: ArnauDate: 2007-04-02 14:28:09
Subject: Dumping views, functions, ...
Previous:From: Shoaib MirDate: 2007-04-02 10:00:40
Subject: Re: Increasing the shared memory

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group