From: | Jeff Willden <jeff(at)pavanell(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Indexes and sequences |
Date: | 2008-01-19 22:04:34 |
Message-ID: | 51ED13DB-7619-4117-BB85-EE61AFCCAA2F@pavanell.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I'm cleaning up a database that someone else made and have a couple
questions. When I look at a table in pgAdmin it shows the DDL below.
Do I need an index on the groupid_seq sequence? Doesn't the sequence
already include one? Also, even if I need it, it doesn't need to be a
unique index because the sequence already ensures uniqueness, right?
On top of that there's a primary key constraint that also ensures
uniqueness. Isn't there a bunch of redundant stuff here?
CREATE TABLE buddygroup
(
groupid integer NOT NULL DEFAULT nextval('groupid_seq'::text),
userid integer NOT NULL,
title character varying(255) NOT NULL,
CONSTRAINT buddygroup_pkey PRIMARY KEY (groupid)
)
WITH OIDS;
ALTER TABLE buddygroup OWNER TO postgres;
-- Index: bg_groupid_idx
-- DROP INDEX bg_groupid_idx;
CREATE UNIQUE INDEX bg_groupid_idx
ON buddygroup
USING btree
(groupid);
-- Index: bg_userid_idx
-- DROP INDEX bg_userid_idx;
CREATE INDEX bg_userid_idx
ON buddygroup
USING btree
(userid);
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Davis | 2008-01-19 22:26:11 | Re: Indexes and sequences |
Previous Message | Andrew Winkler | 2008-01-19 02:45:01 | Re: domains, types, constraints |