Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TQkAJ-0002Um-UN for pgsql-performance@postgresql.org; Tue, 23 Oct 2012 19:29:27 +0000 Received: from mailout-us.gmx.com ([74.208.5.67]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TQkAD-0002Wv-0g for pgsql-performance@postgresql.org; Tue, 23 Oct 2012 19:29:27 +0000 Received: (qmail 15047 invoked by uid 0); 23 Oct 2012 18:33:17 -0000 Received: from 76.255.19.161 by rms-us009 with HTTP Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset="utf-8" Date: Tue, 23 Oct 2012 14:33:16 -0400 From: "Kevin Grittner" Message-ID: <20121023183316.179560@gmx.com> MIME-Version: 1.0 Subject: Re: Query with limit goes from few ms to hours To: "henk de wit" X-Authenticated: #138763884 X-Flags: 0001 X-Mailer: GMX.com Web Mailer x-registered: 0 Content-Transfer-Encoding: 8bit X-GMX-UID: u4f0cEAn3zOlOQ09LnwhXTp+IGRvb4BZ X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/293 X-Sequence-Number: 48252 henk de wit wrote: > Well, what do you know! That did work indeed. Immediately after the > ANALYZE on that parent table (taking only a few seconds) a fast > plan was created and the query executed in ms again. Silly me, I > should have tried that earlier. Of course, if your autovacuum settings are aggressive enough, you should gernerally not need to run ANALYZE explicitly. You should double-check that autovacuum is turned on and configured at least as aggressively as the default settings, or you will probably get little surprises like this when you least expect them. -Kevin