Hi Pavan, that's quite a big query. I can see that the generate_series function is getting repeatedly called and the planner estimates for this sub query are out by a factor of 66. You might try to re-write using a WITH query. I am assuming that you have already analyzed all the tables and also added appropriate indexes on join/query columns. Regards Matthew -- Sent from: http://www.postgresql-archive.org/PostgreSQL-performance-f2050081.html