Re: Foreign Keys - Mailing list pgsql-general

From Neil Conway
Subject Re: Foreign Keys
Date
Msg-id 87ofamzy4w.fsf@mailbox.samurai.com
Whole thread Raw
In response to Foreign Keys  ("Adam T. Gautier" <adam_gautier@yahoo.com>)
List pgsql-general
"Adam T. Gautier" <adam_gautier@yahoo.com> writes:
> CREATE TABLE subjects (
>      id SERIAL PRIMARY KEY,
>      type VARCHAR(3) NOT NULL,
>      status SMALLINT NOT NULL,
>      selectable BOOLEAN DEFAULT true,
>      parent_id BIGINT REFRENCES subjects( id ),
>      subject VARCHAR(255) NOT NULL,
>      description TEXT NOT NULL,
>      childcount BIGINT DEFAULT 0,
>      eurekacount BIGINT DEFAULT 0,
>      path TEXT NOT NULL UNIQUE,
>      updated BIGINT NOT NULL );

Why is parent_id an int8, while id is only an int4? If you change the
types to match (either parent_id -> int4, or id -> bigserial), I'd bet
you'd see a lot better performance.

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

pgsql-general by date:

Previous
From: Joe Conway
Date:
Subject: Re: Foreign Keys
Next
From: Neil Conway
Date:
Subject: Re: Error at startup