pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Dominique Devienne <ddevienne@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: How to store "blobs" efficiently for small and large sizes, with random access
Date: Wed, 19 Oct 2022 17:30:06 +0200
Message-ID: <20221019153006.zmzz4hljtkbo456c@alvherre.pgsql> (raw)
In-Reply-To: <CAFCRh-8o5XzNYjPLZ1hxmzgVCEBA90fRrWTmEq6Ard82n1GDPA@mail.gmail.com>
On 2022-Oct-19, Dominique Devienne wrote:
> Anybody has an answer to my question regarding how substr() works on
> bytea values? I.e. is it "pushed down" / optimized enough that it
> avoids reading the whole N-byte value, to then pass it to substr(),
> which then returns an M-byte value (where M < N)?
>
> If TOAST stores 2,000 chunks, and those chunks' PKs are numbers,
> simple arithmetic should be able to select only the chunks of
> interest, those incurring only the necessary IO for the selected
> range, no?
That's exactly what I was trying to say. If there's no compression, we
don't read prior chunks. (This is valid for bytea, at least; for
textual types we have to worry about multibyte characters, which are
again a potential source of confusion regarding the exact location you
want to seek.)
This can be seen in detoast_attr_slice() in
src/backend/access/common/detoast.c, though there are way too many^W^W^W
multiple layers of indirection if you start from bytea_substr() in
varlena.c.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
view thread (23+ messages) latest in thread
Message-ID: <20221019153006.zmzz4hljtkbo456c@alvherre.pgsql> Permalink: ../20221019153006.zmzz4hljtkbo456c@alvherre.pgsql/ Also on: postgresql.org/message-id/20221019153006.zmzz4hljtkbo456c@alvherre.pgsql ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients from your mail client; the link fills in the headers below: reply via email Some clients, webmail especially, drop In-Reply-To and References from a link, and the reply then starts a new thread: use the mbox below. To: pgsql-general@postgresql.org Cc: alvherre@alvh.no-ip.org, ddevienne@gmail.com Subject: Re: How to store "blobs" efficiently for small and large sizes, with random access In-Reply-To: <20221019153006.zmzz4hljtkbo456c@alvherre.pgsql> References: <CAFCRh-8o5XzNYjPLZ1hxmzgVCEBA90fRrWTmEq6Ard82n1GDPA@mail.gmail.com> <20221019153006.zmzz4hljtkbo456c@alvherre.pgsql> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox