From: | Michel Pelletier <pelletier(dot)michel(at)gmail(dot)com> |
---|---|
To: | Sam Patterson <katoriasdev(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Varlena with recursive data structures? |
Date: | 2019-01-17 20:39:09 |
Message-ID: | CACxu=vJZEcY_R3hnea9XNg+019gTvE9=wmkMV5b2_zi6UEz9Nw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Karl,
I'm going down this road myself. In addition to the files Tom Lane pointed
out there is also some helpful documentation here:
https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-INMEMORY
On Wed, Jan 16, 2019 at 2:09 PM Sam Patterson <katoriasdev(at)gmail(dot)com> wrote:
> Hi all,
>
> I've recently started developing an extension for Postgres for which I'll
> need to create a new variable-length base type. The type will require a
> tree-like structure in order to parse sufficiently, which of course
> probably means having some sort of recursive data structure, like a struct
> that has members which are pointers to itself for child nodes. After doing
> some research, specifically looking at how other variable-length data types
> store their data, it seems almost all of them store the data in a binary
> representation, using bit masks and offsets etc in order to store/access
> the data whilst having an in-memory representation that's used to
> manipulate the data.
>
> I presume the purpose for using this approach is because all the data in a
> varlena type has to be contiguous, and the moment you start using pointers
> this is no longer possible. So my question is, given a structure that looks
> something like this,
>
> typedef struct Node
> {
> char *data;
> Node *left;
> Node *right;
> } Node;
>
> am I right in saying that I wouldn't be able to store that representation
> on-disk, but instead I'd have to transform it into some binary
> representation and back again when writing/reading respectively, are there
> any alternatives?
>
> Regards,
>
> Karl
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2019-01-17 21:13:25 | Re: strange slow query performance |
Previous Message | Laurenz Albe | 2019-01-17 20:04:52 | Re: strange slow query performance |