LinuxCommandLibrary

reindexdb

Rebuild PostgreSQL database indexes

TLDR

Reindex database

$ reindexdb [database_name]
copy
Reindex specific table
$ reindexdb -t [table_name] [database_name]
copy
Reindex specific index
$ reindexdb -i [index_name] [database_name]
copy
Reindex all databases
$ reindexdb -a
copy
Reindex system catalogs
$ reindexdb -s [database_name]
copy
Connect as user
$ reindexdb -U [username] [database_name]
copy
Concurrently reindex
$ reindexdb --concurrently [database_name]
copy

SYNOPSIS

reindexdb [-t table] [-i index] [-a] [-s] [options] [database]

DESCRIPTION

reindexdb rebuilds PostgreSQL indexes. It's a wrapper around SQL REINDEX.
Full database reindex rebuilds all indexes. Fixes corruption and reduces bloat.
Table-specific reindex targets problem areas. Faster than full database reindex.
Concurrent mode allows operations during reindex. Indexes remain usable but reindex is slower.
Parallel jobs speed up multi-table reindex. Each table indexed separately.

PARAMETERS

-t, --table NAME

Reindex specific table.
-i, --index NAME
Reindex specific index.
-a, --all
All databases.
-s, --system
System catalogs only.
--concurrently
Concurrent reindex.
-U, --username USER
Connect as user.
-h, --host HOST
Database server.
-p, --port PORT
Server port.
-j, --jobs N
Parallel jobs.

CAVEATS

Locks tables during non-concurrent reindex. Large indexes take time. Disk space needed.

HISTORY

reindexdb is part of PostgreSQL, providing command-line access to the REINDEX SQL command. It simplifies database maintenance operations.

SEE ALSO

vacuumdb(1), psql(1), pg_dump(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community