Indexes and sequences - Mailing list pgsql-novice

From Jeff Willden
Subject Indexes and sequences
Date
Msg-id 51ED13DB-7619-4117-BB85-EE61AFCCAA2F@pavanell.com
Whole thread Raw
Responses Re: Indexes and sequences  ("Sean Davis" <sdavis2@mail.nih.gov>)
List 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);

pgsql-novice by date:

Previous
From: Andrew Winkler
Date:
Subject: Re: domains, types, constraints
Next
From: "Sean Davis"
Date:
Subject: Re: Indexes and sequences