Indexes and sequences
| От | Jeff Willden |
|---|---|
| Тема | Indexes and sequences |
| Дата | |
| Msg-id | 51ED13DB-7619-4117-BB85-EE61AFCCAA2F@pavanell.com обсуждение исходный текст |
| Ответы |
Re: Indexes and sequences
|
| Список | 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 по дате отправления: