Я создал таблицу, которая используется для хранения информации, относящейся к ресурсам различного вида, описание таблицы печатает 250 индексов для каждого внешнего ключа, это нормально?
Таблица содержит только 50 строк.
CREATE TABLE IF NOT EXISTS resource
(
id serial PRIMARY KEY,
kind resource_kind NOT NULL,
author_id int REFERENCES user(id) ON DELETE SET NULL,
---uri text NOT NULL,
creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modification_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
message_id int references message,
track_id int references track,
location_id int references track,
fileupload_id int references upload
check (
(
(message_id is not null)::integer +
(track_id is not null)::integer +
(location_id is not null)::integer +
(fileupload_id is not null)::integer
) = 1
)
);
create unique index on resource (message_id) where message_id is not null;
create unique index on resource (track_id) where track_id is not null;
create unique index on resource (location_id) where location_id is not null;
create unique index on resource (fileupload_id) where fileupload_id is not null;
И это вывод "\ d resource"
Colonna | Tipo | Ordinamento | | Default
-------------------+-----------------------------+-------------+-----------------+------------------------------------------------
id | integer | | not null | nextval('resource_id_seq'::regclass)
kind | resource_kind | | not null |
author_id | integer | | |
creation_time | timestamp without time zone | | not null | CURRENT_TIMESTAMP
modification_time | timestamp without time zone | | not null | CURRENT_TIMESTAMP
message_id | integer | | |
track_id | integer | | |
location_id | integer | | |
fileupload_id | integer | | |
Indici:
"resource_pkey" PRIMARY KEY, btree (id)
"resource_fileupload_id_idx" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx1" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx10" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx100" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx101" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx102" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx103" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx104" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx105" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx106" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
"resource_fileupload_id_idx107" UNIQUE, btree (fileupload_id) WHERE fileupload_id IS NOT NULL
...
И затем выходные данные идут с сотнямииндексы для каждого внешнего ключа.