short circuit joins

Поиск
Список
Период
Сортировка
От Marcus Engene
Тема short circuit joins
Дата
Msg-id 4A9B032B.8070904@engene.se
обсуждение исходный текст
Список pgsql-general
Hi,

-- a
select
    ...
from
    base_table bt
    left outer join sub_table_1 st1 on (st1.base_table = bt.id)
    left outer join sub_table_2 st1 on (st2.base_table = bt.id)

-- b
select
    ...
from
    base_table bt
    left outer join sub_table_1 st1 on (bt.objecttype = 1 AND
st1.base_table = bt.id)
    left outer join sub_table_2 st1 on (bt.objecttype = 2 AND
st2.base_table = bt.id)

Pretend this is some stupid way of object orientation. base_table is the
base class and sub_table_x are subclasses. base_table.objecttype tells
which instance it is. Just for the sake of discussion, it could also be
like "bt.is_married_monogamous = 1 AND wife.husband = bt.id" for example.

In case b, does Postgres avoid to unnecessarily try look for respective
sub_table ? Is it worthwhile to have?

I'm on 8.3 presently. Still curious if newer versions have some
optimization here.

Best regards,
Marcus


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

Предыдущее
От: David Fetter
Дата:
Сообщение: Re: Using WITH queries on VIEWs
Следующее
От: bilal ghayyad
Дата:
Сообщение: Re: $Body$