Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kq09J-0005oP-TL for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Dec 2020 20:45:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kq08n-0006E2-El for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Dec 2020 20:44:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kq08n-0006Dp-4S for pgsql-hackers@lists.postgresql.org; Thu, 17 Dec 2020 20:44:49 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kq08j-0001nc-Gm for pgsql-hackers@postgresql.org; Thu, 17 Dec 2020 20:44:47 +0000 Received: by mail-oo1-xc29.google.com with SMTP id o5so26848oop.12 for ; Thu, 17 Dec 2020 12:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HGd2z/DBXdJ+Png2+KTcNCIcgIkovt5xHZ7wwNPCZp0=; b=dXxlWq8H67b+s6ZrZ1eLsVIzVKMhHfB0HMJJyspAD+SjAnWQ98uyG6zULfaj9f7yCQ NXi0Zw3wn4KaoHUcxYxJdhA32OijmAtGSWXiM7heruHliHaLpCbVQTO1grD5GkL0DAot 9CYS743ZJ8Ggs+BRJ23W3WAOwtkTelmcTPVvJDZKfkL0PJKZZcDOvjyT4F7qwX/CEgwM 4rMppDFAbKKXlaQCKfdMJT7LsEkNIeLtwVPKNGySags5hWAmnBMWW/RRmT2j0dK0z7cW /TjG37xwXIeTxVlAh2O13bR0DuFf2yPgpmH3LEfkOkK1HqCjgyyzrGCf4zFbrDl2ThwR uXGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HGd2z/DBXdJ+Png2+KTcNCIcgIkovt5xHZ7wwNPCZp0=; b=iwxqAhmW4zUTL02MSGmC7NOmX3rRETO3jmjnn8FF0B1Rhzpg66XEV2FXI9rQLkzSuQ t1N1WlijJAIEJ3MOloOy8dM8OsX898+V6EmXRVcE15HtB/V6r6DPAsM3lN1wdDmip6sp C3a5JwuVTKUmzUBQ5TBKcPvfiZSjCSq9LMB2LVZMkDnWGTeUPr7T+eGj10jfK2yM3OZ1 VMqQ90tXZaKhhAe2pl5Vk7rewDAYkIHQKUGX95VVm2UOhsokbSx8zDJtta6ugh8wXlUl 56dYmasp++qQhOO6MOyawPcXIyLYg+XO1mhIPEUHVgkbVrk///ExPzn/9Z3eGJq/nD2v dV2Q== X-Gm-Message-State: AOAM531JgfQGkZcBiqeepNdv/Dh7rSd5DJXj06XJflU9s/PQXFMBBX0V 4wldVO+XFkDgwfmGLttQwX4Qsg== X-Google-Smtp-Source: ABdhPJxcuglv4n6eqihBFvMRvE7pgArrf7M6TCpzVX+W36f+nslzgmVp5hxETFPFky5oP32zrm9bNg== X-Received: by 2002:a4a:bc8d:: with SMTP id m13mr622343oop.63.1608237884352; Thu, 17 Dec 2020 12:44:44 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id l132sm1302301oia.23.2020.12.17.12.44.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Dec 2020 12:44:43 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5043D80071F; Thu, 17 Dec 2020 14:44:42 -0600 (CST) Date: Thu, 17 Dec 2020 14:44:42 -0600 From: Justin Pryzby To: Bharath Rupireddy Cc: PostgreSQL-development , Andres Freund , Luc Vlaming , Paul Guo Subject: Re: New Table Access Methods for Multi and Single Inserts Message-ID: <20201217204442.GX30237@telsasoft.com> References: <20201217050522.GU30237@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Dec 17, 2020 at 04:35:33PM +0530, Bharath Rupireddy wrote: > > You made the v2 insert interface a requirement for all table AMs. > > Should it be optional, and fall back to simple inserts if not implemented ? > > I tried to implement the APIs mentioned by Andreas here in [1]. I just > used v2 table am APIs in existing table_insert places to show that it > works. Having said that, if you notice, I moved the bulk insert > allocation and deallocation to the new APIs table_insert_begin() and > table_insert_end() respectively, which make them tableam specific. I mean I think it should be optional for a tableam to support the optimized insert routines. Here, you've made it a requirement. + Assert(routine->tuple_insert_begin != NULL); + Assert(routine->tuple_insert_v2 != NULL); + Assert(routine->multi_insert_v2 != NULL); + Assert(routine->multi_insert_flush != NULL); + Assert(routine->tuple_insert_end != NULL); +static inline void +table_multi_insert_v2(TableInsertState *state, TupleTableSlot *slot) +{ + state->rel->rd_tableam->multi_insert_v2(state, slot); +} If multi_insert_v2 == NULL, I think table_multi_insert_v2() would just call table_insert_v2(), and begin/flush/end would do nothing. If table_multi_insert_v2!=NULL, then you should assert that the other routines are provided. Are you thinking that TableInsertState would eventually have additional attributes which would apply to other tableams, but not to heap ? Is heap_insert_begin() really specific to heap ? It's allocating and populating a structure based on its arguments, but those same arguments would be passed to every other AM's insert_begin routine, too. Do you need a more flexible data structure, something that would also accomodate extensions? I'm thinking of reloptions as a loose analogy. -- Justin