From: | Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp> |
---|---|
To: | hackers(at)postgreSQL(dot)org |
Subject: | Why is that so slow? |
Date: | 1999-03-05 03:50:48 |
Message-ID: | 199903050350.MAA01323@srapc451.sra.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I have a 2 tables and in some cases joining them are very slow.
Here are details.
create table postal (
oldcode varchar(5), -- has an btree index
newcode char(7), -- has an btree index
pid int2, -- has an btree index
kana_city text, -- has an btree index
kana_town text, -- has an btree index
city text, -- has an btree index
town text -- has an btree index
);
(has 119479 records)
create table prefecture (
pid int2, -- has an btree index
pref char(8),
kana_pref char(16)
);
(has 47 records)
My question is:
This is fast as I expected.
postal=> explain select * from postal,prefecture where city = 'aaa' and postal.pid = prefecture.pid;
NOTICE: QUERY PLAN:
Nested Loop (cost=4.10 size=1 width=100)
-> Index Scan using cityindex on postal (cost=2.05 size=1 width=74)
-> Index Scan using prefpidindex on prefecture (cost=2.05 size=47 width=26)
But:
postal=> explain select * from postal,prefecture where city ~ '^aaa' and postal.pid = prefecture.pid;
NOTICE: QUERY PLAN:
Nested Loop (cost=98.90 size=1 width=100)
-> Seq Scan on prefecture (cost=2.55 size=47 width=26)
-> Index Scan using pidindex on postal (cost=2.05 size=1 width=74)
This is so slooow. Can anybody explain this? Am I missing something?
Note that 6.4.x and current show same behavior.
---
Tatsuo Ishii
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 1999-03-05 05:37:38 | Re: [HACKERS] Why is that so slow? |
Previous Message | Thomas G. Lockhart | 1999-03-05 02:39:57 | Re: Fixed! PostgreSQL 6.4.2 on AIX 4.3.2: typeidTypeRelid error |