you can also try : select val FROM table ORDER BY val DESC LIMIT 1; which usually is much quicker.
pgsql-performance by date:
Соглашаюсь с условиями обработки персональных данных