Re: Tablespaces and primary keys

From: Neil Conway <neilc(at)samurai(dot)com>
To: Wes <wespvp(at)syntegra(dot)com>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tablespaces and primary keys
Date: 2005-01-25 04:34:17
Message-ID: 1106627657.9525.3.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2005-01-24 at 21:03 -0600, Wes wrote:
> Implicit indexes created by a constraint do not appear to honor the default
> tablespace. The index gets created in the "null" tablespace.
>
> I took pg_dumpall output and modified the schema to place everything in
> specific table spaces. When the statement:
>
> ALTER TABLE ONLY addresses
> ADD CONSTRAINT addresses_pkey PRIMARY KEY (address_key);
>
> is executed, this results in an implicitly created index:
>
> NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index
> "addresses_pkey" for table "addresses"
>
> However, it ignores my previous command:
>
> SET default_tablespace = indexes;
>
> and creates the index without a tablespace.

I can't repro this (with current sources):

neilc=# create tablespace foo location '/tmp/foo';
CREATE TABLESPACE
neilc=# set default_tablespace = 'foo';
SET
neilc=# create table xyz (a int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"xyz_pkey" for table "xyz"
CREATE TABLE
Time: 45.838 ms
neilc=# \d xyz
Table "public.xyz"
Column | Type | Modifiers
--------+---------+-----------
a | integer | not null
Indexes:
"xyz_pkey" PRIMARY KEY, btree (a)
Tablespace: "foo"

neilc=# \d xyz_pkey
Index "public.xyz_pkey"
Column | Type
--------+---------
a | integer
primary key, btree, for table "public.xyz"
Tablespace: "foo"

neilc=# alter table xyz drop constraint xyz_pkey;
ALTER TABLE
neilc=# alter table xyz add constraint "xyz_pkey2" primary key (a);
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index
"xyz_pkey2" for table "xyz"
ALTER TABLE
neilc=# \d xyz_pkey2
Index "public.xyz_pkey2"
Column | Type
--------+---------
a | integer
primary key, btree, for table "public.xyz"
Tablespace: "foo"

-Neil

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Benjamin Smith 2005-01-25 04:35:45 Search for restricting foreign keys
Previous Message Jeff Davis 2005-01-25 04:07:36 Re: disable trigger from transaction