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 1fEGwI-0001eu-Dk for pgsql-general@arkaria.postgresql.org; Thu, 03 May 2018 16:18:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fEGwH-000413-6D for pgsql-general@arkaria.postgresql.org; Thu, 03 May 2018 16:18:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fEGwF-00040s-C2 for pgsql-general@lists.postgresql.org; Thu, 03 May 2018 16:18:36 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fEGw4-0006kq-Ln for pgsql-general@postgresql.org; Thu, 03 May 2018 16:18:34 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5783021839; Thu, 3 May 2018 12:18:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 03 May 2018 12:18:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=b9hbiMrDMeV8T/9hsLgRMm+rjYRrM ozCeSnp59o/j9A=; b=pAeerX5MuOQPNIkFfCJVq05JUjrSbBS6ZhtUtxyUSQyuh 5vdXZBcVcAlBTyPfCdNOrJznY9QTfdpjghnIsqVV5bjhuuMsjo0yort6AJdIjNs1 HG64TiDBAkeC/iKSa5QxL1rb2a9CgGb1J9StsVRv1Jz8yK2nqyLRZhjcTElhv7cs 56YVyOwi+zIwLtwqRxeRM2Q5pcDIMkbE9r6llen3kPoPjc3EAeJAjm5zBIVMM2La vAwJzV8sYdF3wDV3vT2KArhDXHa91yJQ0SCHG5lI1vhVNp1uEDR0b5B0Ld5FBXOv vw+f0WiZtFg8GBaDj7u1q3VwjUB5lmaDzpTvr5orQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=b9hbiM rDMeV8T/9hsLgRMm+rjYRrMozCeSnp59o/j9A=; b=NGHzNhIVmgBc4994PdfPyV FsPluSvvic+pbibidqzIsF55/33WeU5olO2oSWCCreIykPPnvXTyJ9hTG0fRJAh+ kuRTsNOpEikbvdGl2mKNn8LmnwYn7E7a2C3YGlfIIPdRGXK8T11jU7rI5hCdSmYK Y7JRAclDtz1wfn88/OJiFifh/TfJ8FnqCoG07r1K356L10kP210J1N62v4FDpB9m wFhn3f3wyN2+wEuRrqa+VpGKR443Cj1yURUqTDV3JY0tdoe/3z1jkYBr0PYasjFM K+qNGlAdPtg/h/1T/c+ooltzsliW1YRA0lvCkMsrxnXVD0gjceulrM+6xTmYOLAw == X-ME-Sender: Received: from ranger.suse (71-212-32-90.tukw.qwest.net [71.212.32.90]) by mail.messagingengine.com (Postfix) with ESMTPA id B87D2E4812; Thu, 3 May 2018 12:18:21 -0400 (EDT) Subject: Re: relkind='p' has no pg_stat_user_tables To: Justin Pryzby Cc: pgsql-general@postgresql.org References: <20180503141430.GA28019@telsasoft.com> <5e1e8ccf-da3d-5277-df77-a2bbaa714592@aklaver.com> <20180503154545.GG9585@telsasoft.com> From: Adrian Klaver Message-ID: <3b48b9a9-8eec-398d-bf13-86ae8ce93237@aklaver.com> Date: Thu, 3 May 2018 09:18:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180503154545.GG9585@telsasoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/03/2018 08:45 AM, Justin Pryzby wrote: > On Thu, May 03, 2018 at 07:44:24AM -0700, Adrian Klaver wrote: >> On 05/03/2018 07:14 AM, Justin Pryzby wrote: >>> I (finally) realized that my script for ANALYZEing parents of table hierarchies >>> every month or so was looping around the same parent tables every night due to >>> no stats for date of last last analysis. >> >> Would help to see the script. > > I reproduced it more simply than the 300 line script: > > postgres=# CREATE TABLE t(i int)PARTITION BY RANGE(i); > postgres=# CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (1) TO (9); > postgres=# INSERT INTO t1 VALUES(1),(2); > postgres=# ANALYZE VERBOSE t; I would say the answer lies below from above command: test_(postgres)# ANALYZE VERBOSE t; INFO: analyzing "public.t" inheritance tree INFO: "t1": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows INFO: analyzing "public.t1" INFO: "t1": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows ANALYZE and from here: https://www.postgresql.org/docs/10/static/sql-createtable.html "A partitioned table is divided into sub-tables (called partitions), which are created using separate CREATE TABLE commands. The partitioned table is itself empty. A data row inserted into the table is routed to a partition based on the value of columns or expressions in the partition key. ... " test_(postgres)# select * from only t; i --- (0 rows) Table t is just a pointer to the child tables and only the bulk statistics as shown in pg_statistic are maintained. > postgres=# SELECT * FROM pg_stat_user_tables WHERE relname='t'; > (0 rows) > postgres=# SELECT 1 FROM pg_statistic WHERE starelid='t'::regclass; > ?column? | 1 > > Justin > -- Adrian Klaver adrian.klaver@aklaver.com