From: | Marten Feldtmann <marten(at)feki(dot)toppoint(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | index usage ... strange !? |
Date: | 2000-01-17 19:29:34 |
Message-ID: | 200001171929.UAA04218@feki.toppoint.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
He's a small example and I'm trying to speed up this query and I can manage it :-(
The table:
P3AT:
AO - char(15), with index
AT - Integer, with index
AV - VARCHAR(80), with index valind
CI - Integer, with index
We've about 23000 rows in this table. I would like to execute:
SELECT AO,AT,AV FROM P3AT
WHERE EXISTS( SELECT AO FROM P3AT WHERE AV='12' AND AT=12 AND CI=17)
Explain gives me:
Result(946.19,0,0)
InitPlan
-> INdex Scan using valind on p3at (222,265,12) (fine !)
->Seq Scan on p3at (946,22235,26) (urgghhh ?)
This statement takes about 2s to return the results.
The select statement within exists just needs 23ms to find the AO value !
SELECT AO FROM P3AT WHERE AO='12'
EXPLAIN GIVES ME:
INDEX SCAN USING ATROWIND ON P3AT (2,2,12)
In general I expect for each unique AO about 10-12 result rows. I've done
several vacuum analyze (the first one crashed my database by the way :-(, this
tool is really making me crazy - claiming that it can't remove the lock :-().
The reason seems to be the seq scan ... therefore how can I get rid of it !
I use PSQL 6.5.3 under SuSE 6.1.
Marten
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-01-17 22:26:57 | Re: [SQL] index usage ... strange !? |
Previous Message | Gerhard Dieringer | 2000-01-17 08:12:53 | Antw: [SQL] attribute level rules not supported? |