Lists: | pgsql-performance |
---|
From: | "Sean P(dot) Thomas" <spt(at)ulanji(dot)com> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Optimizing FK & PK performance... |
Date: | 2003-12-11 16:38:10 |
Message-ID: | 3FD89D72.8080508@ulanji.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
I am working on migrating to postgres and had some questions regarding
optimization that I could not find references in the documentation:
1. Is there any performance difference for declaring a primary or
foreign key a column or table contraint? From the documentation, which
way is faster and/or scales better:
CREATE TABLE distributors (
did integer,
name varchar(40),
PRIMARY KEY(did)
);
CREATE TABLE distributors (
did integer PRIMARY KEY,
name varchar(40)
);
2. Is DEFERRABLE and INITIALLY IMMEDIATE or INITIALLY DEFERRABLE
perferred for performance? We generally have very small transactions
(web app) but we utilize a model of:
view (limit scope for security) -> rules -> before triggers (validate
permissions and to set proper permissions) -> tables.
I know there were some issues with deferring that was fixed but does it
benefit performance or cause any reliability issues?
Thank you for your assistance and let me know if I can offer additional
information.
--spt
From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | "Sean P(dot) Thomas" <spt(at)ulanji(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Optimizing FK & PK performance... |
Date: | 2003-12-16 22:47:59 |
Message-ID: | 87fzfkl6qo.fsf@mailbox.samurai.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
"Sean P. Thomas" <spt(at)ulanji(dot)com> writes:
> 1. Is there any performance difference for declaring a primary or
> foreign key a column or table contraint? From the documentation,
> which way is faster and/or scales better:
>
> CREATE TABLE distributors (
> did integer,
> name varchar(40),
> PRIMARY KEY(did)
> );
>
> CREATE TABLE distributors (
> did integer PRIMARY KEY,
> name varchar(40)
> );
These are equivalent -- the performance should be the same.
-Neil
From: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
---|---|
To: | "Sean P(dot) Thomas" <spt(at)ulanji(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Optimizing FK & PK performance... |
Date: | 2003-12-17 01:17:28 |
Message-ID: | 3FDFAEA8.1090607@familyhealth.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
> 1. Is there any performance difference for declaring a primary or
> foreign key a column or table contraint? From the documentation, which
> way is faster and/or scales better:
>
>
> CREATE TABLE distributors (
> did integer,
> name varchar(40),
> PRIMARY KEY(did)
> );
>
> CREATE TABLE distributors (
> did integer PRIMARY KEY,
> name varchar(40)
> );
No difference - they're parsed to exactly the same thing (the first
version).
> 2. Is DEFERRABLE and INITIALLY IMMEDIATE or INITIALLY DEFERRABLE
> perferred for performance? We generally have very small transactions
> (web app) but we utilize a model of:
No idea on this one :/
Chris