Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSLjK-0006Ap-5R for pgsql-performance@arkaria.postgresql.org; Sat, 25 Apr 2020 14:24:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jSLjI-0001uF-C5 for pgsql-performance@arkaria.postgresql.org; Sat, 25 Apr 2020 14:24:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSLjI-0001u1-5A for pgsql-performance@lists.postgresql.org; Sat, 25 Apr 2020 14:24:28 +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 1jSLjE-0002iQ-Rl for pgsql-performance@lists.postgresql.org; Sat, 25 Apr 2020 14:24:27 +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 03PEONPD031937; Sat, 25 Apr 2020 10:24:23 -0400 From: Tom Lane To: Moises Lopez cc: pgsql-performance@lists.postgresql.org Subject: Re: The query plan get all columns but I'm using only one column. In-reply-to: References: Comments: In-reply-to Moises Lopez message dated "Fri, 24 Apr 2020 16:11:12 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31935.1587824663.1@sss.pgh.pa.us> Date: Sat, 25 Apr 2020 10:24:23 -0400 Message-ID: <31936.1587824663@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Moises Lopez writes: > -> Seq Scan on public.link l1 (cost=0.00..10.40 rows=40 width=516) > (actual time=0.010..0.011 rows=1 loops=1) > * Output: l1.id , l1.url, l1.name > , l1.description, l1.rel* This is normal; it is not a bug, and it is not a source of performance issues either. The planner is choosing to do that to avoid a projection step in this plan node, because there's no need for one. On the other scan, where it *is* important to project out just the required columns to minimize the size of the hash table above the scan, it does do so: > -> Seq Scan on public.link l2 (cost=0.00..10.40 rows=40 > width=516) (actual time=0.010..0.011 rows=1 loops=1) > Output: l2.url > Is there a manner to avoid returning all columns in order to get a better > performance? You have not shown us anything about what your actual performance issue is, but this isn't it. https://wiki.postgresql.org/wiki/Slow_Query_Questions regards, tom lane