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 1kq5D7-00081m-PH for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Dec 2020 02:09:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kq5D5-0000xy-Pt for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Dec 2020 02:09:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kq5D5-0000xq-HH for pgsql-hackers@lists.postgresql.org; Fri, 18 Dec 2020 02:09:35 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kq5Cy-000776-0p for pgsql-hackers@postgresql.org; Fri, 18 Dec 2020 02:09:34 +0000 Received: by mail-pj1-x1031.google.com with SMTP id b5so490269pjl.0 for ; Thu, 17 Dec 2020 18:09:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ogjX0IYFxahwlbk0vbBTnXskjOnLV0wWgx4/kNZ41KE=; b=BTOjyAHpHh63Rv7PptNcGLZr4x0w+fjDwPQeyCk4qyYkFbvfTt0INAoazqO8GTygFi LaRfzwyEfk02IejIbrm399YFKStMLTCHqSpv7IbKGZn7EQ5F93vIHjPY+eEK8O4pAXiD SbA8EgP4I9cAwEBoADC4VcrL0IKfH2Xbv9W96YkL+0Pu5GP6vB4qatsrO2L1BkTJWKfg Jd9Iw+G6VthzOCoGeq1JcGKvri6CoPjU8lGxoJ+VPBj3mH3T09L2pdOcXl8vCzjcFpHK UKZMckLDBOepj2hyu58tDXb4dg3NTFDCIgKGKjfFGnvEhtwBDYUzdZDdSCPTgSz3bKVr 997w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ogjX0IYFxahwlbk0vbBTnXskjOnLV0wWgx4/kNZ41KE=; b=IJRLO/klW46Tvg+780JJ+PCNRrFRY4fNLUKWrEfCdrJmEx1zXj7pd8X+fgnkLRsZfh NNLbdpfOrYqT/IkHLaiFtPgn3UvpgaoUoagT3tODpInmdw9G7SEufBpd379DkRF2Yfjj lnqnqmMlY2gxtQI4ah3qLxAcFCfiJOqqs2/fe0XYuJdPHAB3nLORQaTMLo73RueN+TAr FzLy2BFBImYDdIvRg83Qerrw8P4icqYnolmI0MDyBEUUcXkIhcRjTM1LtuJiOpy+0tTd +qk0xALO+ueQHBaLhLi0elKwFJKUl89yXPMV+vq4RHdzqA381MViedTwiUkHAm/U+jhE Jbwg== X-Gm-Message-State: AOAM53344Dg+pChP7TbOtBL700jhvv7Wq6FfaxEM0hahCw3aOSkU6sfL DBuSXCwdKVEzIjw7GMOjxiKLsOfNuISK9yl8UKs= X-Google-Smtp-Source: ABdhPJzBGyin4YqnMFZnDlcHiROKzuymvXINgC4PdX8kFTExnkbIT1fjqak8iBmy/15SqL2Hom0gznuOiENhQA3ExOQ= X-Received: by 2002:a17:902:7292:b029:dc:ac9:25b5 with SMTP id d18-20020a1709027292b02900dc0ac925b5mr2267588pll.2.1608257365771; Thu, 17 Dec 2020 18:09:25 -0800 (PST) MIME-Version: 1.0 References: <20201217050522.GU30237@telsasoft.com> <20201217204442.GX30237@telsasoft.com> In-Reply-To: <20201217204442.GX30237@telsasoft.com> From: Bharath Rupireddy Date: Fri, 18 Dec 2020 07:39:14 +0530 Message-ID: Subject: Re: New Table Access Methods for Multi and Single Inserts To: Justin Pryzby Cc: PostgreSQL-development , Andres Freund , Luc Vlaming , Paul Guo Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Dec 18, 2020 at 2:14 AM Justin Pryzby wrote: > 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); +1 to make them optional. I will change. > +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. What should happen if both multi_insert_v2 and insert_v2 are NULL? Should we error out from table_insert_v2()? > 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. I could not think of other tableam attributes now. But +1 to have that kind of flexible structure for TableInsertState. So, it can have tableam type and attributes within the union for each type. > 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. > Currently, the bulk insert state is outside and independent of > tableam. I think we should not make bulk insert state allocation and > deallocation tableam specific. Any thoughts on the above point? With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com