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 1o4P4y-0008Sv-Te for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jun 2022 15:49:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o4P4v-0005ol-QY for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jun 2022 15:49:09 +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 1o4P4v-0005oX-HP for pgsql-hackers@lists.postgresql.org; Thu, 23 Jun 2022 15:49:09 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o4P4o-0002JU-5K for pgsql-hackers@lists.postgresql.org; Thu, 23 Jun 2022 15:49:09 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id r9-20020a4acb09000000b0041b6abb517fso4092762ooq.2 for ; Thu, 23 Jun 2022 08:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8+S4N/p2styPUp9iYDxjpXyI8hqO0VTARjFa7+HJJzk=; b=Rd9TPb8qdz/CovLeVNe5NiO5D0VSPxPQautBHgH77au6Ep1oLn7LFYkAqz8Y35U1rE 74EmJgvT+NlTchkvWB10N+hKlmAPWH/Qg91VpRjM0pA4GEn2BoHXatuW/EvFFdpEVzDI B7lXw1tqFEkjMKvAw6D9cqHzhVbF9S6sqC6a0zqXaEtRcmrPQ562qMWq0qTxfKzW+Adw iVgDDXPcyvKk1kT89NcNBEeA/cqDBO9mhQV2xE8Y/USYsUs+hNPqO98S9ebPVhGZZaLI zvxJ8x/eRbH1HdGXrGdbBgqfzMrPpwczsexhUGeYvVFGt4UahxhRmBKaviwGkdGswhC4 7kWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8+S4N/p2styPUp9iYDxjpXyI8hqO0VTARjFa7+HJJzk=; b=H2maPzz9OSxJCBdACcGFrhTtKllit5C5sqSxZqC2XaZcT2cOpASbtqu8K8Q3evG8q0 F7vSKWFTOs+jdgpfMUlRX26XSp7qvWpNaS+TF720oAvexaQY4S+A0abKk7Y+CzD/7k6W yBIBvApnQHebktdYEG2n3Dcaa/CIgIUgU8+iS6Zr8fYhrnrGiOoub0IQTTdjVKzryMMz SRhQLFZK7fDmKFHISS+ixTvb+vVIn92rXWa4IgMf7QDBbgPwtJyDXqaCkZWcRnK92qHx 5MjKHBgB3C9OwJuRi6/4qvcCiJAlmM6QKdEVsVXM9EXqZFCqkhyrK6/UoZFNkt4vK2Ke Rkkw== X-Gm-Message-State: AJIora9xCSUyKG4Kn0zO1l885fWA4YOP12XS82sotrh4rm7dBF6bVPI2 PS47pfNwfjJY21gFcqFE7/mnNPulFEyQ7IwEyrpZEGeSrp2Q9Y1e4DYUIbWgqrzbSlYEhlqiaz/ fA+eV67jgp2JZ8kZW/+I2vncjpX7H8FyVYM/6OBWumsRoiB0q+ku6oK9SnwDzuAnjj/L2ljSnlo vEFy2oCuGEDjnJhWbx9NnLvGPWiiTtu5vFxz55MvMK/74TwrbTVHHpseQxvRe7W3cd6yMvx7nDD TLA X-Google-Smtp-Source: AGRyM1vh24La3Z5gSsXsOf7wZtB0YoEz5h/6cLPYjA2JyhDZSvoVErd6cyskurGcnIIVOYkbwAjNYwEd1P+6NY0VFFk= X-Received: by 2002:a4a:1746:0:b0:41e:982a:1e24 with SMTP id 67-20020a4a1746000000b0041e982a1e24mr3958565ooe.89.1655999339487; Thu, 23 Jun 2022 08:48:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Simon Riggs Date: Thu, 23 Jun 2022 16:48:48 +0100 Message-ID: Subject: Re: [PATCH] Compression dictionaries for JSONB To: Aleksander Alekseev Cc: Jacob Champion , PostgreSQL Hackers , Alvaro Herrera , Matthias van de Meent Content-Type: text/plain; charset="UTF-8" X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2 Jun 2022 at 14:30, Aleksander Alekseev wrote: > > I saw there was some previous discussion about dictionary size. It > > looks like this approach would put all dictionaries into a shared OID > > pool. Since I don't know what a "standard" use case is, is there any > > risk of OID exhaustion for larger deployments with many dictionaries? > > Or is 2**32 so comparatively large that it's not really a serious > > concern? > > I agree, this is a drawback of the current implementation. To be honest, > I simply followed the example of how ENUMs are implemented. I'm not 100% sure > if we should be worried here (apparently, freed OIDs are reused). I'm OK with > using a separate sequence if someone could second this. This is the first time > I'm altering the catalog so I'm not certain what the best practices are. The goal of this patch is great, thank you for working on this (and ZSON). The approach chosen has a few downsides that I'm not happy with yet. * Assigning OIDs for each dictionary entry is not a great idea. I don't see why you would need to do that; just assign monotonically ascending keys for each dictionary, as we do for AttrNums. * There is a limit on SQL statement size, which will effectively limit the size of dictionaries, but the examples are unrealistically small, so this isn't clear as a limitation, but it would be in practice. It would be better to specify a filename, which can be read in when the DDL executes. This can be put into pg_dump output in a similar way to the COPY data for a table is, so once read in it stays static. * The dictionaries are only allowed for certain datatypes. This should not be specifically limited by this patch, i.e. user defined types should not be rejected. * Dictionaries have no versioning. Any list of data items changes over time, so how do we express that? Enums were also invented as static lists originally, then had to be modified later to accomodate additions and revisions, so let's think about that now, even if we don't add all of the commands in one go. Currently we would have to create a whole new dictionary if even one word changes. Ideally, we want the dictionary to have a top-level name and then have multiple versions over time. Let's agree how we are going do these things, so we can make sure the design and code allows for those future enhancements. i.e. how will we do ALTER TABLE ... UPGRADE DICTIONARY without causing a table rewrite? * Does the order of entries in the dictionary allow us to express a priority? i.e. to allow Huffman coding. Thanks for your efforts - this is a very important patch. -- Simon Riggs http://www.EnterpriseDB.com/