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 1pzcOb-0003r9-07 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 May 2023 12:06:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pzcOZ-00081Q-K0 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 May 2023 12:06:11 +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 1pzcOZ-00081G-7N for pgsql-hackers@lists.postgresql.org; Thu, 18 May 2023 12:06:11 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1pzcOW-000U4o-LB for pgsql-hackers@lists.postgresql.org; Thu, 18 May 2023 12:06:10 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-64a9335a8e7so14040416b3a.0 for ; Thu, 18 May 2023 05:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684411567; x=1687003567; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1T+k/PEJqXLYX7iQPUKufJ1er66dWQInlEqTnq6ToS4=; b=KBFwx7nlF+Ct5QshDlPOVOosUUxe1uwQwwKVJMP5wC9HIHbiEOkeE0k/ObhPTug4G7 bfNSM1eQZPe5tjcX93l01SDgJNkSB/l4zv34/aq3DEcY8UU0x1Zssw5v49IgF1QM6nB5 1RkVb7MvLD1nOYcwi5H7zg8+b7+DxY+QH5ofRNR+X0UKSDrYReKUxVdKGnCX93BErhgJ EcMsrf+uftSDmIcull0/cT/t2n0TeUhSOvbeXGGxX8XleALTN/H243cwiLPz5t3Pk+y4 ybbxMDDZ9nC21F2vYlXe2vBOvoRbhWcaAAlw1j4/nNA7TtPrlH1N26oXz4CTZnRkojQP uB8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684411567; x=1687003567; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1T+k/PEJqXLYX7iQPUKufJ1er66dWQInlEqTnq6ToS4=; b=OeH6blqj0qrdYlb/fpsHS+1nbnlzuSphJZbsMv5PH2bgG3nCN5UDTrlG2VmrFbNOXl 70XlUVYWyLUEO57yagVk5pmtvitz2BXzzwkcaLZhF72BH2AHEsAnSSFtxOWYRhcoACuX jUUxJW7FIaRoUOQmH0P7/hrMVYaErNcvDKpSqG9wmjFPmUPK5D+lDkLmHJE4A1ag4oYb BfUUdDEk8Ivhd1+EYS1o480ATKbC+BEtvs4wBQ/C2emt/GWpKxkYUwXhDv/FdzB8u3p/ QOeXADlT8vy4y8UsMOPgyVHv4PJBPFk5jUQky+QJTqinnuc9AY81/IpSzGAIghEb6ZrU htkA== X-Gm-Message-State: AC+VfDziQjYVPvxlw3sxPX9Iu60QrDN9mcYIqpZknqQPxIBaM2UHPnuD W114on2ZiiJKD6gbkjNqK524Bh20/KiHuthH20w= X-Google-Smtp-Source: ACHHUZ6SJZpAbUpPNnSH3vVq4ZNrnrhW2sKax8oHDpyzGXgVTm0zZfuC4nZtXaOMx6cUVlyoNCBfL8XE9u6x2bWG5+8= X-Received: by 2002:a17:902:da92:b0:1ac:94b3:3ab4 with SMTP id j18-20020a170902da9200b001ac94b33ab4mr2292260plx.27.1684411566790; Thu, 18 May 2023 05:06:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Matthias van de Meent Date: Thu, 18 May 2023 14:05:54 +0200 Message-ID: Subject: Re: RFI: Extending the TOAST Pointer To: Aleksander Alekseev Cc: PostgreSQL Hackers , Nikita Malakhov Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 18 May 2023 at 12:52, Aleksander Alekseev wrote: > > Hi Nikita, > > > this part of the PostgreSQL screams to be revised and improved > > I completely agree. The problem with TOAST pointers is that they are > not extendable at the moment which prevents adding new compression > algorithms (e.g. ZSTD), new features like compression dictionaries > [1], etc. I suggest we add extensibility in order to solve this > problem for the foreseeable future for everyone. > > > where Custom TOAST Pointer is distinguished from Regular one by va_flag field > > which is a part of varlena header > > I don't think that varlena header is the best place to distinguish a > classical TOAST pointer from an extended one. On top of that I don't > see any free bits that would allow adding such a flag to the on-disk > varlena representation [2]. > > The current on-disk TOAST pointer representation is following: > > ``` > typedef struct varatt_external > { > int32 va_rawsize; /* Original data size (includes header) */ > uint32 va_extinfo; /* External saved size (without header) and > * compression method */ > Oid va_valueid; /* Unique ID of value within TOAST table */ > Oid va_toastrelid; /* RelID of TOAST table containing it */ > } varatt_external; > ``` No, that's inaccurate. The complete on-disk representation of a varatt is { uint8 va_header; /* Always 0x80 or 0x01 */ uint8 va_tag; /* Type of datum */ char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Type-dependent data, for toasted values that's currently only a varatt_external */ } varattrib_1b_e; With va_tag being filled with one of the vartag_external values: typedef enum vartag_external { VARTAG_INDIRECT = 1, VARTAG_EXPANDED_RO = 2, VARTAG_EXPANDED_RW = 3, VARTAG_ONDISK = 18 } vartag_external; This enum still has many options to go before it exceeds the maximum of the uint8 va_tag field. Therefore, I don't think we have no disk representations left, nor do I think we'll need to add another option to the ToastCompressionId enum. As an example, we can add another VARTAG option for dictionary-enabled external toast; like what the pluggable toast patch worked on. I think we can salvage some ideas from that patch, even if the main idea got stuck. Kind regards, Matthias van de Meent Neon Inc.