Actually now I already work to upgrade Postgresql version to 8.1 but not yet finish. Yesterday I did re-create the affected tables indices, it does improve the performance but still need 2-5 mins to execute the query. Is this 'normal' for a table with 40K rows of records? Anyway thanks for your help.