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 1s029s-000Dlg-UK for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2024 16:41: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 1s029q-000iKN-1I for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2024 16:41:14 +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.94.2) (envelope-from ) id 1s029p-000iKF-IL for pgsql-hackers@lists.postgresql.org; Thu, 25 Apr 2024 16:41:14 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s029n-0001WH-Ni for pgsql-hackers@postgresql.org; Thu, 25 Apr 2024 16:41:13 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2a52c544077so988188a91.1 for ; Thu, 25 Apr 2024 09:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1714063270; x=1714668070; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=NxL6wXftksQ5HQfKq0wAQ8Iigtj1LYSwMj5vwlpV2CI=; b=B0nyvAVaE8ALbT0p7NGEeNMi1K/CUZUeEdCHHfHa3Fy0QawGjGk4pYuj4PKt6tvJb8 BYm0lae3iRGmQd8W0jpKcGzXn16VB+px8Si8AaJDArsHRukuUnvtYhCObLFqfumsLtvo RxICp/zdq/KofquZPBEeKCcHQmqT63wPzF8Yd7rTNdEae4YQQu8tG0vYbbK6JlhOQCPH N/kpsh3zdloedQvKkz3vWRqcDPgbcaN89FO8OSI/cGNpE2f6yBahYwPzIA4UTVhxVKAX 0btt7fIEgT1y9QOM2l278C7nFKRoRgtLErFDocFaZt91N/JcBC7dtQKAwQBknI05pMkg 0F2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714063270; x=1714668070; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NxL6wXftksQ5HQfKq0wAQ8Iigtj1LYSwMj5vwlpV2CI=; b=uItTwVZnIioggSOC9Qeb22SeLmElrEd0QRDQK4L6fwc9E6yufSga9adrYBQrXQy8A3 PICarrXGI3+OqGAzZjEyivOWBgOlzuSmCdsbiguq8hZhzzPsq9kY9VAJ/nniyjzZxIsm cek/y201w/euiqu02XhWIqi/huLbp8sVVVANaZrDPXAykEopAl5znDTFlm4xUB8g/DQ3 4nK1TqQkMnlH7LSK859Zyq36cr17uziMyDzW0oHR3MtrfrfnmNBLfhcXy0uf3wtxKkBI 42s4ixnW5bfhWlB2e5jIP7yRjZi53Y0TNvwCUM5M5rky9wVq85CpHaPbGnx9F/IRHiIG /rNA== X-Forwarded-Encrypted: i=1; AJvYcCXZImjzqVzF0wABAVCmnPYRWPQYmRr08FIrJGHC8V26EafGkWSvG9YAWrH9HQSBdric/Zy3s5iSnyF1wWgJAof4u7iePymUPn908b7Y X-Gm-Message-State: AOJu0YzsOvCjQGQxRXAPovy458OawNUQVP79ocqlxeLLmL5RdcgEPgLV knl2cGeDGOK46VD4mxAQBZyhYZH8DHDbs1LhSaMVyd37UaC5UZz1AcMrkNMf+A== X-Google-Smtp-Source: AGHT+IEs02s1K47goqE+JQPw4TY+q15mBI+sYPeL0ikR2ky38Zl0PnZ7Eha0396GnLVtjkVPMIrN7Q== X-Received: by 2002:a17:90a:cb18:b0:2ab:b411:8cbc with SMTP id z24-20020a17090acb1800b002abb4118cbcmr80051pjt.31.1714063269906; Thu, 25 Apr 2024 09:41:09 -0700 (PDT) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id g3-20020a17090a828300b002abf2057cefsm12759678pjn.0.2024.04.25.09.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 09:41:09 -0700 (PDT) Message-ID: Subject: Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM From: Jeff Davis To: Bharath Rupireddy Cc: Masahiko Sawada , PostgreSQL-development , Andres Freund , Dilip Kumar , Luc Vlaming , Justin Pryzby , Michael Paquier , Matthias van de Meent , Alexander Korotkov Date: Thu, 25 Apr 2024 09:41:08 -0700 In-Reply-To: References: <20230603223824.o7iyochli2dwwi7k@alap3.anarazel.de> <6be6f58815dc0844fbe058edf56b4e735a6efc1c.camel@j-davis.com> <2280bf7241119bb88cbe0fe5eb36490cbd04c0c0.camel@j-davis.com> <12f1a2d8dd3b6305c0354f1c701f44b7be5e54eb.camel@j-davis.com> <8633171cb034aafc260fdf37df04b6c779aa1e2f.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2024-04-24 at 18:19 +0530, Bharath Rupireddy wrote: > I added a flush callback named TableModifyBufferFlushCallback; when > provided by callers invoked after tuples are flushed to disk from the > buffers but before the AM frees them up. Index insertions and AFTER > ROW INSERT triggers can be executed in this callback. See the v19- > 0001 patch for how AM invokes the flush callback, and see either v19- > 0003 or v19-0004 or v19-0005 for how a caller can supply the callback > and required context to execute index insertions and AR triggers. The flush callback takes a pointer to an array of slot pointers, and I don't think that's the right API. I think the callback should be called on each slot individually. We shouldn't assume that a table AM stores buffered inserts as an array of slot pointers. A TupleTableSlot has a fair amount of memory overhead (64 bytes), so most AMs wouldn't want to pay that overhead for every tuple. COPY does, but that's because the number of buffered tuples is fairly small. >=20 >=20 > > 11. Deprecate the multi_insert API. >=20 > I did remove both table_multi_insert and table_finish_bulk_insert in > v19-0006. That's OK with me. Let's leave those functions out for now. >=20 > If the design, code and benefits that these new Table AMs bring to > the table look good, I hope to see it for PG 18. Sounds good. Regards, Jeff Davis