Hello, thanks for the response. I did not get the response to my email even though I am subscribed to the pgsql-performance mail list. Let's hope that I get the next one :)
Increasing work_mem did not have great impact on the performance. But I will try to update the PostgreSQL version to see if it speeds up things. However is there way to keep query time constant as the database size grows. Should I use partitioning or partial indexes? Best Regards, Tommi Kaksonen