19

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.

2
  • @McNets thank you for help with the question details, no it is index without any features.
    – user144614
    Dec 3, 2018 at 11:50
  • @McNets: that link is irrelevant for Postgres as it is about SQL Server and Postgres does not have clustered indexes to begin with. (plus it's about dropping an index, not about renaming it)
    – user1822
    Dec 3, 2018 at 12:05

1 Answer 1

18

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.