Sharp edge when dropping columns

Поиск
Список
Период
Сортировка
От Quentin de Metz
Тема Sharp edge when dropping columns
Дата
Msg-id 45e27182-8474-4dc5-be7b-adb87041a111@app.fastmail.com
обсуждение исходный текст
Ответы Re: Sharp edge when dropping columns  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Sharp edge when dropping columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
[This is my first message on a PG mailing list, here's hoping I'm not breaching etiquette somehow]

Bonjour,

I'd like to report a sharp edge which caused downtime in my production application: dropping a column which is INCLUDEd in an index drops the index.

In the past, I have included a field in some of my indexes so that related queries can be performed as an index-only scan. This field was later deprecated. When the related column was ultimately dropped, the performance of the initial queries ground to a halt because the underlying index had been dropped.

I found this behavior unexpected. I think preventing the index from being dropped in some circumstances would make this less surprising. The exact circumstances likely need to be hashed out if there is a consensus that this is a (minor) problem.

Please find below a simple reproduction script:

=# CREATE TABLE test (id bigint, label text);
CREATE TABLE

=# CREATE INDEX pkey_with_label ON test USING btree (id) INCLUDE (label);
CREATE INDEX

=# \d test
Table "public.test"
┌────────┬────────┬───────────┬──────────┬─────────┐
│ Column │ Type   │ Collation │ Nullable │ Default │
├────────┼────────┼───────────┼──────────┼─────────┤
│ id     │ bigint │           │          │         │
│ label  │ text   │           │          │         │
└────────┴────────┴───────────┴──────────┴─────────┘
Indexes:
"pkey_with_label" btree (id) INCLUDE (label)

=# ALTER TABLE test DROP COLUMN label;
ALTER TABLE

=# \d test
Table "public.test"
┌────────┬────────┬───────────┬──────────┬─────────┐
│ Column │ Type   │ Collation │ Nullable │ Default │
├────────┼────────┼───────────┼──────────┼─────────┤
│ id     │ bigint │           │          │         │
└────────┴────────┴───────────┴──────────┴─────────┘

Thank you for reading,

Quentin de Metz

В списке pgsql-novice по дате отправления:

Предыдущее
От: blockdump
Дата:
Сообщение: Re: Reset date for Cumulative Statistics System when not in table
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Sharp edge when dropping columns