From: | "Mendola Gaetano" <mendola(at)bigfoot(dot)com> |
---|---|
To: | <pgsql-performance(at)postgresql(dot)org>, <pgsql-admin(at)postgresql(dot)org> |
Subject: | Wrong plan or what ? |
Date: | 2003-07-22 17:10:14 |
Message-ID: | 00c101c35074$1e5f5b20$152aa8c0@GMENDOLA2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-performance |
Hi all,
I'm running Postgres7.3.3 and I'm performing this simple select:
select *
from user_logs ul,
user_data ud,
class_default cd
where
ul.id_user = ud.id_user and
ud.id_class = cd.id_class and
cd.id_provider = 39;
these are the number of rows for each table:
user_logs: 1258955
class_default: 31 ( only one with id_provider = 39 )
user_data: 10274;
this is the explain analyze for that query:
QUERY PLAN
Hash Join (cost=265.64..32000.76 rows=40612 width=263) (actual
time=11074.21..11134.28 rows=10 loops=1)
Hash Cond: ("outer".id_user = "inner".id_user)
-> Seq Scan on user_logs ul (cost=0.00..24932.65 rows=1258965 width=48)
(actual time=0.02..8530.21 rows=1258966 loops=1)
-> Hash (cost=264.81..264.81 rows=331 width=215) (actual
time=30.22..30.22 rows=0 loops=1)
-> Nested Loop (cost=0.00..264.81 rows=331 width=215) (actual
time=29.95..30.20 rows=6 loops=1)
-> Seq Scan on class_default cd (cost=0.00..1.39 rows=1
width=55) (actual time=0.08..0.10 rows=1 loops=1)
Filter: (id_provider = 39)
-> Index Scan using idx_user_data_class on user_data ud
(cost=0.00..258.49 rows=395 width=160) (actual time=29.82..29.96 rows=6
loops=1)
Index Cond: (ud.id_class = "outer".id_class)
Total runtime: 11135.65 msec
(10 rows)
I'm able to performe that select with these 3 steps:
SELECT id_class from class_default where id_provider = 39;
id_class
----------
48
(1 row)
SELECT id_user from user_data where id_class in ( 48 );
id_user
---------
10943
10942
10934
10927
10910
10909
(6 rows)
SELECT * from user_logs where id_user in (
10943, 10942, 10934, 10927, 10910, 10909
);
[SNIPPED]
and the time ammount is a couple of milliseconds.
Why the planner or the executor ( I don't know ) do not follow
the same strategy ?
Thank you
Gaetano Mendola
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-07-22 17:19:10 | Re: RE : common_fields: permission denied |
Previous Message | Olivier Reuland | 2003-07-22 11:28:24 | RE : common_fields: permission denied |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-07-22 17:10:33 | Re: Tuning PostgreSQL |
Previous Message | Bruce Momjian | 2003-07-22 16:26:01 | Re: Dual Xeon + HW RAID question |