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 1fVlnq-0003kp-Aq for pgsql-admin@arkaria.postgresql.org; Wed, 20 Jun 2018 22:42:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fVlnn-0002D1-Az for pgsql-admin@arkaria.postgresql.org; Wed, 20 Jun 2018 22:42:11 +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 1fVlnm-0002Cu-O0 for pgsql-admin@lists.postgresql.org; Wed, 20 Jun 2018 22:42:10 +0000 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fVlni-0004N4-CT for pgsql-admin@postgresql.org; Wed, 20 Jun 2018 22:42:08 +0000 Received: by mail-qk0-x242.google.com with SMTP id j80-v6so721489qke.9 for ; Wed, 20 Jun 2018 15:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=M+QEWHb6SAjsQuKuzLjBSwhi9cM7I8kCo9PR6r1AW1o=; b=AVDxHNSBxH8Zm5w/nJZxb16+RV1VRQDiK62HYQo3Q6Q8+gy5TA7fntNS2xm4ekO28s Pe13sHmP6lUUkzyLP3GM3Fq/dFP99XeVq3Uv7DUz0Y1hG+DrzdgVlXiCARp2CaukDW+A BP/G0K3Ev5w7rGogoyVhWM0RVafMWDRX//te5t5ib2eJfnTBkcSU+VY9xm6Ij0S4oSUu UkKw2l0TyIeHA+OHahex9AdmZ+LgXg+FEV+wZMR26mlVI7Q/5wmZ1bD9PC2OSNFnL2Yv 1QIzE90W8yitbcp1I1pAG8pmSdDq7tn0oFMqSthwqjvrQpSrt12zRViSQiwXDyNnbqjH ZP5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=M+QEWHb6SAjsQuKuzLjBSwhi9cM7I8kCo9PR6r1AW1o=; b=NWIhrFHrmO2t5+y3gKKguzZKP5On7ozTK3gnFmczxVyq6GwUM1ACZb26P0ultWdQhb KX8LG+kOvrHKfxc/4c9AtimqNWLNcd/nK5D3b2jVMuW+1qxdkR5qv3Rw4ybqIXQYeZ3p fNDwrux2Etavcs71/Rp0KZ+tCHhAQ6dmwjnoGWgGPR1LC3tZ6kwI1QhzdVTZdCnncawF KKEzMY7WpnHKgCeEtq2Y4MifXy4dge5sqF1c5OS2VPJj6puf0MengDnAeqwfQW+XX00c vUiVwD4CwQGZDoBWzpCMlHVkJ8tYNGK31sYM/K/JGJicPpempk6mb1f/W8LOIQQXbhfY KzLw== X-Gm-Message-State: APt69E3Zyj3NALLofP7j57E7vLWnJlhF/3RjH80Fhgi+TRItnExUZ/Qp KIyX5wnKYyamJ+PkL4/4IYNIFg== X-Google-Smtp-Source: ADUXVKLfXqmdRxm4d6kMFALw6faRpf6DgLj80Z9voSzfMuBewbQKqmkfFGS3MAhCiwMw8QYw2/RKKg== X-Received: by 2002:a37:2cc5:: with SMTP id s188-v6mr18938548qkh.311.1529534525460; Wed, 20 Jun 2018 15:42:05 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id n59-v6sm2367033qte.97.2018.06.20.15.42.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 15:42:05 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 3D0F0560; Wed, 20 Jun 2018 18:42:03 -0400 (-04) Date: Wed, 20 Jun 2018 18:42:03 -0400 From: Alvaro Herrera To: Wells Oliver Cc: pgsql-admin Subject: Re: explaining the pg_total_relation_size/pg_relation_size results Message-ID: <20180620224203.fqlzl2d3dhvcbe7q@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Jun-20, Wells Oliver wrote: > I have the follwing in a view to glance at the size of my relations: > > pg_size_pretty(pg_relation_size(c.oid::regclass)) AS size, > pg_total_relation_size(c.oid::regclass) AS bytes > > This view sorts by pg_relation_size(c.oid::regclass) descending. > > The question is: the byte values are often higher for relations with a > lower size indicated by size. As I sit here, I see an 11GB table > of 23821893632 bytes and a 12GB table of 14545387520 bytes, and > lastly/weirdly, a 3194MB table of 19924844544 bytes. This is a strange question. pg_total_relation_size includes the size of indexes and toast table and index, which pg_relation_size does not, so it seems natural that they give wildly different results for differently shaped tables. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services