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 1w12LN-002R8K-2q for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 13:14:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w12LL-0045zl-1g for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 13:14:20 +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.96) (envelope-from ) id 1w12LL-0045zZ-0T for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 13:14:19 +0000 Received: from meesny.iki.fi ([2001:67c:2b0:1c1::201]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w12LJ-00000001wTR-0xFd for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 13:14:18 +0000 Received: from [10.0.2.15] (unknown [130.41.208.2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4fXQ1K4TCmzyQ5; Fri, 13 Mar 2026 15:14:13 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1773407654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Obv6RvO3cTBp8EyY/cADsCvZd73Mle8pAi8yKjNk+9A=; b=Qx/eY9zjmsB99eETme0eUeEXXjMo2USEEy6q796I6mC4JmzXghggjpW/fXPm2nWf2TyFyg eAEtMKrEunLI1duo5DXOjNEb/+sZZK7KYQyrxpuYg3b1DuL2Gd6eRbPpAN6X3Ioc3+hROS pYJLbPmbqWQq06TQsKYcqHxvoBIHDl8= ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=meesny; cv=none; t=1773407654; b=UWElUvSdtw6EXJo+C4UEh7mrzUd31WTcSWH2V7d3SASYdoQi4+Hav2kzmzyF6y/Knf3I6K rb1jopJmWgTL+V3tjQztRYP7/Jv13M+/iTsIU0lSt8WCxLHne2oJz8IbsFZDDfvDPUOsp9 wmoUFzqALH5dJp4Z5PbHMrrLo+jBxJg= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1773407654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Obv6RvO3cTBp8EyY/cADsCvZd73Mle8pAi8yKjNk+9A=; b=VcknY1BfQI1Gt77+b9/z66oGxwBfp/DjWrZK2Mefgik0zR9875S1IexwzDm5+DIVEOCyg9 UakT7FLg4q4C7kPGleKZFZNNxGNto/HHuGxhEEM3xdNFuRvm36FO1VWHyU5zuQf+IyjS97 CdA5MGL7ueuc9AZshB65cUQpCt7q66s= Message-ID: Date: Fri, 13 Mar 2026 15:14:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add a check for interrupts in ginInsert To: Vinod Sridharan , pgsql-hackers References: Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/03/2026 22:26, Vinod Sridharan wrote: > Please find attached a small patch that adds the ability to check for > interrupts during the insert into the GIN index. Currently, ginInsert > can generate a large number of entries for a given input tuple from > extractEntries. In the case of Json/Jsonb for instance, the standard > opclasses may generate 1 term per path & value (which may be large). > During index build, the build process does check for interrupts in > between the inserts of each entry into the index (since there may be a > large number of entries to insert). However, the same loop during > insert was not checking for interrupts. This patch adds an interrupt > check to allow for early termination if the overall request is > abandoned. I believe this should be a safe point for checking for > interrupts since we should not be in the middle of modifying the index > tree in between entries. Applied, thanks. To test this, I created a large array: create table largearray as select array_agg(g) from generate_series(1, 10_000_000) g; and table with a GIN index: create table gintest (intarray int[]); create index on gintest using gin (intarray); -- to reach the ginHeapTupleInsert() function: alter index gintest_intarray_idx set (fastupdate = off); Without the patch, insertion into the index takes about 5 seconds on my laptop. A larger array with a more complicated extract function could take even longer. Without this patch, it's indeed uninterruptible. The fast-update path already had CHECK_FOR_INTERRUPTS() calls. - Heikki