Re: Hey! ORDER BY in VIEWS?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Hey! ORDER BY in VIEWS?
Дата
Msg-id 11521.995233823@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Hey! ORDER BY in VIEWS?  ("Josh Berkus" <josh@agliodbs.com>)
Список pgsql-sql
"Josh Berkus" <josh@agliodbs.com> writes:
>> Hmm, I just realized that there's a bug here: let's say you have
>> 
>> CREATE VIEW latest AS
>> SELECT * FROM news ORDER BY story_timestamp DESC LIMIT 1;
>> 
>> ie, this view gives you the latest news story.

> Why, exactly, do we need to support ORDER BY ... LIMIT in VIEWS, anyway?
> I'm frankly unclear on the utility of this ...

I think the above example is pretty compelling, don't you?  Easy to read
and it generates a very nice indexscan plan.


> If we gotta have 'em, though, Tom, you'd have to code in an exception to
> the VIEW optimizer that doesn't push down WHERE clauses if the VIEW has
> an ORDER BY ... LIMIT statement.  Sure you wanna get into this?

It's a one-line addition to code that already knows that certain kinds
of clauses (like UNION) prevent pushdown.  Just an oversight, not a
fundamental flaw.
        regards, tom lane


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

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Hey! ORDER BY in VIEWS?
Следующее
От: Chris Ruprecht
Дата:
Сообщение: Unknown values in int8 fields?