Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XZgpt-0000IJ-OR for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Oct 2014 13:54:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XZgps-0005qi-9M for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Oct 2014 13:54:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XZgpr-0005qZ-0u for pgsql-hackers@postgresql.org; Thu, 02 Oct 2014 13:54:23 +0000 Received: from smtprelay0245.b.hostedemail.com ([64.98.42.245] helo=smtprelay.b.hostedemail.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XZgpl-000267-R4 for pgsql-hackers@postgresql.org; Thu, 02 Oct 2014 13:54:21 +0000 Received: from filter.hostedemail.com (b-bigip1 [10.5.19.254]) by smtprelay06.b.hostedemail.com (Postfix) with ESMTP id 394918D016; Thu, 2 Oct 2014 13:54:16 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50, 0, 0, , d41d8cd98f00b204, alvherre@alvh.no-ip.org, :::::::::, RULES_HIT:41:355:379:599:871:967:973:988:989:1260:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1535:1540:1575:1594:1595:1596:1711:1730:1747:1764:1777:1792:2393:2525:2560:2563:2682:2685:2691:2693:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4118:4605:4659:5007:6261:6748:7281:9025:9121:10004:10400:10848:11232:11256:11257:11604:11658:11914:12517:12519:13161:13229:13894:13895:21080, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: stew64_80229626ed2b X-Filterd-Recvd-Size: 7284 Received: from eldon.alvh.no-ip.org (pc-144-132-215-201.cm.vtr.net [201.215.132.144]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf08.b.hostedemail.com (Postfix) with ESMTPA; Thu, 2 Oct 2014 13:54:14 +0000 (UTC) Received: by eldon.alvh.no-ip.org (Postfix, from userid 1000) id D3AA61FCD; Thu, 2 Oct 2014 10:54:13 -0300 (CLST) Date: Thu, 2 Oct 2014 10:54:13 -0300 From: Alvaro Herrera To: Robert Haas Cc: Mark Kirkwood , Amit Kapila , Haribabu Kommi , "pgsql-hackers@postgresql.org" Subject: Re: Per table autovacuum vacuum cost limit behaviour strange Message-ID: <20141002135412.GX5311@eldon.alvh.no-ip.org> References: <53672F63.3080400@catalyst.net.nz> <53686F22.8030300@catalyst.net.nz> <20140826161911.GE6343@eldon.alvh.no-ip.org> <20140930221644.GR5311@eldon.alvh.no-ip.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xs+9IvWevLaxKUtW" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20140930221644.GR5311@eldon.alvh.no-ip.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) 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 --xs+9IvWevLaxKUtW Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Alvaro Herrera wrote: > So in essence what we're going to do is that the balance mechanism > considers only tables that don't have per-table configuration options; > for those that do, we will use the values configured there without any > changes. > > I'll see about implementing this and making sure it finds its way to > 9.4beta3. Here's a patch that makes it work as proposed. How do people feel about back-patching this? On one hand it seems there's a lot of fear of changing autovacuum behavior in back branches, because for many production systems it has carefully been tuned; on the other hand, it seems hard to believe that anyone has tuned the system to work sanely given how insanely per-table options behave in the current code. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --xs+9IvWevLaxKUtW Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="per_table_vacuum_para_v5.patch" *** a/doc/src/sgml/maintenance.sgml --- b/doc/src/sgml/maintenance.sgml *************** *** 792,801 **** analyze threshold = analyze base threshold + analyze scale factor * number of tu ! When multiple workers are running, the cost limit is balanced among all the running workers, so that the ! total impact on the system is the same, regardless of the number ! of workers actually running. --- 792,804 ---- ! When multiple workers are running, the cost delay parameters are balanced among all the running workers, so that the ! total I/O impact on the system is the same regardless of the number ! of workers actually running. However, any workers processing tables whose ! autovacuum_vacuum_cost_delay or ! autovacuum_vacuum_cost_limit have been set are not considered ! in the balancing algorithm. *** a/src/backend/postmaster/autovacuum.c --- b/src/backend/postmaster/autovacuum.c *************** *** 193,198 **** typedef struct autovac_table --- 193,199 ---- int at_multixact_freeze_table_age; int at_vacuum_cost_delay; int at_vacuum_cost_limit; + bool at_dobalance; bool at_wraparound; char *at_relname; char *at_nspname; *************** *** 223,228 **** typedef struct WorkerInfoData --- 224,230 ---- Oid wi_tableoid; PGPROC *wi_proc; TimestampTz wi_launchtime; + bool wi_dobalance; int wi_cost_delay; int wi_cost_limit; int wi_cost_limit_base; *************** *** 1716,1721 **** FreeWorkerInfo(int code, Datum arg) --- 1718,1724 ---- MyWorkerInfo->wi_tableoid = InvalidOid; MyWorkerInfo->wi_proc = NULL; MyWorkerInfo->wi_launchtime = 0; + MyWorkerInfo->wi_dobalance = false; MyWorkerInfo->wi_cost_delay = 0; MyWorkerInfo->wi_cost_limit = 0; MyWorkerInfo->wi_cost_limit_base = 0; *************** *** 1776,1788 **** autovac_balance_cost(void) if (vac_cost_limit <= 0 || vac_cost_delay <= 0) return; ! /* caculate the total base cost limit of active workers */ cost_total = 0.0; dlist_foreach(iter, &AutoVacuumShmem->av_runningWorkers) { WorkerInfo worker = dlist_container(WorkerInfoData, wi_links, iter.cur); if (worker->wi_proc != NULL && worker->wi_cost_limit_base > 0 && worker->wi_cost_delay > 0) cost_total += (double) worker->wi_cost_limit_base / worker->wi_cost_delay; --- 1779,1792 ---- if (vac_cost_limit <= 0 || vac_cost_delay <= 0) return; ! /* calculate the total base cost limit of participating active workers */ cost_total = 0.0; dlist_foreach(iter, &AutoVacuumShmem->av_runningWorkers) { WorkerInfo worker = dlist_container(WorkerInfoData, wi_links, iter.cur); if (worker->wi_proc != NULL && + worker->wi_dobalance && worker->wi_cost_limit_base > 0 && worker->wi_cost_delay > 0) cost_total += (double) worker->wi_cost_limit_base / worker->wi_cost_delay; *************** *** 1801,1806 **** autovac_balance_cost(void) --- 1805,1811 ---- WorkerInfo worker = dlist_container(WorkerInfoData, wi_links, iter.cur); if (worker->wi_proc != NULL && + worker->wi_dobalance && worker->wi_cost_limit_base > 0 && worker->wi_cost_delay > 0) { int limit = (int) *************** *** 2285,2290 **** do_autovacuum(void) --- 2290,2296 ---- /* advertise my cost delay parameters for the balancing algorithm */ MyWorkerInfo->wi_cost_delay = tab->at_vacuum_cost_delay; + MyWorkerInfo->wi_dobalance = tab->at_dobalance; MyWorkerInfo->wi_cost_limit = tab->at_vacuum_cost_limit; MyWorkerInfo->wi_cost_limit_base = tab->at_vacuum_cost_limit; *************** *** 2579,2584 **** table_recheck_autovac(Oid relid, HTAB *table_toast_map, --- 2585,2598 ---- tab->at_relname = NULL; tab->at_nspname = NULL; tab->at_datname = NULL; + + /* + * If any of the cost delay parameters has been set individually for + * this table, disable the balancing algorithm. + */ + tab->at_dobalance = + !(avopts && (avopts->vacuum_cost_limit > 0 || + avopts->vacuum_cost_delay > 0)); } heap_freetuple(classTup); --xs+9IvWevLaxKUtW Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --xs+9IvWevLaxKUtW--