From: | Wes <wespvp(at)syntegra(dot)com> |
---|---|
To: | Postgresql-General <pgsql-general(at)postgresql(dot)org> |
Subject: | How are foreign key constraints built? |
Date: | 2005-01-23 18:41:58 |
Message-ID: | BE194C16.2166%wespvp@syntegra.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
How are foreign key constraints built? In loading my database into
PostgreSQL 8.0, on the command:
ALTER TABLE ONLY TABLEA
ADD CONSTRAINT "$1" FOREIGN KEY (mkey) REFERENCES tableb(mkey) ON DELETE
CASCADE;
I ended up with the following in pg_tmp as it is adding the constraint:
-rw------- 1 postgres admin 1073741824 23 Jan 06:09 pgsql_tmp2559.25
-rw------- 1 postgres admin 1073741824 23 Jan 06:24 pgsql_tmp2559.26
-rw------- 1 postgres admin 1073741824 23 Jan 06:39 pgsql_tmp2559.27
-rw------- 1 postgres admin 636526592 23 Jan 06:48 pgsql_tmp2559.28
-rw------- 1 postgres admin 1073741824 23 Jan 11:51 pgsql_tmp2559.29
-rw------- 1 postgres admin 1073741824 23 Jan 11:34 pgsql_tmp2559.30
-rw------- 1 postgres admin 1073741824 23 Jan 11:36 pgsql_tmp2559.31
-rw------- 1 postgres admin 1073741824 23 Jan 11:37 pgsql_tmp2559.32
-rw------- 1 postgres admin 1073741824 23 Jan 11:38 pgsql_tmp2559.33
-rw------- 1 postgres admin 1073741824 23 Jan 11:39 pgsql_tmp2559.34
-rw------- 1 postgres admin 1073741824 23 Jan 11:41 pgsql_tmp2559.35
-rw------- 1 postgres admin 1073741824 23 Jan 11:42 pgsql_tmp2559.36
-rw------- 1 postgres admin 1073741824 23 Jan 11:43 pgsql_tmp2559.37
-rw------- 1 postgres admin 1073741824 23 Jan 11:45 pgsql_tmp2559.38
-rw------- 1 postgres admin 1073741824 23 Jan 11:46 pgsql_tmp2559.39
-rw------- 1 postgres admin 1073741824 23 Jan 11:47 pgsql_tmp2559.40
-rw------- 1 postgres admin 1073741824 23 Jan 11:49 pgsql_tmp2559.41
-rw------- 1 postgres admin 1073741824 23 Jan 11:50 pgsql_tmp2559.42
-rw------- 1 postgres admin 603136000 23 Jan 11:51 pgsql_tmp2559.43
I believe files 25-28 are about the size of one of the indexes, but 29-43 is
about 35% larger than the tmp files when building the other index (the other
index is about 10GB).
There's no problem here, I'd just like to understand what it is doing. I
expected adding the foreign key constraint would just use the existing
indexes to verify the database is currently consistent. Is this just
working space to more efficiently build the initial constraint, or does it
actually write this to the database?
Wes
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-01-23 19:01:41 | Re: How are foreign key constraints built? |
Previous Message | Jeffrey Melloy | 2005-01-23 18:09:26 | Re: SCHEMA compatibility with Oracle/DB2/Firebird |