From: | Federico <rotellaro(at)gmail(dot)com> |
---|---|
To: | Rickard Sjöström <rickard(dot)sjostrom(at)bluebottle(dot)com> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: PG does not use my index |
Date: | 2007-04-02 15:08:26 |
Message-ID: | a3e8e2210704020808qaffae2cicd9c523658ae0701@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On 4/2/07, Rickard Sjöström <rickard(dot)sjostrom(at)bluebottle(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Moran | 2007-04-02 15:32:22 | Re: [GENERAL] Increasing the shared memory |
Previous Message | Shoaib Mir | 2007-04-02 15:01:50 | Re: Increasing the shared memory |