K.4. Дополнительные модули #
K.4.1. Встроенные модули по умолчанию #
Чтобы обеспечить поддержку решений 1C, дистрибутив Postgres Pro содержит следующие встроенные модули, которые включены по умолчанию и не требуют дополнительной настройки:
fasttrun — предоставляет транзакционно-небезопасную функцию для усечения временных таблиц, предотвращающую увеличение размера
pg_class.fulleq — предоставляет дополнительный оператор равенства для совместимости с Microsoft SQL Server.
mchar — предоставляет дополнительные типы данных
MCHARиMVARCHARдля совместимости с Microsoft SQL Server.
K.4.2. dbcopies_decoding #
dbcopies_decoding — модуль 1C для обновления копий баз данных, который включён по умолчанию. Для использования механизма логической репликации этого модуля установите для параметра wal_level значение logical.
За более подробной информацией об этом модуле обратитесь в поддержку 1C.
K.4.3. plantuner #
Модуль plantuner позволяет оптимизировать планы выполнения запросов. Чтобы настроить его для решений 1C, выполните следующее:
Добавьте имя библиотеки в переменную
shared_preload_librariesв файлеpostgresql.conf.shared_preload_libraries = 'plantuner'
Установите для параметра
plantuner.fix_empty_tableзначениеonдля улучшения планирования запросов с недавно созданными пустыми таблицами.plantuner.fix_empty_table = on
K.4.4. online_analyze #
Модуль online_analyze предоставляет набор функций, которые немедленно обновляют статистику для задействованных таблиц после операций INSERT, UPDATE, DELETE, SELECT INTO или COPY.
Примечание
Не рекомендуется использовать этот модуль с современными версиями 1C.
Однако online_analyze можно включить, если фоновые изменения не обеспечивают ожидаемые результаты или оптимизатор часто ошибается в оценке количества строк.
Следующая инструкция полезна, только если вы решите использовать этот модуль.
Чтобы настроить этот модуль, выполните шаги ниже.
Добавьте имя библиотеки в переменную
shared_preload_librariesв файлеpostgresql.conf.shared_preload_libraries = 'online_analyze'
Включите этот модуль.
online_analyze.enable = on
Укажите минимальное число изменений строк, после которого может начаться немедленный анализ.
online_analyze.threshold = 50
Укажите процент от размера таблицы, при котором начнётся немедленный анализ.
online_analyze.scale_factor = 0.1
Выполняйте команду
ANALYZEбезVERBOSE.online_analyze.verbose = off
Включите немедленный анализ для временных таблиц.
online_analyze.table_type = 'temporary'
Укажите минимальный интервал времени между вызовами
ANALYZEдля каждой таблицы, в миллисекундах.online_analyze.min_interval = 10000
K.4.5. auto_dump #
Расширение auto_dump предназначено для сбора данных по длительным и проблемным запросам и последующего воспроизведения этих запросов с целью устранения неполадок.
Чтобы включить и настроить это расширение, выполните следующие действия:
Добавьте
auto_dumpв параметр shared_preload_libraries в файлеpostgresql.conf.shared_preload_libraries = 'auto_dump'
Включите расширение:
auto_dump.enable = on
Перед использованием расширения задайте другие обязательные параметры конфигурации и перезапустите сервер баз данных, чтобы изменения вступили в силу.
K.4.6. Использование pg_hint_plan для 1С #
Модуль pg_hint_plan позволяет управлять планами выполнения запросов с помощью указаний для планировщика. За подробной информацией об установке и поддерживаемых типах указаний pg_hint_plan обратитесь к документации модуля.
Чтобы использовать pg_hint_plan для решений 1C, необходимо установить параметр pg_hint_plan.hints_anywhere в значение on. Это позволит планировщику считывать указания из любой части запроса. Сами указания должны задаваться в комментарии особого вида, который начинается с символов /*+ и заканчивается символами */. Такой комментарий следует добавлять в предложение WHERE в следующем формате:
WHERE ... AND '1' != '/*+ указание */'
Следующий пример демонстрирует запрос с указанием SeqScan:
SELECT
Спр.Ссылка,
Спр.Наименование
FROM
Справочник.Номенклатура КАК Спр
WHERE
Спр.ПометкаУдаления = ЛОЖЬ
AND
'1' != '/*+ SeqScan(t1) */'K.4. Additional Modules #
K.4.1. Built-In Default Modules #
To provide support for 1C solutions, the Postgres Pro distribution includes the following built-in modules that are enabled by default and do not require additional configuration:
fasttrun — provides a transaction-unsafe function to truncate temporary tables without growing the size of
pg_class.fulleq — provides an additional equivalence operator for compatibility with Microsoft SQL Server.
mchar — provides additional
MCHARandMVARCHARdata types for compatibility with Microsoft SQL Server.
K.4.2. dbcopies_decoding #
dbcopies_decoding is a 1C module for updating database copies, which is enabled by default. To use the logical replication mechanism of this module, set the wal_level parameter to logical.
For more information about this module, contact 1C support.
K.4.3. plantuner #
The plantuner module allows optimizing query execution plans. To configure it for 1C solutions, do the following:
Add the library name to the
shared_preload_librariesvariable in thepostgresql.conffile.shared_preload_libraries = 'plantuner'
Set the
plantuner.fix_empty_tableparameter toonto improve planning for recently created empty tables.plantuner.fix_empty_table = on
K.4.4. online_analyze #
The online_analyze module provides a set of features that immediately update statistics after INSERT, UPDATE, DELETE, SELECT INTO, or COPY operations for the affected tables.
Note
It is not recommended to use this module with modern versions of 1C.
However, you can enable online_analyze if background updates do not provide the desired result or if the optimizer frequently fails to estimate the row count.
The instruction below is relevant only if you decide to use the module.
To configure this module, follow the steps below.
Add the library name to the
shared_preload_librariesvariable in thepostgresql.conffile.shared_preload_libraries = 'online_analyze'
Enable this module.
online_analyze.enable = on
Specify the minimum number of row updates before starting online analysis.
online_analyze.threshold = 50
Specify the fraction of the table size to start online analysis.
online_analyze.scale_factor = 0.1
Execute the
ANALYZEcommand withoutVERBOSE.online_analyze.verbose = off
Enable online analysis for temporary tables.
online_analyze.table_type = 'temporary'
Specify the minimum time interval between
ANALYZEcalls per table, in milliseconds.online_analyze.min_interval = 10000
K.4.5. auto_dump #
The auto_dump extension is designed to collect data on long-running and problematic queries and to further reproduce these problems for troubleshooting.
To enable and configure this extension, do the following:
Add
auto_dumpto the shared_preload_libraries parameter in thepostgresql.conffile:shared_preload_libraries = 'auto_dump'
Enable the extension:
auto_dump.enable = on
Before using the extension, set other required configuration parameters and restart the database server for the changes to take effect.
K.4.6. Using pg_hint_plan in 1C #
The pg_hint_plan module allows managing query execution plans by providing hints to the planner. For information about installation and supported hints of pg_hint_plan, refer to its documentation.
To use pg_hint_plan in 1C solutions, it is required to set the pg_hint_plan.hints_anywhere parameter to on to read hints from anywhere in a query. Hints should be specified in the special comment that begins with /*+ and ends with */. This comment should be added to the WHERE clause using the following syntax:
WHERE ... AND '1' != '/*+ your_hint */'
The following example shows a sample query with the SeqScan hint:
SELECT * FROM t1 WHERE t1.id = 1 AND '1' != '/*+ SeqScan(t1) */';