vincent.moreau@xxxxxxxxxxxxxx wrote: > I have attached the requested information. > > You will see that the query is quite messy and could be easily improved. > Unfortunately, it came from a third party application and we do not have > access to the source code. There are only nested loops and hash joins, while the other plan seems to be more elaborate -- I wonder if you have disabled bitmap scan, merge joins, in 8.2? Try a SHOW enable_mergejoin in psql. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.