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 1sjZXu-001uxd-54 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Aug 2024 07:26:18 +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 1sjZXs-00Ganc-5Y for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Aug 2024 07:26:16 +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 1sjZXr-00GanU-SE for pgsql-hackers@lists.postgresql.org; Thu, 29 Aug 2024 07:26:16 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sjZXp-001yh6-QZ for pgsql-hackers@postgresql.org; Thu, 29 Aug 2024 07:26:15 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2f4f24263acso4724921fa.0 for ; Thu, 29 Aug 2024 00:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724916372; x=1725521172; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Rg5k0zMJsnx8EfkBio/Ys+4duZs2EHe3YzfrtUi7PA0=; b=LPltCvP7b7cynixxry707bWfOCySGaKokYkEwfNIA9v/Doq7E31x+KPFZajHp8myX6 5v+BFjp68AlTzYGX+86Ed91TaX96oGRzQrjrGpAVD4fVXZ6VP0q7Wyj2elRvERPr+Ge/ 1IPJ4GxUwFtJWBHB0DFDg6G7G8Pk/ohejI+h1EAt7npjgjvUOfU52iOp0H7NMhbFzL5+ ujGoumZJtWhP61fYGfAHkiNiW2HRwEKOXRyHTIQC1teHVaCjpnFMpOgNaaEgt6sGwZtw erg/UFe5XwGvWuBDqgHq93Qwps/d/mMv56Kz2WYKxV7/QBQR+93Gpi61cErvCRcdt1Bh Xplw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724916372; x=1725521172; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rg5k0zMJsnx8EfkBio/Ys+4duZs2EHe3YzfrtUi7PA0=; b=oLYe+njsZf8Bj/2DJ+3HdyxMbLGM0v7L9EaBAJtB9j1IwvGRRdf7ny+V9OMJ2Bpalp sL9A2TXNECYfXvLPC72jUiP9hgbTse2DgkWQSDm6loBkyjhQpp59pt+wWdnR8tgi+E8Q LiKWymQALuytEElYcdJ9Lfu2Jzm18wF2PzAoX+6hpIkScuhncPVQQdiQtO+SK3K9KsX7 sc0T7wM8R4Kj0a1TBW2vs0+7AjADJBe4pArMK2wUrfVq/EVSmod2pCmvmen6KmNhYNkL ZrHYjcllJ1PakUxaYPcdF7sb/ELnHBP+bOzXPrN9Z9Fa9WRnzPn8d3rwvRHZue2nnD+b rj+A== X-Forwarded-Encrypted: i=1; AJvYcCUNdKQjksxHH76ktRAG3yHG10Mgp3Yf/9DXrla2Bfdhueixa3JqVdfJA9qn1XPoa0yBB9Co0rT2LKWngh9X@postgresql.org X-Gm-Message-State: AOJu0YyXXvziP99IQYDs/HDwbXYumRrBJKv9kAhpzlL/Zckr4u0kT6ag by/OkF2+Te0/3+a28mSob/vgqewL5f8modejFwRo62GCu5Squ2w7+9x91TCjGoZ3nHTgVvERlVK 8td05CpI9jIgxAj2rPdJprf5t9bc= X-Google-Smtp-Source: AGHT+IHWe/OqpwTwE1x+KUUL/HH3wGkORUJe6ysS70MuHvddhqJYLG34MGcBejuRMvcGDIs5LHdQNIPZsoHOdHatMas= X-Received: by 2002:a2e:4c19:0:b0:2f2:a1f1:39ed with SMTP id 38308e7fff4ca-2f6108af59dmr12359701fa.48.1724916371485; Thu, 29 Aug 2024 00:26:11 -0700 (PDT) MIME-Version: 1.0 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> <229c4f7219ed164088dadc935df21e1cf125e191.camel@j-davis.com> <23a29125a2d07f96d49f97c31fcdb09a7f0ff6c1.camel@j-davis.com> In-Reply-To: <23a29125a2d07f96d49f97c31fcdb09a7f0ff6c1.camel@j-davis.com> From: Bharath Rupireddy Date: Thu, 29 Aug 2024 12:55:59 +0530 Message-ID: Subject: Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM To: Jeff Davis Cc: Masahiko Sawada , PostgreSQL-development , Andres Freund , Dilip Kumar , Luc Vlaming , Justin Pryzby , Michael Paquier , Matthias van de Meent , Alexander Korotkov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Aug 28, 2024 at 3:14=E2=80=AFAM Jeff Davis wrot= e: > > On Mon, 2024-08-26 at 14:18 -0700, Jeff Davis wrote: > > 0001 implementation issues: > > > > * We need default implementations for AMs that don't implement the > > new > > APIs, so that the AM will still function even if it only defines the > > single-tuple APIs. If we need to make use of the AM's multi_insert > > method (I'm not sure we do), then the default methods would need to > > handle that as well. (I thought a previous version had these default > > implementations -- is there a reason they were removed?) > > On second thought, it would be easier to just have the caller check > whether the AM supports the multi-insert path; and if not, fall back to > the single-tuple path. The single-tuple path is needed anyway for cases > like before-row triggers. Up until v21, the default implementation existed, see https://www.postgresql.org/message-id/CALj2ACX90L5Mb5Vv%3DjsvhOdZ8BVsfpZf-C= dCGhtm2N%2BbGUCSjg%40mail.gmail.com. I then removed it in v22 to keep the code simple. IMO, every caller branching out in the code like if (rel->rd_tableam-> tuple_modify_buffer_insert !=3D NULL) then multi insert; else single insert; doesn't look good. IMO, the default implementation approach keeps things simple which eventually can be removed in *near* future. Thoughts? One change in the default implementation I would do from that of v21 is to assign the default AMs in GetTableAmRoutine() itself to avoid if .. else if .. else in the table_modify_XXX(). -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com