pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Federico <rotellaro@gmail.com>
To: Rickard Sjöström <rickard.sjostrom@bluebottle.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: PG does not use my index
Date: Mon, 2 Apr 2007 17:08:26 +0200
Message-ID: <a3e8e2210704020808qaffae2cicd9c523658ae0701@mail.gmail.com> (raw)
In-Reply-To: <1175513194.4610e86a2ffab@mail.bluebottle.com>
References: <1175253570.460cf2427984c@mail.bluebottle.com>
	<20418.1175271262@sss.pgh.pa.us>
	<1175513194.4610e86a2ffab@mail.bluebottle.com>

On 4/2/07, Rickard Sjöström <rickard.sjostrom@bluebottle.com> wrote:
> Hi!
> 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"?)

Hi,
a full index scan is even more expensive than a sequential scan.
So the query optimizer works fine.

Regards
Federico



view thread (4+ messages)  latest in thread

Message-ID: <a3e8e2210704020808qaffae2cicd9c523658ae0701@mail.gmail.com>
Permalink:  ../a3e8e2210704020808qaffae2cicd9c523658ae0701@mail.gmail.com/
Also on:    postgresql.org/message-id/a3e8e2210704020808qaffae2cicd9c523658ae0701@mail.gmail.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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: rotellaro@gmail.com, rickard.sjostrom@bluebottle.com
  Subject: Re: PG does not use my index
  In-Reply-To: <a3e8e2210704020808qaffae2cicd9c523658ae0701@mail.gmail.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