Thread: TOAST-slicing: substring access methods for TOASTed values.

TOAST-slicing: substring access methods for TOASTed values.

From
John Gray
Date:
Hi all,

I attach a version of my toast-slicing patch, against current CVS
(current as of a few hours ago.)

This patch:

1. Adds PG_GETARG_xxx_P_SLICE() macros and associated support routines.

2. Adds routines in src/backend/access/tuptoaster.c for fetching only
necessary chunks of a toasted value. (Modelled on latest changes to
assume chunks are returned in order).

3. Amends text_substr and bytea_substr to use new methods. It now
handles multibyte cases -and should still lead to a performance
improvement in the multibyte case where the substring is near the
beginning of the string.

4. Added new command: ALTER TABLE tabname ALTER COLUMN colname SET
STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN} to parser and documented in
alter-table.sgml. (NB I used ColId as the item type for the storage
mode string, rather than a new production - I hope this makes sense!).
All this does is sets attstorage for the specified column.

4. AlterTableAlterColumnStatistics is now AlterTableAlterColumnFlags and
handles both statistics and storage (it uses the subtype code to
distinguish). The previous version of my patch also re-arranged other
code in backend/commands/command.c but I have dropped that from this
patch.(I plan to return to it separately).

5. Documented new macros (and also the PG_GETARG_xxx_P_COPY macros) in
xfunc.sgml. ref/alter_table.sgml also contains documentation for ALTER
COLUMN SET STORAGE.

Comments or suggestions welcome.

John






Attachment

Re: TOAST-slicing: substring access methods for TOASTed values.

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


John Gray wrote:
> Hi all,
>
> I attach a version of my toast-slicing patch, against current CVS
> (current as of a few hours ago.)
>
> This patch:
>
> 1. Adds PG_GETARG_xxx_P_SLICE() macros and associated support routines.
>
> 2. Adds routines in src/backend/access/tuptoaster.c for fetching only
> necessary chunks of a toasted value. (Modelled on latest changes to
> assume chunks are returned in order).
>
> 3. Amends text_substr and bytea_substr to use new methods. It now
> handles multibyte cases -and should still lead to a performance
> improvement in the multibyte case where the substring is near the
> beginning of the string.
>
> 4. Added new command: ALTER TABLE tabname ALTER COLUMN colname SET
> STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN} to parser and documented in
> alter-table.sgml. (NB I used ColId as the item type for the storage
> mode string, rather than a new production - I hope this makes sense!).
> All this does is sets attstorage for the specified column.
>
> 4. AlterTableAlterColumnStatistics is now AlterTableAlterColumnFlags and
> handles both statistics and storage (it uses the subtype code to
> distinguish). The previous version of my patch also re-arranged other
> code in backend/commands/command.c but I have dropped that from this
> patch.(I plan to return to it separately).
>
> 5. Documented new macros (and also the PG_GETARG_xxx_P_COPY macros) in
> xfunc.sgml. ref/alter_table.sgml also contains documentation for ALTER
> COLUMN SET STORAGE.
>
> Comments or suggestions welcome.
>
> John
>
>
>
>
>

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: TOAST-slicing: substring access methods for TOASTed values.

From
Bruce Momjian
Date:
Patch applied.  I discussed this with Jan and Tom and both liked the
idea.  Thanks.

---------------------------------------------------------------------------

John Gray wrote:
> Hi all,
>
> I attach a version of my toast-slicing patch, against current CVS
> (current as of a few hours ago.)
>
> This patch:
>
> 1. Adds PG_GETARG_xxx_P_SLICE() macros and associated support routines.
>
> 2. Adds routines in src/backend/access/tuptoaster.c for fetching only
> necessary chunks of a toasted value. (Modelled on latest changes to
> assume chunks are returned in order).
>
> 3. Amends text_substr and bytea_substr to use new methods. It now
> handles multibyte cases -and should still lead to a performance
> improvement in the multibyte case where the substring is near the
> beginning of the string.
>
> 4. Added new command: ALTER TABLE tabname ALTER COLUMN colname SET
> STORAGE {PLAIN | EXTERNAL | EXTENDED | MAIN} to parser and documented in
> alter-table.sgml. (NB I used ColId as the item type for the storage
> mode string, rather than a new production - I hope this makes sense!).
> All this does is sets attstorage for the specified column.
>
> 4. AlterTableAlterColumnStatistics is now AlterTableAlterColumnFlags and
> handles both statistics and storage (it uses the subtype code to
> distinguish). The previous version of my patch also re-arranged other
> code in backend/commands/command.c but I have dropped that from this
> patch.(I plan to return to it separately).
>
> 5. Documented new macros (and also the PG_GETARG_xxx_P_COPY macros) in
> xfunc.sgml. ref/alter_table.sgml also contains documentation for ALTER
> COLUMN SET STORAGE.
>
> Comments or suggestions welcome.
>
> John
>
>
>
>
>

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026