Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V5L4P-0001iS-3i for pgsql-performance@arkaria.postgresql.org; Fri, 02 Aug 2013 19:31:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V5L4O-0001l8-Eo for pgsql-performance@arkaria.postgresql.org; Fri, 02 Aug 2013 19:31:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V5L4N-0001l1-9u for pgsql-performance@postgresql.org; Fri, 02 Aug 2013 19:31:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V5L4J-0000yq-R0 for pgsql-performance@postgresql.org; Fri, 02 Aug 2013 19:31:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id r72JVIop006896; Fri, 2 Aug 2013 15:31:18 -0400 From: Tom Lane To: Scott Marlowe cc: "pgsql-performance@postgresql.org" Subject: Re: subselect requires offset 0 for good performance. In-reply-to: References: <4522.1375400642@sss.pgh.pa.us> Comments: In-reply-to Scott Marlowe message dated "Fri, 02 Aug 2013 11:08:34 -0600" Date: Fri, 02 Aug 2013 15:31:18 -0400 Message-ID: <6895.1375471878@sss.pgh.pa.us> X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Scott Marlowe writes: > I extracted all the data like so: > select * into dba.pp_test_wide from original table; > and get this query plan from explain analyze: > http://explain.depesz.com/s/EPx which takes 20 minutes to run. > If I extract it this way: > select tree_sortkey, product_name, deleted_at into db.pp_test_3col > from original table; > I get this plan: http://explain.depesz.com/s/gru which gets a > materialize in it, and suddenly takes 106 ms. There's no reason why suppressing some unrelated columns would change the rowcount estimates, but those two plans show different rowcount estimates. I suspect the *actual* reason for the plan change was that autovacuum had had a chance to update statistics for the one table, and not yet for the other. Please do a manual ANALYZE on both tables and see if there's still a plan difference. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance