Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGuxB-0005CO-Ar for pgsql-admin@arkaria.postgresql.org; Thu, 29 Jan 2015 19:40:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGuxA-0008JU-RH for pgsql-admin@arkaria.postgresql.org; Thu, 29 Jan 2015 19:40:36 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGux9-0008JM-Vl for pgsql-admin@postgresql.org; Thu, 29 Jan 2015 19:40:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGux2-0002EH-KK for pgsql-admin@postgresql.org; Thu, 29 Jan 2015 19:40:34 +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 t0TJeOxR025495; Thu, 29 Jan 2015 14:40:24 -0500 From: Tom Lane To: Basant Dagar cc: pgsql-admin@postgresql.org Subject: Re: Space taken by Null values In-reply-to: References: Comments: In-reply-to Basant Dagar message dated "Thu, 29 Jan 2015 14:32:15 -0500" Date: Thu, 29 Jan 2015 14:40:24 -0500 Message-ID: <25494.1422560424@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Basant Dagar writes: > I have big flat table with 100 columns in it. For about 40% of its data, 90 > columns would be null out of 100.And this table keeps growing and will > initial have more than 100 million rows. > ​May I know, will this impact the size in anyways as I heard nulls will > take no or very little space in PostgreSQL unlike oracle. even for millions > of rows with many columns in it. Is that true? If a row has any nulls at all in it, there is a "nulls bitmap" added to the row header which contains 1 bit per column, showing whether that column is null or not. Null columns do not occupy any space in the actual payload area. A row with no null columns omits the bitmap. So, if you like, you can consider that the first null appearing in a row of this table will cost you 16 bytes (100/8 = 12.5 rounded up to the next alignment boundary), and then all the rest are free. > ​And if that is not true, would you recommend to make this table into 2 > tables with the 2nd table containing those ​40% records with only 10 > required columns in it? It seems highly unlikely that such a scheme would be worth the trouble. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin