Re: Best way to get the latest revision from a table

От: Kevin Grittner
Тема: Re: Best way to get the latest revision from a table
Дата: ,
Msg-id: 4D308067020000250003962D@gw.wicourts.gov
(см: обсуждение, исходный текст)
Ответ на: Re: Best way to get the latest revision from a table  (Nikolas Everett)
Список: pgsql-performance

Скрыть дерево обсуждения

Best way to get the latest revision from a table  (Nikolas Everett, )
 Re: Best way to get the latest revision from a table  ("Kevin Grittner", )
  Re: Best way to get the latest revision from a table  (Nikolas Everett, )
   Re: Best way to get the latest revision from a table  ("Kevin Grittner", )
 Re: Best way to get the latest revision from a table  (Shaun Thomas, )
  Re: Best way to get the latest revision from a table  ("Kevin Grittner", )
   Re: Best way to get the latest revision from a table  (Tom Lane, )
    Re: Best way to get the latest revision from a table  ("Kevin Grittner", )
     Re: Best way to get the latest revision from a table  (Nikolas Everett, )
      Re: Best way to get the latest revision from a table  (Shaun Thomas, )
      Re: Best way to get the latest revision from a table  (Robert Haas, )
       Re: Best way to get the latest revision from a table  (Nikolas Everett, )
    Re: Best way to get the latest revision from a table  (Shaun Thomas, )

Nikolas Everett <> wrote:

> I'm really going to be doing this with an arbitrary list of As.

OK, how about this?:

CREATE TEMPORARY TABLE request (a INTEGER NOT NULL);
INSERT INTO request SELECT a FROM generate_series(2, 200) AS t(a);
ANALYZE request;
SELECT y.*
  from (select a, max(revision) as revision
          from test join request using (a)
          group by a) x
  join test y using (a, revision);
DROP TABLE request;

-Kevin


В списке pgsql-performance по дате сообщения:

От: Nikolas Everett
Дата:
Сообщение: Re: Best way to get the latest revision from a table
От: Craig Ringer
Дата:
Сообщение: Re: The good, old times