Re: pg_upgrade: convert on read is dead end

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade: convert on read is dead end
Date: 2008-10-13 07:04:48
Message-ID: 48F2F310.9090303@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zdenek Kotala wrote:
> PostgreSQL stores all table's external data in one TOAST table and
> stored data does not contains any clue about datatype. When postgreSQL
> reads TOSTEed value then there is not possible detect what type it is
> and perform varlena conversion on composite datatypes or arrays.
>
> It could be converted in detoast_datum function but it means that datum
> have to be retoasted and store back on new pages. The old page MUST keep
> in old format because any page conversion lost information about version
> and different datatypes can be store on one page PosgreSQL.

Hmm. There's two things here:
1. The format of the toast page, and the toast chunk tuples.
2. The format of the toasted tuple, stored within the chunk tuples.

The format of the toast page and the varlena headers of the byteas in
the toast tuples could be converted when the page is read in, as usual.
The format of the toasted tuple within the chunks is indeed trickier.
Retoasting all tuples on the "master" heap page when the page is read in
is probably simplest, as you say. But they don't necessarily need to be
stored on new pages, any toast pages will do, because we keep track of
1. separately.

> By my opinion, this issue completely kill convert on read solution and
> only "read all formats..." solution is right one.

It is quite heavy-weight, I agree, but doesn't "completely kill" the
idea in my opinion.

Besides, the "read all formats" approach wouldn't really avoid it
either. If you passed a toasted datum to a function, when the function
needs to detoast it, detoast_datum still wouldn't know whether the datum
is in old or new format. You'd still need to detoast all values in the
tuple somewhere before they could be passed around.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2008-10-13 07:25:18 Re: [PATCH] Extending pg_class info + more flexible TOAST chunk size
Previous Message Zdenek Kotala 2008-10-13 07:04:37 Re: [PATCH] Extending pg_class info + more flexible TOAST chunk size