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 1krFpr-0004QH-TN for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Dec 2020 07:42:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krFpq-0000TQ-A8 for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Dec 2020 07:42:26 +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 1krFpq-0000T5-1I for pgsql-hackers@lists.postgresql.org; Mon, 21 Dec 2020 07:42:26 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1krFpj-0007gX-Ip for pgsql-hackers@postgresql.org; Mon, 21 Dec 2020 07:42:24 +0000 Received: by mail-pf1-x436.google.com with SMTP id h186so6013468pfe.0 for ; Sun, 20 Dec 2020 23:42:19 -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=2hqeRa65NHDUkJuzzYAOdC8USyTAmEnWLAFAH/seans=; b=caMkcJfxFmL5KAO71K+Mrokd5Rz1BGl1BriGE8lxaVO86PAp0rCj8NPGHerMmGbpmX WDsILHgpshsQCr8phDpyBBNh+0y4IgC1Rsp88aNBXNMAz4JlDn1VFjNFtN7ntGNqozk/ 5LssEKOYfsPWFzy8RL4rx0BvAld8xMi6TOU1EtZvH0U+NBpTqJ1g2ugR1ZMm7T3u+cxg lEvknbmmIKfb58bpbQHOpDMqBt9KdBUjjcNyRCzFqPO2vJBOXNd2UyOks7rFjpR4aeLp l2yslcqgB7/S68SwiWumXiT1e1+pdNyD1AUpMJaUsKUkSxpWNRqKn0JhiKQ0Z2lf60pX 8OoA== 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=2hqeRa65NHDUkJuzzYAOdC8USyTAmEnWLAFAH/seans=; b=O4Ti7tyCBLOAQxerAPXbL1RdgBFWyDAMOWLKT9/UWYNWvMXiu8JyXmLpWpZrGXd7FL f5ntEV+QY+bvXsTm5USwnblHsQ/3S3Md/JGDpLKCsUmG04CkR1DgQEBuv32ArtvFPqIQ PGm82EcLoT7Z6BKZb6bHINU/A7zlNpxrej+UjORZaFnvwqv+u8ASOzN8P/kCgRgXm+pW yCMZ4t2RpEgRG+2lJiHbNMEXJ0TVWWWuaEHRAS3swbss22THTTBKljW4hmnX91Xjvucx 58sES0q8RSUEESC7wX5G4jc7w2rysR/PCfywxo/zgjMZIgIVfpHNiqYK9txbt3aaIsKG xk5A== X-Gm-Message-State: AOAM530oy4vyCyf+wBEuEJQcsaR5c/SSiVHko9hAKOFm2Ge9Ft7GfTEn OrztS41K20ifb/Kq5OfOYnyqZRhthsDYE8UVoh0= X-Google-Smtp-Source: ABdhPJwAa5D26LXQZsXmWBSUf/Y5G4LzJqkErp0bZpeENlBJSl7FJGRPyuDX9rqlSeTWixT/CKOYT/A0uB8GgMYLHwc= X-Received: by 2002:a62:7ad5:0:b029:1a3:d0a2:e49 with SMTP id v204-20020a627ad50000b02901a3d0a20e49mr14554182pfc.31.1608536538254; Sun, 20 Dec 2020 23:42:18 -0800 (PST) MIME-Version: 1.0 References: <20201217050522.GU30237@telsasoft.com> <20201217204442.GX30237@telsasoft.com> <20201218175439.GA30237@telsasoft.com> In-Reply-To: <20201218175439.GA30237@telsasoft.com> From: Bharath Rupireddy Date: Mon, 21 Dec 2020 13:12:07 +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 11:24 PM Justin Pryzby wrote: > On Fri, Dec 18, 2020 at 07:39:14AM +0530, Bharath Rupireddy wrote: > > On Fri, Dec 18, 2020 at 2:14 AM Justin Pryzby wrote: > > > 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. > > Right now you have heap_insert_begin(), and I asked if it was really > heap-specific. Right now, it populates a struct based on a static list of > arguments, which are what heap uses. > > If you were to implement a burp_insert_begin(), how would it differ from > heap's? With the current API, they'd (have to) be the same, which means either > that it should apply to all AMs (or have a "default" implementation that can be > overridden by an AM), or that this API assumes that other AMs will want to do > exactly what heap does, and fails to allow other AMs to implement optimizations > for bulk inserts as claimed. > > I don't think using a "union" solves the problem, since it can only accommodate > core AMs, and not extensions, so I suggested something like reloptions, which > have a "namespace" prefix (and core has toast.*, like ALTER TABLE t SET > toast.autovacuum_enabled). IIUC, your suggestion is to make the heap options such as alloc_bistate(bulk insert state is required or not), mi_max_slots (number of maximum buffered slots/tuples) and mi_max_size (the maximum tuple size of the buffered slots) as reloptions with some default values in reloptions.c under RELOPT_KIND_HEAP category so that they can be modified by users on a per table basis. And likewise other tableam options can be added by the tableam developers. This way, the APIs will become more generic. The tableam developers need to add reloptions of their choice and use them in the new API implementations. Let me know if I am missing anything from what you have in your mind. With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com