This article is half-done without your Comment! *** Please share your thoughts via Comment ***
The Index Rebuilding is a very common and routine task for a Database Administrator.
All types of RDBMS system have various types of Reindexing option.
The Index Rebuilding is necessary periodically to remove fragmentation of Indexes.
PostgreSQL provides two ways to perform Reindexing on Database.
Using REINDEX command:
You can execute REINDEX command on Database, Table and Index.
You can connect PostgreSQL using PGAdmin or PSQL tools to execute this command.
Reindex all indexes of Database:
1 |
REINDEX DATABASE Database_Name; |
Reindex on particular Index:
1 |
REINDEX INDEX Index_Name; |
Reindex on particular Table:
1 |
REINDEX TABLE Table_Name; |
Using REINDEXDB.EXE utility:
A REINDEXDB is a one type of utility of PostgreSQL. It is an executable file which we can run without connect to database server.
A REINDEXDB requires command line arguments like database_username, database_name.
We can execute REINDEXDB using command prompt of the Operating System.
Below an example of Windows Command Prompt, the same way you can also execute in Linux.
Reindex all Database of PostgreSQL Server:
1 2 |
C:\Program Files\PostgreSQL\9.5\bin> reindexdb.exe -U user_name -a Password:**** |
Reindex on particular Database:
1 2 |
C:\Program Files\PostgreSQL\9.5\bin> reindexdb.exe -d database -U user_name Password:**** |
Reindex on particular Table:
1 2 |
C:\Program Files\PostgreSQL\9.5\bin> reindexdb.exe -d database_name -U user_name -t table_name Password:**** |