HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

postgresql rename index

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlindexrename

Problem

I want to understand how safe is the rename command:

ALTER INDEX old_name RENAME TO new_name;


The index was created by command(for the foreign key column):

CREATE INDEX old_name ON table_t1 (user_id);


Does it mean simple update in the postgres system tables or do much more operations. I try to find it in the docs but unsuccess.

Solution

Quote from the manual


The RENAME form changes the name of the index (...) There is no effect on the stored data

(emphasis mine)

So yes, this is a simple update to the system catalog.

The statement sill needs an exclusive lock on the table if I'm not mistaken, but the lock will only be held for a very short period.

Context

StackExchange Database Administrators Q#223992, answer score: 18

Revisions (0)

No revisions yet.