Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iRTYT-0006wH-Bv for pgsql-general@arkaria.postgresql.org; Mon, 04 Nov 2019 04:01:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iRTYS-0002VV-5o for pgsql-general@arkaria.postgresql.org; Mon, 04 Nov 2019 04:01:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iRTYR-0002VO-PU for pgsql-general@lists.postgresql.org; Mon, 04 Nov 2019 04:01:23 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iRTYP-0002Qh-DB for pgsql-general@lists.postgresql.org; Mon, 04 Nov 2019 04:01: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 xA441JwN014146; Sun, 3 Nov 2019 23:01:19 -0500 From: Tom Lane To: Steve Baldwin cc: pgsql-general@lists.postgresql.org Subject: Re: explain plan difference In-reply-to: References: Comments: In-reply-to Steve Baldwin message dated "Mon, 04 Nov 2019 14:14:03 +1100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14144.1572840079.1@sss.pgh.pa.us> Date: Sun, 03 Nov 2019 23:01:19 -0500 Message-ID: <14145.1572840079@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Steve Baldwin writes: > I guess the difference doesn't have a huge bearing (as far as I can tell) > on the result, but it just seems odd that the inner-most 'Output' step > outputs the entire row in the case of the copy and only the required field > in the case of the original table. What triggers that behaviour? The plan with the full output row is actually slightly cheaper, or at least so the planner thinks, because it saves a projection step. I imagine the reason you're not getting that with the original table is that there are some dropped column(s) in the original table, forcing the projection to be done to get rid of them. regards, tom lane