"Maksim Likharev" <mlikharev@aurigin.com> writes:
> I was trying to force PG do inner join 2 small tables calcs. necessary
> aggregates per id
> and only after that left outer join with the rest.
AFAICS you're contorting your query to force the evaluation order.
Why are you complaining that PG follows what you told it to do?
I'm having a hard time figuring out exactly what the query's intent
is. What does it look like when you express it in the simplest way
possible, with minimum use of subselects?
regards, tom lane