On Fri, Nov 7, 2008 at 4:14 AM, Віталій Тимчишин <tivv00@xxxxxxxxx> wrote:> "Merge Join (cost=518771.07..62884559.80 rows=1386158171 width=32) (actual> time=30292.802..755751.242 rows=34749 loops=1)" Have you tried increasing the default_statistics_target? The planneris expecting 1.3 billion rows to be produced from a query that's onlyactually producting 35k, which probably indicates some very badstatistics. At the same time, the materialize step produces 242million rows when the planner only expects to produce 2.3, indicatinga similar problem in the opposite direction. This probably means thatthe planner is choosing plans that would be optimal if it was makinggood guesses but are decidedly sub-optimal for your actual data. -- - David T. Wilsondavid.t.wilson@xxxxxxxxx -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-performance