databasepostgresqlindexingb-treeb-tree-index

How to apply the index line "my_table_<custom_name>" btree (<comma, separated, fields>) to a table?


I am managing a postgres db created by third parts.

One of the tables is described as

\d my_table;
Table "my_table"

...

Indexes:
    "my_table_pkey" PRIMARY KEY, btree (dt, ida, idm, idd, idt, idr)
    "my_table_fa" btree (dt, idd, idt, idfa, fnc)
    "my_table_typ_fnc" btree (dtr, idd, idt, typl, fnc, idb)

I understand the meaning of the first line of Indexes, and I know that in order to make it "appear in the table description", the code to run in CREATE TABLE is

...
PRIMARY KEY(dt, ida, idm, idd, idt, idr)
...

Bu what is the meaning of the other two lines, and which command should be run in CREATE TABLE (or ALTER TABLE) in order to apply them to the table / "to make them appear in the table description" ?


Solution

  • The two last lines indicate indexes, which were created after the table was created, with the following commands:

    CREATE INDEX my_table_fa
    ON my_table(dt, idd, idt, idfa, fnc);
    
    CREATE INDEX my_table_typ_fnc 
    ON my_table(dtr, idd, idt, typl, fnc, idb);
    

    So they are not part of the CREATE TABLE command.