Re: The nested view from hell - Restricting a subquerry

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: The nested view from hell - Restricting a subquerry
Дата
Msg-id 87y7h74un7.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: The nested view from hell - Restricting a subquerry  (Nis Jørgensen <nis@superlativ.dk>)
Ответы Re: The nested view from hell - Restricting a subquerry  (Nis Jørgensen <nis@superlativ.dk>)
Список pgsql-sql
Nis Jørgensen <nis@superlativ.dk> writes:

> Well, the query can be satisfied by looking only at the rows with an
> order_id matching the invoice_id given. The condition that this is the
> largest invoice in the group then needs to be checked afterwards.
>
> I certainly did not expect the query planner to be able to deduce this,
> though.

No, that's not true. If you had two records in eg_order with the same order_id
but different invoice_ids then the query would need both records to satisfy
the query.

The query planner can't deduce that this can't happen because it simply does
not have that information.

The more I look at this view the more I think it's just seriously broken.
Why is it grouping by order_id at all if, I suspect, there will only be one
record per order_id in eg_orders??

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com



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

Предыдущее
От: Nis Jørgensen
Дата:
Сообщение: Re: The nested view from hell - Restricting a subquerry
Следующее
От: Nis Jørgensen
Дата:
Сообщение: Re: The nested view from hell - Restricting a subquerry