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)
ALTER TABLE buddygroup OWNER TO postgres;
-- Index: bg_groupid_idx
-- DROP INDEX bg_groupid_idx;
CREATE UNIQUE INDEX bg_groupid_idx
-- Index: bg_userid_idx
-- DROP INDEX bg_userid_idx;
CREATE INDEX bg_userid_idx
pgsql-novice by date
|Next:||From: Sean Davis||Date: 2008-01-19 22:26:11|
|Subject: Re: Indexes and sequences|
|Previous:||From: Andrew Winkler||Date: 2008-01-19 02:45:01|
|Subject: Re: domains, types, constraints|