From: | Chris Albertson <chris(at)topdog(dot)pas1(dot)logicon(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Help, how to get sub-select to look at index? |
Date: | 1998-05-27 20:56:43 |
Message-ID: | 356C7E0B.51F61A75@topdog.logicon.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
The outer SELECT in a stament that uses sub selects appears not
to ever make use of index files. Here is an example
(1) select * from foo where bar = 1;
The above will use an index if one exists. It is very fast
even on my 3 million row table.
(2) select * from foo where bar IN (SELECT 1)
The above seems to always do a sequencial scan of the
table It is very slow on my 3 million row table.
My real code is more complex. The inner select returns about 100
rows which triggers about 100 sequencial scans of my 3 million row
table. I let it run for hours and I have never seen it finish.
(I use a 2000 block buffer chache and disabled fsync)
Is there a trick I could use? Can you type cast a subselect?
I have both btree and hash indexes
built and did a fresh vacuum. Still no luck. Just thought I'd
ask before writting a libpg C program to simulate (2).
(Please cc a direct reply)
Thanks,
--
--Chris Albertson
chris(at)topdog(dot)logicon(dot)com Voice: 626-351-0089 X127
Logicon RDA, Pasadena California Fax: 626-351-0699
From | Date | Subject | |
---|---|---|---|
Next Message | Peter T Mount | 1998-05-27 21:03:24 | Re: [HACKERS] Off-topic: Communication. (was: Connect string again) |
Previous Message | Tom Ivar Helbekkmo | 1998-05-27 19:22:36 | Off-topic: Communication. (was: Connect string again) |