David Carpio wrote > Thank you for your time You're not likely to get too many if any takers who want to try and decipher that mess you call a query/explain. Especially since you've made it pretty much impossible to read by removing/obfuscating information. It is not self-contained and we have no idea what the goal of the query is without actually reading it. At minimum you should write a paragraph or two describing your schema, problem, and what broadly you are trying to accomplish with the supplied query. My first instinct is that you table/schema layout simply sucks and that you are going to have to either re-design that or put considerable effort into manual caching or turn it into a function so that you can help the planner out. Ignore the whole "it runs too slowly" for the time being and create self-contained example that at least runs and where the query can actually be read. In addition maybe try performing surgery on the query so that a lot of the detail is removed without losing the structure. That way you and others can much more quickly view this modified query - even if it doesn't run - and get a feel for what it is doing and how it goes about doing it. You'd still need table definitions and sample data even for this. The whole "I want help but I can't (or won't take the time to) actually tell you what I am doing" position doesn't usually work for these kinds of problems. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/decrease-my-query-duration-tp5762622p5762758.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general