{
    "mode": "man",
    "parameter": "reindexdb",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/reindexdb/1/json",
    "generated": "2026-10-24T06:32:00Z",
    "synopsis": "reindexdb [connection-option...] [option...] [ -S | --schema schema ]...\n[ -t | --table table ]...  [ -i | --index index ]...  [dbname]\nreindexdb [connection-option...] [option...] -a | --all\nreindexdb [connection-option...] [option...] -s | --system  [dbname]",
    "sections": {
        "NAME": {
            "content": "reindexdb - reindex a PostgreSQL database\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "reindexdb [connection-option...] [option...] [ -S | --schema schema ]...\n[ -t | --table table ]...  [ -i | --index index ]...  [dbname]\n\nreindexdb [connection-option...] [option...] -a | --all\n\nreindexdb [connection-option...] [option...] -s | --system  [dbname]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "reindexdb is a utility for rebuilding indexes in a PostgreSQL database.\n\nreindexdb is a wrapper around the SQL command REINDEX. There is no effective difference\nbetween reindexing databases via this utility and via other methods for accessing the server.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "reindexdb accepts the following command-line arguments:\n",
            "subsections": [
                {
                    "name": "-a",
                    "content": "",
                    "flag": "-a"
                },
                {
                    "name": "--all",
                    "content": "Reindex all databases.\n",
                    "long": "--all"
                },
                {
                    "name": "--concurrently",
                    "content": "Use the CONCURRENTLY option. See REINDEX(7), where all the caveats of this option are\nexplained in detail.\n\n[-d] dbname\n[--dbname=]dbname\nSpecifies the name of the database to be reindexed, when -a/--all is not used. If this is\nnot specified, the database name is read from the environment variable PGDATABASE. If\nthat is not set, the user name specified for the connection is used. The dbname can be a\nconnection string. If so, connection string parameters will override any conflicting\ncommand line options.\n",
                    "long": "--concurrently"
                },
                {
                    "name": "-e",
                    "content": "",
                    "flag": "-e"
                },
                {
                    "name": "--echo",
                    "content": "Echo the commands that reindexdb generates and sends to the server.\n",
                    "long": "--echo"
                },
                {
                    "name": "-i _",
                    "content": "--index=index\nRecreate index only. Multiple indexes can be recreated by writing multiple -i switches.\n",
                    "flag": "-i"
                },
                {
                    "name": "-j _",
                    "content": "--jobs=njobs\nExecute the reindex commands in parallel by running njobs commands simultaneously. This\noption may reduce the processing time but it also increases the load on the database\nserver.\n\nreindexdb will open njobs connections to the database, so make sure your maxconnections\nsetting is high enough to accommodate all connections.\n\nNote that this option is incompatible with the --index and --system options.\n",
                    "flag": "-j"
                },
                {
                    "name": "-q",
                    "content": "",
                    "flag": "-q"
                },
                {
                    "name": "--quiet",
                    "content": "Do not display progress messages.\n",
                    "long": "--quiet"
                },
                {
                    "name": "-s",
                    "content": "",
                    "flag": "-s"
                },
                {
                    "name": "--system",
                    "content": "Reindex database's system catalogs only.\n",
                    "long": "--system"
                },
                {
                    "name": "-S _",
                    "content": "--schema=schema\nReindex schema only. Multiple schemas can be reindexed by writing multiple -S switches.\n",
                    "flag": "-S"
                },
                {
                    "name": "-t _",
                    "content": "--table=table\nReindex table only. Multiple tables can be reindexed by writing multiple -t switches.\n\n--tablespace=tablespace\nSpecifies the tablespace where indexes are rebuilt. (This name is processed as a\ndouble-quoted identifier.)\n",
                    "flag": "-t"
                },
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "--verbose",
                    "content": "Print detailed information during processing.\n",
                    "long": "--verbose"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                },
                {
                    "name": "--version",
                    "content": "Print the reindexdb version and exit.\n\n-?",
                    "long": "--version"
                },
                {
                    "name": "--help",
                    "content": "Show help about reindexdb command line arguments, and exit.\n\nreindexdb also accepts the following command-line arguments for connection parameters:\n",
                    "long": "--help"
                },
                {
                    "name": "-h _",
                    "content": "--host=host\nSpecifies the host name of the machine on which the server is running. If the value\nbegins with a slash, it is used as the directory for the Unix domain socket.\n",
                    "flag": "-h"
                },
                {
                    "name": "-p _",
                    "content": "--port=port\nSpecifies the TCP port or local Unix domain socket file extension on which the server is\nlistening for connections.\n",
                    "flag": "-p"
                },
                {
                    "name": "-U _",
                    "content": "--username=username\nUser name to connect as.\n",
                    "flag": "-U"
                },
                {
                    "name": "-w",
                    "content": "",
                    "flag": "-w"
                },
                {
                    "name": "--no-password",
                    "content": "Never issue a password prompt. If the server requires password authentication and a\npassword is not available by other means such as a .pgpass file, the connection attempt\nwill fail. This option can be useful in batch jobs and scripts where no user is present\nto enter a password.\n",
                    "long": "--no-password"
                },
                {
                    "name": "-W",
                    "content": "",
                    "flag": "-W"
                },
                {
                    "name": "--password",
                    "content": "Force reindexdb to prompt for a password before connecting to a database.\n\nThis option is never essential, since reindexdb will automatically prompt for a password\nif the server demands password authentication. However, reindexdb will waste a connection\nattempt finding out that the server wants a password. In some cases it is worth typing -W\nto avoid the extra connection attempt.\n\n--maintenance-db=dbname\nWhen the -a/--all is used, connect to this database to gather the list of databases to\nreindex. If not specified, the postgres database will be used, or if that does not exist,\ntemplate1 will be used. This can be a connection string. If so, connection string\nparameters will override any conflicting command line options. Also, connection string\nparameters other than the database name itself will be re-used when connecting to other\ndatabases.\n",
                    "long": "--password"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "PGDATABASE\nPGHOST\nPGPORT\nPGUSER\nDefault connection parameters\n\nPGCOLOR\nSpecifies whether to use color in diagnostic messages. Possible values are always, auto\nand never.\n\nThis utility, like most other PostgreSQL utilities, also uses the environment variables\nsupported by libpq (see Section 34.15).\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "In case of difficulty, see REINDEX(7) and psql(1) for discussions of potential problems and\nerror messages. The database server must be running at the targeted host. Also, any default\nconnection settings and environment variables used by the libpq front-end library will apply.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "reindexdb might need to connect several times to the PostgreSQL server, asking for a password\neach time. It is convenient to have a ~/.pgpass file in such cases. See Section 34.16 for\nmore information.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To reindex the database test:\n\n$ reindexdb test\n\nTo reindex the table foo and the index bar in a database named abcd:\n\n$ reindexdb --table=foo --index=bar abcd\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "REINDEX(7)\n\nPostgreSQL 16.14                                2026                                    REINDEXDB(1)",
            "subsections": []
        }
    },
    "summary": "reindexdb - reindex a PostgreSQL database",
    "flags": [
        {
            "flag": "-a",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--all",
            "arg": null,
            "description": "Reindex all databases."
        },
        {
            "flag": "",
            "long": "--concurrently",
            "arg": null,
            "description": "Use the CONCURRENTLY option. See REINDEX(7), where all the caveats of this option are explained in detail. [-d] dbname [--dbname=]dbname Specifies the name of the database to be reindexed, when -a/--all is not used. If this is not specified, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is used. The dbname can be a connection string. If so, connection string parameters will override any conflicting command line options."
        },
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--echo",
            "arg": null,
            "description": "Echo the commands that reindexdb generates and sends to the server."
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": "--index=index Recreate index only. Multiple indexes can be recreated by writing multiple -i switches."
        },
        {
            "flag": "-j",
            "long": null,
            "arg": null,
            "description": "--jobs=njobs Execute the reindex commands in parallel by running njobs commands simultaneously. This option may reduce the processing time but it also increases the load on the database server. reindexdb will open njobs connections to the database, so make sure your maxconnections setting is high enough to accommodate all connections. Note that this option is incompatible with the --index and --system options."
        },
        {
            "flag": "-q",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--quiet",
            "arg": null,
            "description": "Do not display progress messages."
        },
        {
            "flag": "-s",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--system",
            "arg": null,
            "description": "Reindex database's system catalogs only."
        },
        {
            "flag": "-S",
            "long": null,
            "arg": null,
            "description": "--schema=schema Reindex schema only. Multiple schemas can be reindexed by writing multiple -S switches."
        },
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "--table=table Reindex table only. Multiple tables can be reindexed by writing multiple -t switches. --tablespace=tablespace Specifies the tablespace where indexes are rebuilt. (This name is processed as a double-quoted identifier.)"
        },
        {
            "flag": "-v",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--verbose",
            "arg": null,
            "description": "Print detailed information during processing."
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Print the reindexdb version and exit. -?"
        },
        {
            "flag": "",
            "long": "--help",
            "arg": null,
            "description": "Show help about reindexdb command line arguments, and exit. reindexdb also accepts the following command-line arguments for connection parameters:"
        },
        {
            "flag": "-h",
            "long": null,
            "arg": null,
            "description": "--host=host Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket."
        },
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "--port=port Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections."
        },
        {
            "flag": "-U",
            "long": null,
            "arg": null,
            "description": "--username=username User name to connect as."
        },
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--no-password",
            "arg": null,
            "description": "Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."
        },
        {
            "flag": "-W",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": "--password",
            "arg": null,
            "description": "Force reindexdb to prompt for a password before connecting to a database. This option is never essential, since reindexdb will automatically prompt for a password if the server demands password authentication. However, reindexdb will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt. --maintenance-db=dbname When the -a/--all is used, connect to this database to gather the list of databases to reindex. If not specified, the postgres database will be used, or if that does not exist, template1 will be used. This can be a connection string. If so, connection string parameters will override any conflicting command line options. Also, connection string parameters other than the database name itself will be re-used when connecting to other databases."
        }
    ],
    "examples": [
        "To reindex the database test:",
        "$ reindexdb test",
        "To reindex the table foo and the index bar in a database named abcd:",
        "$ reindexdb --table=foo --index=bar abcd"
    ],
    "see_also": [
        {
            "name": "REINDEX",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/REINDEX/7/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Rebuild indexes in a PostgreSQL database.",
        "examples": [
            {
                "description": "Reindex a specific database",
                "command": "reindexdb {{database_name}}"
            },
            {
                "description": "Reindex a specific database using connection options",
                "command": "reindexdb {{database_name}} {{-h|--host}} {{hostname}} {{-p|--port}} {{port}} {{-U|--username}} {{username}}"
            },
            {
                "description": "Reindex all databases",
                "command": "reindexdb {{-a|--all}}"
            },
            {
                "description": "Reindex a specific table in a database",
                "command": "reindexdb {{database_name}} {{-t|--table}} {{table_name}}"
            },
            {
                "description": "Reindex a specific index in a database",
                "command": "reindexdb {{database_name}} {{-i|--index}} {{index_name}}"
            },
            {
                "description": "Reindex a specific schema in a database",
                "command": "reindexdb {{database_name}} {{-S|--schema}} {{schema_name}}"
            },
            {
                "description": "Reindex with verbose output",
                "command": "reindexdb {{database_name}} {{-v|--verbose}}"
            },
            {
                "description": "Reindex a database using multiple parallel jobs",
                "command": "reindexdb {{database_name}} {{-j|--jobs}} {{number_of_jobs}}"
            }
        ]
    }
}