Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9vTD-0003Y6-Vb for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jun 2016 14:25:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b9vTD-0002D0-Dw for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jun 2016 14:25:35 +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.84_2) (envelope-from ) id 1b9vTD-0002Ct-0B for pgsql-bugs@postgresql.org; Mon, 06 Jun 2016 14:25:35 +0000 Received: from szalupa.batory.org.pl ([81.18.204.35]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b9vTA-0002k0-66 for pgsql-bugs@postgresql.org; Mon, 06 Jun 2016 14:25:34 +0000 Received: from tomost.syncron.local ([89.174.251.86]) (authenticated bits=0) by szalupa.batory.org.pl (8.14.4/8.14.4) with ESMTP id u56EPTRX027534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 6 Jun 2016 16:25:29 +0200 To: pgsql-bugs@postgresql.org From: Tomasz Ostrowski Subject: Routine analyze of single column prevents standard autoanalyze from running at all Message-ID: Date: Mon, 6 Jun 2016 16:25:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 81.18.204.35 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi. I'm routinely bulk inserting data to a PostgreSQL table and then analyzing a single column of the table, because it contains data which significantly changes histogram of this column values - for example something like adding rows with "todo=true" column, when all rows before bulk insert have "todo=false". This column has rather small "statistics" value, so analyze of it is fairly fast, which is important as I'm doing it often and also in parallel (and analyze blocks - only one can run at the time). The full analyze of this large table would take a lot of time (20 times more actually), and I can't perform it after each bulk insert. But I've noticed that a standard automatic analyze, which should work in background, never runs. I've noticed that this fast analyze of one column resets pg_stat_user_tables(n_mod_since_analyze) counter. I suppose that the decision to analyze the whole table is based on these values from pg_stat_user_tables and autovacuum_analyze_threshold and autovacuum_analyze_scale_factor settings. And in this case this highly updated table never reaches these values. I suppose this is a bug - an analyze, which does not analyze all columns, should not reset pg_stat_user_tables(n_mod_since_analyze). What do you think? -- Tomasz "Tometzky" Ostrowski -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs