Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fjugW-0006JM-1Z for pgsql-performance@arkaria.postgresql.org; Sun, 29 Jul 2018 23:01:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fjugT-0008Or-NI for pgsql-performance@arkaria.postgresql.org; Sun, 29 Jul 2018 23:01:05 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fjugT-0008Ok-CV for pgsql-performance@lists.postgresql.org; Sun, 29 Jul 2018 23:01:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fjugQ-0005t6-UX for pgsql-performance@postgresql.org; Sun, 29 Jul 2018 23:01:04 +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 w6TN0xO7016507; Sun, 29 Jul 2018 19:00:59 -0400 From: Tom Lane To: David Rowley cc: Dinesh Kumar , postgres performance list Subject: Re: Performance difference in accessing differrent columns in a Postgres Table In-reply-to: References: Comments: In-reply-to David Rowley message dated "Mon, 30 Jul 2018 09:53:55 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16505.1532905259.1@sss.pgh.pa.us> Date: Sun, 29 Jul 2018 19:00:59 -0400 Message-ID: <16506.1532905259@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > On 29 July 2018 at 17:38, Dinesh Kumar wrote: >> I found performance variance between accessing int1 and int200 column which >> is quite large. > Have a look at slot_deform_tuple and heap_deform_tuple. You'll see > that tuples are deformed starting at the first attribute. If you ask > for attribute 200 then it must deform 1-199 first. Note that that can be optimized away in some cases, though evidently not the one the OP is testing. From memory, you need a tuple that contains no nulls, and all the columns to the left of the target column have to be fixed-width datatypes. Otherwise, the offset to the target column is uncertain, and we have to search for it. regards, tom lane