Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKw2S-00BdG5-FY for pgsql-performance@arkaria.postgresql.org; Tue, 10 Dec 2024 08:56:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tKw1Q-001ASp-Cq for pgsql-performance@arkaria.postgresql.org; Tue, 10 Dec 2024 08:55:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKw1P-001AQM-7n for pgsql-performance@lists.postgresql.org; Tue, 10 Dec 2024 08:55:12 +0000 Received: from mail-dbaeur03on2071c.outbound.protection.outlook.com ([2a01:111:f403:260d::71c] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKw1K-00237s-Ql for pgsql-performance@lists.postgresql.org; Tue, 10 Dec 2024 08:55:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I3ZXjiJBNBWglPGIY+N5HEfQQmxu1fIwSfr+NXfbGWT8u5gAbSK20KLgZU+YgmFXKfGmT7Uq3noqFpQHXO/uVQVmndvlnxaBsphFpk26PcqWNYXHS8BoCrMJ8xDBY2Ii031WO7KmObPRF8APplHHrW30oFDXsUCv8jr4bxRXgsS0ABsNcTqbQxvEbz/18TAvERdYKDjm5p7c/Le8rlEfeBtEBGuIhezbXI5/1HAAkWfeP/RuRq2KT4SilRQ18vmE0PVzLXPVWxXhPqx6jojA0tjh3+gcNigjPG7kdgHAjbhJnkBiK0Qvwb36rFIcIdyhD3tB46DCdlQWPBimBQybUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PJ7IVnsWVPOaeNXHh2OavycBTYntZ3zc125SO9u0bMo=; b=bHlXNX6ndFU8g+cqWy8dyTAugYv+/U2tYQkptbCZ5SQIS2ho4eSgK1TJIyHWwamC3xXcxffjjYWYGOn//+sAQ+7DNXDJ1Af6PwSXwpsTzErP3XfCqaZOW9eCTqMxjbWAr/x7xV/IaUk3jlOCycLd3wtAoxvjG6AT1pgJrydrBtnKUsCOXIHGqGpCjuzjrAIs3EDK4348BbY94QCp8SQwfGS4HG5+9GwGyokXpMncBKL9XlEqmU6UOsh8VRM3KT10xzyffy+bCC+/J7ibY1W5R+TvcekVtz966cNVdLVnOWjjyU8r9ZsjateiELJLMUv1XhGSuR40ZCP/KNLyglHkyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nibio.no; dmarc=pass action=none header.from=nibio.no; dkim=pass header.d=nibio.no; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nibio.onmicrosoft.com; s=selector2-nibio-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PJ7IVnsWVPOaeNXHh2OavycBTYntZ3zc125SO9u0bMo=; b=Dmljyqi1jpnXyyKeNDdyj5rm2oU+FlgyAQw2EMdvslkPhDcl1gYr315l7YajXdSebypByIHnkPBIAD7w+EX7akA8pV+M1KGAon7PJsueDNfcsF1FmtAPz98wurUQSmpYNjmmkopQestNxsNWmsv0pcCsX4YN6wYsmvJEdrSv7do= Received: from AM7P189MB1028.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:174::18) by AM7P189MB0821.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:122::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 08:55:00 +0000 Received: from AM7P189MB1028.EURP189.PROD.OUTLOOK.COM ([fe80::7021:938f:7ff2:6406]) by AM7P189MB1028.EURP189.PROD.OUTLOOK.COM ([fe80::7021:938f:7ff2:6406%6]) with mapi id 15.20.8230.016; Tue, 10 Dec 2024 08:55:00 +0000 From: Lars Aksel Opsahl To: Tom Lane , Christophe Pettus CC: "pgsql-performance@lists.postgresql.org" Subject: Re: PostgreSQL and a Catch-22 Issue related to dead rows Thread-Topic: PostgreSQL and a Catch-22 Issue related to dead rows Thread-Index: AQHbSiR8fAE8+rgvhkWYwOHzJhBte7Ld+jSAgAAaboCAARHFqA== Date: Tue, 10 Dec 2024 08:55:00 +0000 Message-ID: References: <5EE4CC0C-E624-4E82-A2E8-B2EBA44D3521@thebuild.com> <3908773.1733760455@sss.pgh.pa.us> In-Reply-To: <3908773.1733760455@sss.pgh.pa.us> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nibio.no; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7P189MB1028:EE_|AM7P189MB0821:EE_ x-ms-office365-filtering-correlation-id: c66b5f1c-7949-4036-5562-08dd18f85479 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|41320700013|376014|1800799024|8096899003|7053199007|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?nuksH8nz77p4MbzweFj3KrrJmZAFroXhSnWQNBYO23/DDOn43DeiMA1rNx?= =?iso-8859-1?Q?Cw73ouBV5xPqIkivdZL778SjHwpz7IM5rP0tffcA5qSfVkp731Aj6nFR4f?= =?iso-8859-1?Q?8k0rN66p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AaR8?= =?iso-8859-1?Q?A3YNFDsJOfaaQ7AX0oJYNe6s7JidLxIocP8M0rv0MTA8fsYZonQnvMBtQq?= =?iso-8859-1?Q?kDzyZY2ccwmBbonPHeb2kYckGWKgyUVX2t6uH3j8ItBNo/VTdWpRePBgbK?= =?iso-8859-1?Q?tBOgQHESQfYUdxXlotAjnY0XGYlTip160gnQcQOb6weI2EW/ivtsmf/bcD?= =?iso-8859-1?Q?dtSiX3Tvs4clvxszXnEUWk1eaXulZy8YJvXLPv7+8Hk9XKGNn9R3K5kYYA?= =?iso-8859-1?Q?RLHXNgaJ0ywEyVkrAdN2JVe1P1Y7UTukW0CAbW+XyJaI7CcH1dsnabzPzS?= =?iso-8859-1?Q?cfHjsva4vmx4OL+OW2wpeKk7vcvA7AlaLFuehYVgvFe/V40kkm8rCFh5Fz?= =?iso-8859-1?Q?tPehlMcf9+NYT8fiXJ5ri9z1jiOXWh/mX+mCdj4xFFieFFCOh/DVqadn1X?= =?iso-8859-1?Q?KtLwCAE+c7+i5pyWAJOAYcSZPEQ9DEsmpEM8nw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7P189MB1028.EURP189.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(41320700013)(376014)(1800799024)(8096899003)(7053199007)(38070700018);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?5oKF3PcM3cr07hvwOsk/cxQooFW8yYc8g96OkAh3pw6gB1HE2HPd3XQqU4?= =?iso-8859-1?Q?/qCxfhIQd7JRZKD/6lshdGbQNwBpODGRtnBtwzfygn1ydC2DUr6qwLU+dS?= =?iso-8859-1?Q?V6KuInUYJZHBIvnLwHCf5WYj8CfeU3Ji4YH2wyE2Oq1/Oufzd7QVG+IyAm?= =?iso-8859-1?Q?HQ4fIaHxawJGFAAGzr5m00pX02iEYuazR0mt2biajgknUMlfhZoYp1bTiC?= =?iso-8859-1?Q?Z6uRiyEx0D09eFG4pIeRPWGBz9yVSMejs8T/JYgugwzLY9Pfl4aYA7UBta?= =?iso-8859-1?Q?4I8nTXndeAN13IAVbAAmXvFpfyFr21ah5GVSLAedTODkaseP1g7rZvcica?= =?iso-8859-1?Q?tz0kJ9zqH7Caq0E5g4BFFhgU3STzbexdLFReVAwC5/jLg8Dr9L53Aa3I4c?= =?iso-8859-1?Q?lAktKQKRAojnD8B9w4sNamhezNrgwp3gJ+XP1YfZQt3JlD2ow+lmimA1qz?= =?iso-8859-1?Q?1nG4b/8WnkQ6pKHSyN3WLVZ5r/ddWTcGv4XciMAO32SD3xblWjtQhYCQDz?= =?iso-8859-1?Q?8U+yl2ZjcKf2Glg7nmNEIWWL12ePKICGW5CjA/hry+mHMxkvxpP3+liZ76?= =?iso-8859-1?Q?jF/5naLsJiVcb+b+FfLAvnJU8y9ZyxBoevl646tnA6CZMPgEeYsEpashBJ?= =?iso-8859-1?Q?+E/ns8b49XziLxYWWB4rZlB0XqjsDQOrEr+dUHMtG/d9zSFqChMI6JVcqW?= =?iso-8859-1?Q?KYieuTu4z25zk0noKferpo333+ywCFbXE06pbm53/a9xIii+2pn5Pn3chI?= =?iso-8859-1?Q?Mjr0Wgv9keExgmwu9fINgL+F1kTH4oT0SDZ+n+WCA0USEixX6z+i73mKig?= =?iso-8859-1?Q?OUGUcQpHrUU9GhM0sEYCCbIljlVIYtQMRvT2/vm/ozjVJ+e+drRr7yOoX7?= =?iso-8859-1?Q?PK95VWkyKfEy9kdKshGjEFV6O9AGN561IdA1SEaub/KYHH4TXYeMaf4uOG?= =?iso-8859-1?Q?1vJdYBRBkRBE2VjzOEhyIXTzfnkTtJAikKNTL2nqvUrhjxgBgaQ7X3+LaR?= =?iso-8859-1?Q?8lwTGR3JqARHoizxTOwOPF7uiDLy0BfgEactsNj6GNxocAQvlOKH+0szY/?= =?iso-8859-1?Q?9o2la5zOsT/Zg55Xa1BcDT0dUNOSHaGZFjmk/uQiFE3KEtv2rKp0MMBQr7?= =?iso-8859-1?Q?8Wt12xIBaNjsN5sQReimiDTTasdQO8hXSBvb9YEYZ8BckFh/BeHdbH9uaL?= =?iso-8859-1?Q?d8JnRXUutaqy5pDwe4m1z33AYN7fSSCEnNg89Y04KxzuYfAHBX6zBsJF7i?= =?iso-8859-1?Q?VC9LhxH9qw/bGX2CVBykqDjPFmKGnIOjWSRb5fK3taGhRcV7HONqvX2CR4?= =?iso-8859-1?Q?KfPCAloQMFD8aal1xs5Q86SSNnWdqGUuDSlTvoabgj3VBwxBWhCRuIbnB+?= =?iso-8859-1?Q?U1egqrhUSOVv7HKsisG9j67SHjEmO1S4oVopGGbEEw7pkeGFWK2fJriMeI?= =?iso-8859-1?Q?U5hufw89YPe4yDlAAB0NN8aDhs0AvGgcjPbVxlDIqsrOohR2COkaTuW3so?= =?iso-8859-1?Q?Aa4iuQvJkKTYDHHkeFVjB7PR5kwoWpIV2mQULPvyek6NzebQ8WpZElQlYA?= =?iso-8859-1?Q?RgQAy7gmUE3+acCR9YnPlX4ERqFRz6obW6awY3DNgaX69KXw14uTHKWa+L?= =?iso-8859-1?Q?iVopUTfmFRX/40VcEOeIUrnEuVluFrJh5x?= Content-Type: multipart/alternative; boundary="_000_AM7P189MB102815FBBAC696A3FE173CEB9D3D2AM7P189MB1028EURP_" MIME-Version: 1.0 X-OriginatorOrg: Nibio.no X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7P189MB1028.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: c66b5f1c-7949-4036-5562-08dd18f85479 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2024 08:55:00.4590 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6df9a8ea-1ed0-462c-85a8-831200d5f7c5 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bicy6Gt6PWfc56rVAJneUobRcyC66F9oVEgYzyWswFXiZXLxlfWtdsyBvJClqIOlG0da7IknCiqVVwzly90EQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P189MB0821 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_AM7P189MB102815FBBAC696A3FE173CEB9D3D2AM7P189MB1028EURP_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ________________________________ From: Tom Lane Sent: Monday, December 9, 2024 5:07 PM We do only very coarse-grained analysis of whether a row is "dead". In principle, if vacuum had access to all the live snapshots of all sessions, it could realize that a row really is dead even though it's later than the current global xmin horizon. But discovering that would be quite difficult and therefore expensive. Notably, sessions would have to expose far more of their snapshot state than they do today, and there would have to be interlocks to allow other sessions to inspect that state safely, and that'd probably put us into much the same sort of too-many-lock-conflicts problem that the OP has already. I don't think there's any free lunch here. Maybe there's some other compromise between amount-of-state-exposed versus dead-row-discoverability, but finding a better way would take a great deal of creative effort and testing. regards, tom lane Hi again. On my bike to work this morning I was thinking more about this. When the application run vacuum I find this "7954046 are dead but not yet = removable removable" so the job knows what rows that are involved. Is it difficult to add parameter like force-dead-rows-removal that we send = to the vacuum job that will remove this rows like this ? Just to test what happens and also how it affects performance. The tables I work on are unlogged , vacuum command is controlled by the app= lication. If this option is only applicable on unlogged tables which are un= safe anyway and from command line , maybe that can help to reduce complexit= y and side effects. I am now testing on PostgreSQL "16.4 (Ubuntu 16.4-1.pgdg22.04+1) on x86_64-= pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit= " Thanks. Lars --_000_AM7P189MB102815FBBAC696A3FE173CEB9D3D2AM7P189MB1028EURP_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable



From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Monday, December 9, 2024 5:07 PM

We do only very coarse-grained analysis of whether a row is "dead"= ;.
In principle, if vacuum had access to all the live snapshots of
all sessions, it could realize that a row really is dead even though
it's later than the current global xmin horizon.  But discovering that=
would be quite difficult and therefore expensive.  Notably, sessions would have to expose far more of their snapshot state than they do
today, and there would have to be interlocks to allow other sessions
to inspect that state safely, and that'd probably put us into much the
same sort of too-many-lock-conflicts problem that the OP has already.

I don't think there's any free lunch here.  Maybe there's some
other compromise between amount-of-state-exposed versus
dead-row-discoverability, but finding a better way would take
a great deal of creative effort and testing.

            &nb= sp;           regards, to= m lane

Hi again.

On my bike to work this morning I was thinking more about this.


When the application run vacuum I find this  "7954046 = are dead but not yet removable removable" so the job knows w= hat rows that are involved.


Is it difficult to add= parameter like force-dead-rows-removal that we send to the vacuum job that= will remove this rows like this ?

J= ust to test what happens and also how it affects performance.

<= br>

T= he tables I work on are unlogged , vacuum command is controlled by the appl= ication. If this option is only applicable on unlogged tables which are uns= afe anyway and from command line , maybe that can help to reduce complexity and side effects.

<= br>

I= am now testing on PostgreSQL "16.4 (Ubuntu 16.4-1.pgdg22.04+1) on x86= _64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64= -bit"

<= br>

T= hanks.

<= br>

L= ars

<= br>


--_000_AM7P189MB102815FBBAC696A3FE173CEB9D3D2AM7P189MB1028EURP_--