reindexdb
reindexdb — переиндексировать базу данных Postgres Pro
Синтаксис
reindexdb [параметр-подключения...] [параметр...] [ -S | --schema схема ] ... [ -t | --table таблица ] ... [ -i | --index индекс ] ... [имя_бд]
reindexdb [параметр-подключения...] [параметр...] -a | --all
reindexdb [параметр-подключения...] [параметр...] -s | --system [имя_бд]
Описание
Утилита reindexdb предназначена для перестроения индексов в базе данных Postgres Pro.
Утилита reindexdb представляет собой обёртку SQL-команды REINDEX. Переиндексация базы данных с её помощью по сути не отличается от переиндексации при обращении к серверу другими способами.
Параметры
reindexdb принимает следующие аргументы командной строки:
-a--allПереиндексировать все базы данных.
[-d]имя_бд[--dbname=]имя_бдУказывает имя базы данных для переиндексации, когда не используется параметр
-a/--all. Если это указание отсутствует, имя базы определяется переменной окруженияPGDATABASE. Если эта переменная не установлена, именем базы будет имя пользователя, указанное для подключения. В аргументеимя_бдможет задаваться строка подключения. В этом случае параметры в строке подключения переопределяют одноимённые параметры, заданные в командной строке.-e--echoВыводить команды, которые reindexdb генерирует и передаёт серверу.
-iиндекс--index=индексПересоздать только указанный
индекс. Добавив дополнительные ключи-i, можно пересоздать несколько индексов.-q--quietПодавлять вывод сообщений о прогрессе выполнения.
-s--systemПереиндексировать только системные каталоги базы данных.
-Sсхема--schema=схемаПереиндексировать только указанную
схему. Переиндексировать несколько схем можно, добавив несколько ключей-S.-tтаблица--table=таблицаПереиндексировать только указанную
таблицу. Переиндексировать несколько таблиц можно, добавив несколько ключей-t.-v--verboseВывести подробную информацию во время процесса.
-V--versionСообщить версию reindexdb и завершиться.
-?--helpПоказать справку по аргументам командной строки reindexdb и завершиться.
Утилита reindexdb также принимает следующие аргументы командной строки в качестве параметров подключения:
-hсервер--host=серверУказывает имя компьютера, на котором работает сервер. Если значение начинается с косой черты, оно определяет каталог Unix-сокета.
-pпорт--port=портУказывает TCP-порт или расширение файла локального Unix-сокета, через который сервер принимает подключения.
-Uимя_пользователя--username=имя_пользователяИмя пользователя, под которым производится подключение.
-w--no-passwordНе выдавать запрос на ввод пароля. Если сервер требует аутентификацию по паролю и пароль не доступен с помощью других средств, таких как файл
.pgpass, попытка соединения не удастся. Этот параметр может быть полезен в пакетных заданиях и скриптах, где нет пользователя, который вводит пароль.-W--passwordПринудительно запрашивать пароль перед подключением к базе данных.
Это несущественный параметр, так как reindexdb запрашивает пароль автоматически, если сервер проверяет подлинность по паролю. Однако чтобы понять это, reindexdb лишний раз подключается к серверу. Поэтому иногда имеет смысл ввести
-W, чтобы исключить эту ненужную попытку подключения.--maintenance-db=имя_бдУказывает имя базы данных, к которой будет выполняться подключение для определения подлежащих переиндексации баз данных, когда используется ключ
-a/--all. Если это имя не указано, будет выбрана базаpostgres, а если она не существует —template1. В данном аргументе может задаваться строка подключения. В этом случае параметры в строке подключения переопределяют одноимённые параметры, заданные в командной строке. Кроме того, все параметры в строке подключения, за исключением имени базы, будут использоваться и при подключении к другим базам данных.
Переменные окружения
PGDATABASEPGHOSTPGPORTPGUSERПараметры подключения по умолчанию
Эта утилита, как и большинство других утилит Postgres Pro, также использует переменные среды, поддерживаемые libpq (см. Раздел 33.14).
Диагностика
В случае возникновения трудностей, обратитесь к описаниям REINDEX и psql, где обсуждаются потенциальные проблемы и сообщения об ошибках. Учтите, что на целевом компьютере должен работать сервер баз данных. При этом применяются все свойства подключения по умолчанию и переменные окружения, которые использует клиентская библиотека libpq.
Замечания
Утилите reindexdb может потребоваться подключаться к серверу Postgres Pro несколько раз, и при этом она будет каждый раз запрашивать пароль. В таких случаях удобно иметь файл ~/.pgpass. За дополнительными сведениями обратитесь к Разделу 33.15.
Примеры
Переиндексирование базы данных test:
$reindexdb test
Переиндексирование таблицы foo и индекса bar в базе данных abcd:
$reindexdb --table=foo --index=bar abcd
См. также
REINDEXreindexdb
reindexdb — reindex a Postgres Pro database
Synopsis
reindexdb [connection-option...] [option...] [ -S | --schema schema ] ... [ -t | --table table ] ... [ -i | --index index ] ... [dbname]
reindexdb [connection-option...] [option...] -a | --all
reindexdb [connection-option...] [option...] -s | --system [dbname]
Description
reindexdb is a utility for rebuilding indexes in a Postgres Pro database.
reindexdb is a wrapper around the SQL command REINDEX. There is no effective difference between reindexing databases via this utility and via other methods for accessing the server.
Options
reindexdb accepts the following command-line arguments:
-a--allReindex all databases.
[-d]dbname[--dbname=]dbnameSpecifies the name of the database to be reindexed, when
-a/--allis not used. If this is not specified, the database name is read from the environment variablePGDATABASE. If that is not set, the user name specified for the connection is used. Thedbnamecan be a connection string. If so, connection string parameters will override any conflicting command line options.-e--echoEcho the commands that reindexdb generates and sends to the server.
-iindex--index=indexRecreate
indexonly. Multiple indexes can be recreated by writing multiple-iswitches.-q--quietDo not display progress messages.
-s--systemReindex database's system catalogs only.
-Sschema--schema=schemaReindex
schemaonly. Multiple schemas can be reindexed by writing multiple-Sswitches.-ttable--table=tableReindex
tableonly. Multiple tables can be reindexed by writing multiple-tswitches.-v--verbosePrint detailed information during processing.
-V--versionPrint the reindexdb version and exit.
-?--helpShow help about reindexdb command line arguments, and exit.
reindexdb also accepts the following command-line arguments for connection parameters:
-hhost--host=hostSpecifies 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.
-pport--port=portSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.
-Uusername--username=usernameUser name to connect as.
-w--no-passwordNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a
.pgpassfile, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.-W--passwordForce 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
-Wto avoid the extra connection attempt.--maintenance-db=dbnameSpecifies the name of the database to connect to to discover which databases should be reindexed, when
-a/--allis used. If not specified, thepostgresdatabase will be used, or if that does not exist,template1will 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.
Environment
PGDATABASEPGHOSTPGPORTPGUSERDefault connection parameters
This utility, like most other Postgres Pro utilities, also uses the environment variables supported by libpq (see Section 33.14).
Diagnostics
In case of difficulty, see REINDEX and psql for discussions of potential problems and error messages. The database server must be running at the targeted host. Also, any default connection settings and environment variables used by the libpq front-end library will apply.
Notes
reindexdb might need to connect several times to the Postgres Pro server, asking for a password each time. It is convenient to have a ~/.pgpass file in such cases. See Section 33.15 for more information.
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