Re: A slow query - Help please?

Поиск
Список
Период
Сортировка
От Gurjeet Singh
Тема Re: A slow query - Help please?
Дата
Msg-id 65937bea0606190500n1718ad1v744dab59e74f3892@mail.gmail.com
обсуждение исходный текст
Ответ на Re: A slow query - Help please?  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
Hubert said 'do "something similar" to this'... The syntax was
incorrect for sure.

If you wish to be able to do ORDER BY and LIMIT in UNION queries, you
need to make them sub-queries "something similar" to this:

select * from
(
select * from (select * from only table_a  order by number desc limit 25) as A
union
select * from (select * from only table_b  order by number desc limit 25) as B
union
select * from (select * from only table_c  order by number desc limit 25) as C
) x
order by number desc limit 25;

    Again, this query and the syntax is totally untested (I don't have
access to a PG right now); and I don't know much about the history of
this thread!!! But I think it will allow you to do a LIMIT 25 alright.

> And of course 'select *' isn't going to work in the subqueries, the base
> table contains less columns than the inherited tables.

    I don't think you have much of an option in that case...

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

Предыдущее
От: "Florian G. Pflug"
Дата:
Сообщение: Re: Adding foreign key constraints without integrity check?
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: A slow query - Help please?