nataraj: (Бритый небритый)
[personal profile] nataraj
When you are creating table in postgres, you are creating up to two relations in a row.
In case when you create table with fixed-length attributes only, only one relation is created. A heap relation.
If you have at least one variable-length attribute in your table, then both heap and toast relations will be created.

Relations also have options: reloptions. You can set them while creating and altering table. To set options for toast relations you should use toast. prefix before reloption name:
CREATE TABLE reloptions_test (s varchar) WITH (toast.autovacuum_vacuum_cost_delay = 23 );

The only problem is that if you have table with no varlen values, postgres will accept toast reloption, but will not write it anywhere.
#CREATE TABLE reloptions_test (i int) WITH (toast.autovacuum_vacuum_cost_delay = 23 );
CREATE TABLE
# select reltoastrelid from pg_class where oid = 'reloptions_test'::regclass;
 reltoastrelid 
---------------
             0
(1 row)

there is no toast relation and reloption is not saved at all, postgres reports, everything is ok

Same for alter table:
# ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24 );
ALTER TABLE
# select reltoastrelid from pg_class where oid = 'reloptions_test'::regclass;
 reltoastrelid 
---------------
             0
(1 row)

This is not nice behavior, isn't it?

PS please when writing a comment, login with any account you have, or just leave a name and/or e-mail so I will be able to answer that comment ;-)

Date: 2016-06-09 06:45 am (UTC)
From: [identity profile] david turoň (from livejournal.com)
Yes, its awfull. I know other bad behavior... when you want dump database with pg_dump option -Fc, you can't dump specific database options something like ALTER DATABASE test SET client_min_messages TO 'error';.... (-C) not dump this... only way to do this is use pg_dumpall - stop execution when you read \connect $database, create databases from this file and then load from dumps from pg_dump.... you can of course use pg_basebackup ... but if you want only few databases not whole cluster ... output of pg_dumpall:
....
CREATE DATABASE test WITH TEMPLATE = template0 OWNER = postgres;
ALTER DATABASE test SET client_min_messages TO 'error';
....
Edited Date: 2016-06-09 08:02 am (UTC)

Date: 2016-06-09 09:22 am (UTC)
ext_613079: Default userpic (Бритый небритый)
From: [identity profile] shaplov.livejournal.com
Yeah, this seems to be an error.
But for now I will not fix it because as far as I can guess it has no common code with reloptions.

[livejournal.com profile] vitus_wagner, have a look at it. May be you can add something...

Profile

nataraj: (Default)
Swami Dhyan Nataraj

July 2024

S M T W T F S
 123456
789 10111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 13th, 2025 10:10 am
Powered by Dreamwidth Studios
OSZAR »