query slowness caused by table alias

Поиск
Список
Период
Сортировка
От Chi Fan
Тема query slowness caused by table alias
Дата
Msg-id 20000505025745.9718.qmail@web4002.mail.yahoo.com
обсуждение исходный текст
Ответы Re: query slowness caused by table alias  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
I don't know if this's really a bug in 7.0, but I
don't see this
problem/feature in 6.5.3.

The system: Linux RedHat 6.0, running postgresql
7.0RC4

The bug: The mixed uses of table names and table alias
in a query results in an extra sequential scan in
query execution

Test cases:

EXPLAIN
SELECT *
FROM part p              -- let p alias to part
WHERE part.part_id = 42; -- but don't use p

Nested Loop  (cost=0.00..2429.30 rows=50735 width=219)
  ->  Index Scan using part_pkey on part
(cost=0.00..3.60 rows=1 width=4)
  ->  Seq Scan on part p  (cost=0.00..1918.35
rows=50735 width=215)

# note: a seq scan appears


EXPLAIN
SELECT *
FROM part                -- take out the alias
WHERE part.part_id = 42;

Index Scan using part_pkey on part  (cost=0.00..3.60
rows=1 width=215)

# note: now the seq scan is gone


EXPLAIN
SELECT *
FROM part p
WHERE p.part_id = 42;    -- use alias only

Index Scan using part_pkey on part p  (cost=0.00..3.60
rows=1 width=215)

# note: it's also ok


Thanks,

Chi-Fung


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

В списке pgsql-bugs по дате отправления:

Предыдущее
От: W-A-S-P@lqmiqutspp.org
Дата:
Сообщение: ,,~~Advice For New Immigrants~~...
Следующее
От: Tom Lane
Дата:
Сообщение: Re: query slowness caused by table alias