I often use Max(ARRAY[]) to get the ID of the maximum value.
pgsql-bugs by date:
Соглашаюсь с условиями обработки персональных данных