"Alexander Dolgin" <alex@dolgin.dp.ua> writes:
> Does anybody have idea about reasons of such results?
Try converting the MAX() functions to queries that will use indexes.
See FAQ entry 4.7 "My queries are slow or don't make use of the
indexes. Why?"
regards, tom lane