Query and Index Statistics Collector
The query and index statistics collector is used to collect statistics during database running. The statistics include the times of inserting and updating a table and index, the number of disk blocks and tuples, and the time required for the last cleanup and analysis on each table. The statistics can be viewed by querying system views pg_stats and pg_statistic. The parameters below are used to set the statistics collection feature in the server scope.
track_activities
Parameter description: Collects statistics about the commands that are being executed in each session. For a stored procedure, if this parameter is enabled, you can view the PERFORM statement, stored procedure calling statement, SQL statement, and OPEN CURSOR statement that are being executed in the stored procedure in the pg_stat_activity view.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: Boolean
- on indicates that the statistics collection function is enabled.
- off indicates that the statistics collection function is disabled.
Default value: on
If this parameter is set to off, the memory recycling capability of the storage engine is affected, causing space expansion.
track_counts
Parameter description: Collects statistics about database activities.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: Boolean
- on indicates that the statistics collection function is enabled.
- off indicates that the statistics collection function is disabled.
When the database to be cleaned up is selected from the AutoVacuum automatic cleanup process, the database statistics are required. In this case, the default value is set to on.
Default value: on
If this parameter is set to off, the memory recycling capability of the storage engine is affected, causing space expansion.
track_procedure_sql
Parameter description: Specifies whether the SQL statements that are being executed in the stored procedure are printed in the query column in the pg_stat_activity system catalog.
Parameter type: Boolean
Unit: none
Value range: on or off
- on: indicates that when a stored procedure is invoked, the statements that are being executed by the stored procedure are printed in the query column of pg_stat_activity.
- off: indicates that when a stored procedure is invoked, only statements for invoking the stored procedure are printed in the query column of pg_stat_activity.
Default value: on
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: none
track_io_timing
Parameter description: Collects statistics about I/O timing in the database. The I/O timing statistics can be queried by using the pg_stat_database parameter.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: Boolean
- If this parameter is set to on, the collection function is enabled. In this case, the collector repeatedly queries the OS at the current time. As a result, large number of costs may occur on some platforms. Therefore, the default value is set to off.
- off indicates that the statistics collection function is disabled.
Default value: off
track_functions
Parameter description: Collects statistics of the number and duration of function invocations.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
When the SQL functions are set to inline functions queried by the invoking, these SQL functions cannot be traced no matter these functions are set or not.
Value range: enumerated values
- pl indicates that only procedural language functions are traced.
- none indicates that the function tracing function is disabled.
Default value: none
track_activity_query_size
Parameter description: Specifies byte counts of the current running commands used to trace each active session. If the actual number of bytes in a command is greater than the value of this parameter, the command is truncated.
Parameter type: integer.
Unit: byte
Value range: 100 to 102400
Default value: 1024
Setting method: This is a POSTMASTER parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Set this parameter based on the actual service scenario.
update_process_title
Parameter description: Collects statistics updated with a thread name each time the server receives a new SQL statement.
The thread name can be viewed on Windows task manager by running the ps command.
This is an INTERNAL parameter. Set it based on instructions provided in Table 1.
Value range: Boolean
- on indicates that the statistics collection function is enabled.
- off indicates that the statistics collection function is disabled.
Default value: off
stats_temp_directory
Parameter description: Specifies the directory for storing temporary statistics. Only the sysadmin user can access this parameter.
This is a SIGHUP parameter. Set it based on instructions provided in Table 1.
If a RAM-based file system directory is used, the actual I/O cost can be lowered and the performance can be improved.
Value range: a string
Default value: pg_stat_tmp
track_thread_wait_status_interval
Parameter description: Specifies the interval of collecting the thread status information.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: an integer ranging from 0 to 1440. The unit is min.
Default value: 30min
enable_save_datachanged_timestamp
Parameter description: Specifies whether to record the time when INSERT, UPDATE, DELETE, or EXCHANGE/TRUNCATE/DROP PARTITION is performed on table data.
This is a USERSET parameter. Set it based on instructions provided in Table 1.
Value range: Boolean
- on indicates that the time when an operation is performed on table data will be recorded.
- off indicates that the time when an operation is performed on table data will not be recorded.
Default value: on
plan_collect_thresh
Parameter description: Collects statistics about the plans that are being executed in each session.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: an integer ranging from –1 to 2147483647
- –1: Plans that are being executed are not collected.
- 0: Plans that are being executed are collected before plan execution.
- A value greater than 0 indicates that when the total number of tuples incrementally returned by all operators in a plan is greater than or equal to the value of this parameter, plans that are being executed are collected once.
Default value: 0
track_sql_count
Parameter description: Collects statistics on the statements (SELECT, INSERT, UPDATE, MERGE INTO, and DELETE) that are being executed in a session.
This is a SUSET parameter. Set it based on instructions provided in Table 1.
Value range: Boolean
- on indicates that the statistics collection function is enabled.
- off indicates that the statistics collection function is disabled.
Default value: on
If this parameter is disabled, the query result is 0.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot