Re: Semantics around INSERT INTO with SELECT and ORDER BY.

Поиск
Список
Период
Сортировка
От Ravi Krishna
Тема Re: Semantics around INSERT INTO with SELECT and ORDER BY.
Дата
Msg-id CACER=P2AL6G5ZC4HQFhXBAAYXQ5-tmEdOcbcyUbUwzece9vjsA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Semantics around INSERT INTO with SELECT and ORDER BY.  (Steve Krenzel <sgk284@gmail.com>)
Список pgsql-general
>Or to put it another way, I want to select values from one table ordered by 
>complex criteria and insert them into another table. I want to be able to 
>retrieve the rows from the target table in the same order they were inserted,
>but I don't care about the specific ordering criteria. I only care about the order they were inserted.

As I understand, your business requirement is to retrieve the rows from the target 
table the same way they were inserted.  The one and only way to achieve it is
to use the same ORDER by clause to SELECT from target, what it was used
to insert into target. In your case, the insert is
 INSERT INTO bar (val) SELECT val FROM foo ORDER BY id DESC;
So the SELECT should also be ORDER BY ID desc

Just don't care on how it inserts and stores row internally.

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

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: Bad performance with cascaded deletes
Следующее
От: Bo Peng
Дата:
Сообщение: Re: Add to watchdog cluster request is rejected by node