"Carlos H. Reimer" <carlos.reimer@xxxxxxxxxxxxx> writes: > I would like to improve the response time of the following SQL command Try getting rid of the silly concatenate-with-empty-string operations that appear to lurk within some view underlying this command. Those seem to be defeating the planner's ability to guess how many join rows there will be. > -> Nested Loop (cost=4.69..2231.03 > rows=12 width=1264) (actual time=3.775..6353.475 rows=32069 loops=1) > -> Hash Join (cost=4.69..2081.99 > rows=11 width=658) (actual time=3.257..1305.769 rows=32069 loops=1) > Hash Cond: > (("outer".codcor)::text = (("inner".codite)::text || ''::text)) It would surely not have used a nestloop here if it had had a better idea of how many rows would come out of the lower join ... but since it has no statistics about the result of the concatenate, it's just guessing about that. regards, tom lane