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.96) (envelope-from ) id 1viUI2-007iIP-0W for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 09:14:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1viUI0-0067qZ-0D for pgsql-general@arkaria.postgresql.org; Wed, 21 Jan 2026 09:14:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1viUHz-0067qQ-1x for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 09:14:12 +0000 Received: from mout-u-204.mailbox.org ([80.241.59.204]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1viUHx-001glp-1p for pgsql-general@lists.postgresql.org; Wed, 21 Jan 2026 09:14:11 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4dwz5m6dMsz9sp4; Wed, 21 Jan 2026 10:14:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1768986845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vrgh2gRXj6SC01rYkf09unJarzxxpeDSM06gt+ZA4Oc=; b=mgyq/bisXE3gCO1OMPybB/J2OWbE492eInFSyuyPNHBAMFJ+Rl8GTuRgKvEWgHE0qZTdty qCRrXsJC6AEtpGjVAWc2D6ECI5haUdhTKe5ehbZYE+WFz1sg2wn+GSZjiaeduOElKlSZm1 /lrlW8ag20JwnPyEdQJxIQAZxrqWwuRroDcveFbURIJq0S2p53+BL09AIB9vxU3EPYIVp9 fQnFquEAf61Ia6k+HKJlONgc9hlldV4DuODabZMXiLVYEIZ7vxK15Rubkk0BXefPp8JPDc jiBMiUlH199v7Su0yYkb2sx6nP/JAUFcBWjPsG0WDyln3EcVw3f/D9bedO0gPg== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ewie@ewie.name designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=ewie@ewie.name Date: Wed, 21 Jan 2026 10:14:02 +0100 From: Erik Wienhold To: Nicolas Seinlet Cc: "pgsql-general@lists.postgresql.org" Subject: Re: pg_trgm upgrade to 1.6 led to load average increase Message-ID: <261d81f9-3291-40e3-9af1-48724c649887@ewie.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4dwz5m6dMsz9sp4 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-01-20 09:50 +0100, Nicolas Seinlet wrote: > we've upgraded the pg_trgm extension from 1.0 to 1.6 on our production > database, while sticking our postgresql cluster version to 16. This > led to an increase in the load average of the server (twice the load > average on our use case). After investigation, we found our issue was > linked to : > https://github.com/postgres/postgres/commit/935f6666502250abde8615bc7805a6e5aa05a066 > > We issue queries like : > SELECT model, res_id FROM ir_model_data WHERE module='base' AND name='public_user'; > > With 1.0 extension, the query is planned with a matching btree index: > "ir_model_data_module_name_uniq_index" UNIQUE, btree (module, name) > > With 1.6 extension, the query is planned with a gist index: > "ir_model_data_name_idx2" gist (name gist_trgm_ops) > > 1.0 extension executes the query in 0.1ms, while 1.6 in 100ms > > Our solution was to revert to pg_trgm 1.5, so remove operation 11 from > gist_trgm_ops. After the removal, the load average was back to normal. > > Is there another way of preventing PostgreSQL to use the gist index > when a btree exactly match the condition? It's been suggested to move the GiST index to another tablespace with increased random_page_cost. [1] > Is ivt viable to stick with the extension in 1.6, but with the > operation 11 removed from gist_trgm_ops? This would be the same as sticking with 1.5 since the new equality operator is the only change in 1.6. [1] https://www.postgresql.org/message-id/CAApHDvp3W7G8Oo4=wjt0ceTbic35SHJ=qfoD_CnPXSnZVzCkhQ@mail.gmail.com -- Erik Wienhold