Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hftG5-00047M-AF for pgsql-general@arkaria.postgresql.org; Tue, 25 Jun 2019 21:45:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hftG4-00053q-4a for pgsql-general@arkaria.postgresql.org; Tue, 25 Jun 2019 21:45:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hftG3-00053j-EV for pgsql-general@lists.postgresql.org; Tue, 25 Jun 2019 21:45:43 +0000 Received: from mail-oln040092012041.outbound.protection.outlook.com ([40.92.12.41] helo=NAM05-BY2-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hftFo-0001xC-8B for pgsql-general@postgresql.org; Tue, 25 Jun 2019 21:45:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Get5jZJjC2FEXShtFDo7ZGIedpIxWsm4tn0fFj8cvmw=; b=AUbnS1SN5eFUiPlnm8o/tqdsI2AyLBqtUchsPEetDOtKUvVOLTq0d7v0ZBzxTlecWCPYzpeFgk7ihN/lGuZUA6g6v27mfw/mvE8Y9Qk+vGv4zJz654/QIf2B8+MKQYk90It+gr+3mPWynySlVQYK0w7Wr59SHqkAhz0vv/lMizfaxqb/p4YUmmJ6XWeH1s7AuQP3V+hIGmpcBAjyi3mii6yJYDnj4E67uHq7P68sC5oSJYbJ5SAbU/2eNCwIPqKwCvkCYsQoQad5h31H0ungJWlE8YeN7z1On97bngBlpET1ReabMGTPvg0Egrfw3Ii5lEtCLXf5T9yRstgkgCOYFQ== Received: from CO1NAM05FT031.eop-nam05.prod.protection.outlook.com (10.152.96.55) by CO1NAM05HT198.eop-nam05.prod.protection.outlook.com (10.152.97.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2032.6; Tue, 25 Jun 2019 21:45:26 +0000 Received: from DM6PR06MB5562.namprd06.prod.outlook.com (10.152.96.55) by CO1NAM05FT031.mail.protection.outlook.com (10.152.96.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2032.6 via Frontend Transport; Tue, 25 Jun 2019 21:45:26 +0000 Received: from DM6PR06MB5562.namprd06.prod.outlook.com ([fe80::2016:b0cf:4313:a536]) by DM6PR06MB5562.namprd06.prod.outlook.com ([fe80::2016:b0cf:4313:a536%6]) with mapi id 15.20.2008.014; Tue, 25 Jun 2019 21:45:26 +0000 From: John Lumby To: pgsql general Subject: REINDEX : new parameter to preserve current average leaf density as new implicit FILLFACTOR Thread-Topic: REINDEX : new parameter to preserve current average leaf density as new implicit FILLFACTOR Thread-Index: AQHVK5ybyheYeBn/pEeqHQr9ZtxX2w== Date: Tue, 25 Jun 2019 21:45:26 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:C15DC42D5616254D0F2D1E064D4C1870F1B6786D987C075415284005393BAA61;UpperCasedChecksum:38837CD24FCBD6BEFB1583265E3EF7E4F357D088465CD9458E549D36A3A7314D;SizeAsReceived:6623;Count:40 x-tmn: [QhA9t1Vrfl1sTSCyq0903QbcpFtQsycu] x-ms-publictraffictype: Email x-incomingheadercount: 40 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(5050001)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031322404)(2017031323274)(2017031324274)(1601125500)(1603101475)(1701031045);SRVR:CO1NAM05HT198; x-ms-traffictypediagnostic: CO1NAM05HT198: x-microsoft-antispam-message-info: hqfcL6H09FV0fRcaykBpqvLQ2Q6aF/rrVcVY1PgDHz4IHYZMrKJY9UT0U0h+iF1wogZ86UNIJeJIfZrFSTxq1cgHb+rvIKUojSnltmjkS9jV4s+uhg9MLHvoJvqqrP4HQH4O7HLlZjO9y3aiQ7oYF1MS/MmgQ+YVBGlKy0booo5a048Yw7BPnUcKG6jCzXDl Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e05da93a-d2f1-427a-f4e9-08d6f9b66f05 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 21:45:26.0859 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM05HT198 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Background :=A0=A0 For some workloads involving high volume of INSERT/UPDAT= E/DELETE,=A0 It is sometimes beneficial=0A= to schedule regular REINDEX of high-activity indexes,=A0=A0 so as to improv= e performance,=A0 or restore performance levels back to what it was earlier= , by removing dead keys etc.=A0=A0=A0=A0=A0 This can result in the averag= e page density of these indexes fluctuating up and down in a saw-tooth fash= ion,=A0 REINDEX causing large increase in density (large drop in total numb= er of pages) and the workload gradually=A0 decreasing density back to some = "steady-state".=0A= =0A= Suggestion : it would be useful if REINDEX could ,=A0=A0 when some new para= meter is set , first determine current average leaf page density in the ind= ex to be rebuilt, =A0=A0 (e.g. the value of=A0pgstatindex().avg_leaf_densit= y from the =A0 pgstattuple extension ),=A0 and then adopt this density as t= he temporary override FILLFACTOR while rebuilding index pages,=A0 as to to = minimize change in density.=0A= =0A= This would avoid the saw-tooth effect on number of pages,=A0=A0 and also re= duce the number of index page-splits which occur during the period immediat= ely following a REINDEX done with default FILLFACTOR of 90%.=A0=A0 In effec= t,=A0 it lessens the need for the physical reorganization aspect of REINDEX= and focusses more on the function of removing dead=A0 keys.=0A= =0A= An admin do this for themselves by monitoring index page density and settin= g the FILLFACTOR to the current density before each REINDEX (and may find t= hat this doesn't change much if the workload is truly steady-state),=A0=A0 = but I wonder if this community would agree that it would provide a useful a= utomation of the process.=0A= =0A= Cheers,=A0 John Lumby=0A= =0A=