Q: Multicolumn lookup, Join or Sub-query ?

Поиск
Список
Период
Сортировка
От radevenz@ix.netcom.com (Richard A. DeVenezia)
Тема Q: Multicolumn lookup, Join or Sub-query ?
Дата
Msg-id e320eda1.0308270730.4706d397@posting.google.com
обсуждение исходный текст
Список pgsql-sql
I have a table T with many columns whose values are are lookup keys
id_1, id_2, id_3, id_4, id_5, ..., id_26

The values corresponding to the keys live in table L, the lookup table:
id, id_value

T might have 100K rows and L 500K rows.

I am wondering what would be the best view (performance-wise) to see the values?

-----
Method one - join

create view V1 as
select a.id_value as v_1, ... z.id_value as v_26
from 
T, L as a, L as b, ..., L as z
where   a.id = T.id_1
and b.id = T.id_2
...
and z.id = T.id_26

-----
Method two - sub-query

create view V2 as
select (select id_value from L where id = id_1) as v_1
, (select id_value from L where id = id_2) as v_2
...
, (select id_value from L where id = id_26) as v_26


TIA,
Richard


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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: smallfloat with postgresql
Следующее
От: "ProgHome"
Дата:
Сообщение: Re: How to optimize this query ?