Why not just change the function all together to 'select $1 from $2 order by $1 desc limit 1;' Is there ANY situation where max(col) as it is, would be faster? ... John
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных