Thank you very much, I followed both of your advice, plus adding some extra ram, and the excution time dropped from 10 to 2 minutes.
Since I did everything with one shot, I can't tell the weight of every single action.....
Regards
IF
____________________________________________________________________________________________________
Also, in regards to:
Sort Method: external merge Disk: 287784kB
Id increase work_mem setting, to avoid on-disk sorting.
Regards,
Igor Neyman