Solve Oracle SQL statement performance problems - collect and maintain statistical data

The so-called statistical data, as mentioned in the previous article, are the basis for the database optimizer to generate the optimal execution plan of the SQL statement. Based on these statistical data, the optimizer calculates the cost (Cost) of all or candidate execution plans through built-in models, algorithms, etc., and compares the cost of each execution plan to select the execution plan with the lowest cost, which is obtained The execution plan that the SQL statement intends to adopt finally lays a stable and reliable foundation for saving system resource consumption. The optimizer is one of the most important and core components in the database system. Here, the statistical data we are talking about to be collected and maintained mainly refers to the object-related statistical data mentioned in the preceding article.

1. Automatic collection of statistics

Under normal circumstances, the system will have a task (Task) to automatically collect statistical data on a regular basis. This task collects database-related statistical data in a fixed time window. Of course, this time window can also be changed. The default is every night and weekend. The specific tasks and time windows, as well as the commands for viewing and operating, will vary from version to version. For details, please refer to the official or other related documents. Below, we take Oracle 11g as an example to explain the query, disabling, enabling, and configuration of this task and its scheduling window.

1.1. Task view

SQL> select CLIENT_NAME,STATUS from DBA_AUTOTASK_CLIENT;

1.2. Task Disable

SQL> exec DBMS_AUTO_TASK_A

Guess you like

Origin blog.csdn.net/LHDZ_BJ/article/details/131296388