Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1ek5-0001pF-Bn for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jan 2014 16:15:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W1ek4-00030i-R0 for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jan 2014 16:15:28 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1ek3-00030V-Ce; Fri, 10 Jan 2014 16:15:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W1ejs-0005Y1-FR; Fri, 10 Jan 2014 16:15:26 +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 s0AGFEb7012481; Fri, 10 Jan 2014 11:15:14 -0500 From: Tom Lane To: Kadri Raudsepp cc: pgsql-admin@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [ADMIN] Column missing from pg_statistics In-reply-to: References: Comments: In-reply-to Kadri Raudsepp message dated "Fri, 10 Jan 2014 16:31:48 +0200" Date: Fri, 10 Jan 2014 11:15:14 -0500 Message-ID: <12480.1389370514@sss.pgh.pa.us> X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Kadri Raudsepp writes: > I have set up a cron-job that sends me daily reports on bloat amount in > tables and indices, which I calculate using pg_stats, not pgstattuple, for > performance and I/O reasons. If the bloat amount or percentage are big > enough, I use pg_repack to get rid of it. At some point I noticed, that > some tables keep showing up in the reports with the same amount of bloat, > which pg_repack was seemingly unable to remove. Investigation showed that > pgstattuple gave very different results than my bloat-finding query. > Reason - for some tables there are some columns that never show up in > pg_statistics. Hmm. Eyeballing the ANALYZE code, I note that it will decide that it hasn't got any valid statistics for a column if (1) it finds no NULL values and (2) every single sampled value in the column is too wide (more than WIDTH_THRESHOLD = 1024 bytes wide). Does this describe your problematic column? It seems like the code is being too conservative here --- it could at least generate valid values for stanullfrac and stawidth. I'm inclined to think maybe it should also set stadistinct = -1 ("unique") in this case, since the basic assumption that validates ignoring very wide values is that they aren't duplicates. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers