Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VqRjJ-0004Wh-W6 for pgsql-admin@arkaria.postgresql.org; Tue, 10 Dec 2013 18:08:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VqRjJ-0000ZP-Ea for pgsql-admin@arkaria.postgresql.org; Tue, 10 Dec 2013 18:08:21 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VqRjI-0000ZH-64 for pgsql-admin@postgresql.org; Tue, 10 Dec 2013 18:08:20 +0000 Received: from qmta07.emeryville.ca.mail.comcast.net ([2001:558:fe2d:43:76:96:30:64]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VqRjA-0004au-SG for pgsql-admin@postgresql.org; Tue, 10 Dec 2013 18:08:18 +0000 Received: from omta09.emeryville.ca.mail.comcast.net ([76.96.30.20]) by qmta07.emeryville.ca.mail.comcast.net with comcast id zslX1m0020S2fkCA7u8BCi; Tue, 10 Dec 2013 18:08:11 +0000 Received: from jerry.enova.com ([38.98.177.132]) by omta09.emeryville.ca.mail.comcast.net with comcast id zu7z1m00t2rmZlA8Vu82cu; Tue, 10 Dec 2013 18:08:08 +0000 Received: by jerry.enova.com (Postfix, from userid 1001) id 656FA740208; Tue, 10 Dec 2013 12:07:59 -0600 (CST) From: Jerry Sievers To: Luis Cc: pgsql-admin@postgresql.org Subject: Re: Difference in the size of database size and relations References: Date: Tue, 10 Dec 2013 12:07:59 -0600 In-Reply-To: (Luis's message of "Tue, 10 Dec 2013 12:33:50 +0100") Message-ID: <86vbyw1sw0.fsf@jerry.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1386698891; bh=h3YOl8qRRbpSs2jHBN1xc5F2xNI0PL2NPAL0BFd4srg=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=UnOE/WE2jPWzln+EImCJ5/ms/BqHc0uLZmaAgCTtZum5luW9r7l23hvN7wFFv6ghl WHVT88gV8ww+xqzdJHRVt1Sy0OgAh0+P8LCPCKJoK32w2z9c/lVtsfZgv1oUBWZXkN peaDCsmDFe8beeixHE6LiaN6Wj4l7rSoEz74tgMrYDLO0O12K+AEppyd4mwnxk1Iw+ 8PuUxOfpeN0jdYKFx8UUBjfTDu+aJWnyp5ErZmF1pbZ5ZIBvkC32bo9FdhXT1DuB62 yPYux+AskZ2tkE4oaSBBi+L/PfXlBm3WByRnuabnWSIkUL2cRhz0jVJWrRAzLP2K1u GVo2b7VqXxagw== X-Pg-Spam-Score: -0.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 Luis writes: > Hi, > > I have noticed a weird thing in different databases. > When I run pg_database_size on some databases they report a pretty > high value and if I take a look to all relations the sum of all of > them is not even the half of the one reported by pg_database_size. > > Although I've seen this in different databases, this is a specific example. > > > This are the sizes reported by this query: > > SELECT pg_size_pretty(pg_relation_size(C.oid)) AS "size" > FROM pg_class C > LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) > WHERE nspname NOT IN ('pg_catalog', 'information_schema') > ORDER BY pg_relation_size(C.oid) DESC > LIMIT 20; > Try just comparing what pg_database_size() tells you vs a sum() over relpages*8192 (assuming standard page size). You may have to do some casting to bigint depending how large your DB is. > size > --------- > 99 MB > 45 MB > 10 MB > 8528 kB > 5280 kB > 4352 kB > 3184 kB > 1304 kB > 1152 kB > 896 kB > 544 kB > 528 kB > 336 kB > 336 kB > 336 kB > 304 kB > 296 kB > 288 kB > 272 kB > 248 kB > > And this is the database size reported by this query: > SELECT pg_size_pretty(pg_database_size('mydb')); > > pg_size_pretty > ---------------- > 3539 MB > > I've read about LOBs but I don't seem to have any. > > Any idea where the space is being used? > > Thanks -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800 -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin