Re: Last event per user

Поиск
Список
Период
Сортировка
От Michael Lewis
Тема Re: Last event per user
Дата
Msg-id CAHOFxGqhh5T2Uidw6ha404kiX87ipgs4MCGKOoDOqsp=j4Z89g@mail.gmail.com
обсуждение исходный текст
Ответ на Last event per user  (Luís Roberto Weck <luisroberto@siscobra.com.br>)
Ответы Re: Last event per user  (Luís Roberto Weck <luisroberto@siscobra.com.br>)
Список pgsql-performance
The obfuscation makes it difficult to guess at the query you are writing and the schema you are using. Can you provide any additional information without revealing sensitive info?

1) Do you have an index on ( user_id ASC, timestamp_inc DESC ) ?
2) Sub-queries can't be re-written inline by the optimizer when there is an aggregate inside the subquery, and I think DISTINCT ON would behave the same. So, that might explain the significant change in behavior when the lateral is used. I am guessing at how you wrote the two versions of the view though.

Obviously not best design, but you could insert events as "is_latest" and update any prior events for that user via trigger as is_latest = false.

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

Предыдущее
От: Luís Roberto Weck
Дата:
Сообщение: Last event per user
Следующее
От: David Rowley
Дата:
Сообщение: Re: Planner performance in partitions