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 1rp8rU-005HN6-MW for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 15:37:17 +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 1rp8rT-00HHpS-Dd for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 15:37:15 +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 1rp8rS-00HHjV-VL for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 15:37:15 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rp8rN-006bXv-UR for pgsql-hackers@postgresql.org; Tue, 26 Mar 2024 15:37:14 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e0fa980d55so4870525ad.3 for ; Tue, 26 Mar 2024 08:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1711467427; x=1712072227; 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=p3PACL6iKqPwws/3fUnhjEWpR3HtVbsrI1gN/iQ0EPI=; b=I6x6B4lTT/p+/YTIns3/7ZipHbx8QCj7BmDotfmVvqpLxG9FQuZjF7jjpsk0os3+tJ N0eBGcyhX5sFeTIvguMyPuYQI0wAVK7bGnL1jNICZvfnYQnuGLk1tcve/d4BReTVTcBq BY7omo7vbKcjte7eE+W9ancjdAb+vaBzebWHruUB5tolyPOOvthjUNZYR/lZRa7BfGKh JbNTg8b1s5LMgvT+JvkOuNB3NW0D0aWtNFomBGxdn9Ehb20Er1aq9CKrR6u1BZP6I0tx OIDh1BRWhKb6zBHztjV4Tlb4WT38F0XNX0WLJ4E5swRt8IS4a7GdblAqb6jTl1APdeTB w4ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711467427; x=1712072227; 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=p3PACL6iKqPwws/3fUnhjEWpR3HtVbsrI1gN/iQ0EPI=; b=N/EEzuhn7ZHbzl0SJN+DoS00f61bdW5URhyNt2stPZ5hw9/jZ+qn7c/ohoyfreRiyn snu68eC8MTvAtGseyt2fshyL6B0Gg/kc8e5IDI3NjYtNktthb87/y6PwIU2BBhuEuX/p xBljV45NtcdXL1wb9SmWflKFaHCgzYRszCpZYEuKF6SIaZmKoeqdDXzJslA6uqm8GYse 7e3606Q5OSpI/IqVf4jImcjpmsvse4Zox7kFHI1TNxO7wCWSSv5s9SmkBRcl2LI0BtrP R2dKmjJZlZFADpdMdwW2qoA9Np3JErcLL12haJFViJEae+ICV29Q2CTqtPu/DcTrxavS ZxZg== X-Forwarded-Encrypted: i=1; AJvYcCVORIphkfqZBQxNaZdvED7DY7xBlx/NaI8qyNWzsQsskOGjquFAsbI/AQvwWxiAArGeVMvtbqoyIN+pl/pPgL0KIVnSWR8Ave6caR6h X-Gm-Message-State: AOJu0YxymNY3qC782mTLB5zRTk9KpoDWgD4qea3NyBlx6eaYMNiLEgTn Ey4CDxhRfYH4PZj7aTH1ABSdBl32/A3HQtkTnaW0FDOdtW0GKmnQl2gERbh3Bg== X-Google-Smtp-Source: AGHT+IHQ6fAixYuokUfcruQGSn59uyRkyVQRhYb1Titkwj6D/tAiCqrbZa8q+idfXIz+m4eu+gNkHQ== X-Received: by 2002:a17:90a:6282:b0:299:73b3:cf15 with SMTP id d2-20020a17090a628200b0029973b3cf15mr1495936pjj.12.1711467427517; Tue, 26 Mar 2024 08:37:07 -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 x17-20020a17090a531100b002a03da6286asm7699405pjh.35.2024.03.26.08.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 08:37:06 -0700 (PDT) Message-ID: <2280bf7241119bb88cbe0fe5eb36490cbd04c0c0.camel@j-davis.com> Subject: Re: New Table Access Methods for Multi and Single Inserts 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 Date: Tue, 26 Mar 2024 08:37:04 -0700 In-Reply-To: References: <20230603223824.o7iyochli2dwwi7k@alap3.anarazel.de> <6be6f58815dc0844fbe058edf56b4e735a6efc1c.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 Tue, 2024-03-26 at 01:28 +0530, Bharath Rupireddy wrote: > I'm thinking > of dropping the COPY FROM patch using the new multi insert API for > the > following reasons: ... I agree with all of this. We do want COPY ... FROM support, but there are some details to work out and we don't want to make a big code change at this point in the cycle. > The new APIs are more extensible, memory management is taken care of > by AM, and with TableModifyState as the structure name and more > meaningful API names. The callback for triggers/indexes etc. aren't > taken care of as I'm now only focusing on CTAS, CMV, RMV > optimizations. >=20 > Please see the attached v14 patches. * No need for a 'kind' field in TableModifyState. The state should be aware of the kinds of changes that it has received and that may need to be flushed later -- for now, only inserts, but possibly updates/deletes in the future. * If the AM doesn't support the bulk methods, fall back to retail inserts instead of throwing an error. * It seems like this API will eventually replace table_multi_insert and table_finish_bulk_insert completely. Do those APIs have any advantage remaining over the new one proposed here? * Right now I don't any important use of the flush method. It seems that could be accomplished in the finish method, and flush could just be an internal detail when the memory is exhausted. If we find a use for it later, we can always add it, but right now it seems unnecessary. * We need to be careful about cases where the command can be successful but the writes are not flushed. I don't tihnk that's a problem with the current patch, but we will need to do something here when we expand to INSERT INTO ... SELECT. Andres, is this patch overall closer to what you had in mind in the email here: https://www.postgresql.org/message-id/20230603223824.o7iyochli2dwwi7k@alap3= .anarazel.de ? Regards, Jeff Davis