Search

CN-114253991-B - Execution mode control method, device, equipment and storage medium

CN114253991BCN 114253991 BCN114253991 BCN 114253991BCN-114253991-B

Abstract

The method comprises the steps of determining execution events corresponding to sub-query sentences in a first SQL sentence and corresponding execution modes respectively, determining whether the first sub-query sentences contain preset hit prompt sentences, if so, determining target execution events and corresponding target execution modes of the first sub-query sentences based on the hit prompt sentences, adjusting cost estimation of the execution modes corresponding to the target execution events, obtaining adjusted cost estimation corresponding to the execution modes respectively, determining the input of an optimizer, and triggering the target execution event based on the target execution modes. According to the embodiment of the disclosure, after the target execution mode is determined based on the hit prompt statement, the execution mode corresponding to the single execution event can be controlled in finer granularity by adjusting the cost estimation mode of each execution mode, so that the control flexibility is improved.

Inventors

  • Fan Guoteng
  • YIN QIANG

Assignees

  • 北京人大金仓信息技术股份有限公司

Dates

Publication Date
20260505
Application Date
20211207

Claims (8)

  1. 1. A method for controlling an execution mode, the method comprising: determining an execution event corresponding to each sub-query statement in the SQL statement of the first structured query language, and an execution mode corresponding to each execution event; Determining whether a first sub-query statement comprises a preset hit prompt statement, wherein the hit prompt statement is used for specifying a target execution event and a target execution mode corresponding to the target execution event, the hit prompt statement carries a data table identifier and an execution mode identifier, the data table identifier is used for identifying an event executed aiming at a data table corresponding to the data table identifier, and the execution mode identifier is used for specifying the target execution mode corresponding to the event; If the first sub-query statement contains the hit prompt statement, determining a target execution event of the first sub-query statement based on the data table identifier carried by the hit prompt statement, and determining a target execution mode corresponding to the target execution event based on the execution mode identifier; Adjusting the cost estimation value of the target execution mode corresponding to the target execution event to 0 to serve as an adjusted cost estimation value of the target execution mode; Or adding a preset value to the cost estimated values of the execution modes corresponding to the target execution event except the target execution mode to obtain adjusted cost estimated values corresponding to the execution modes respectively, wherein the magnitude of the preset value is larger than that of the cost estimated value of any execution mode; the method comprises the steps of determining adjusted cost estimation values corresponding to all execution modes respectively as input of an optimizer, and enabling the target execution mode to be selected as a final execution mode corresponding to a target execution event by the optimizer based on the characteristics of the final execution mode corresponding to the target execution event, wherein the optimizer is used for triggering the execution of the target execution event based on the target execution mode.
  2. 2. The method of claim 1, wherein the execution mode identification includes an execution mode key and a number of parallel processes; The determining the target execution mode corresponding to the target execution event based on the execution mode identification comprises the following steps: and determining a target execution mode corresponding to the target execution event based on the execution mode key words and the parallel process quantity.
  3. 3. The method of claim 2, wherein the target execution event comprises a parallel scan event performed for the data table to identify a corresponding data table.
  4. 4. The method of claim 1, wherein the execution mode identification comprises a sequential relationship between an execution mode key and each data table identification; The determining the target execution mode corresponding to the target execution event based on the execution mode identification comprises the following steps: And determining a target execution mode corresponding to the target execution event based on the sequence relation between the execution mode keywords and the data table identifiers.
  5. 5. The method of claim 4, wherein the target execution event comprises a connection order determination event performed for the data table for which the data table identification corresponds.
  6. 6. An execution mode control device, characterized by comprising: The first determining module is used for determining the execution event corresponding to each sub-query statement in the SQL statement of the first structured query language and the execution mode corresponding to each execution event; The system comprises a first sub-query statement, a second determination module and a first query module, wherein the first sub-query statement comprises a preset hit prompt statement, the hit prompt statement is used for specifying a target execution event and a target execution mode corresponding to the target execution event, the hit prompt statement carries a data table identifier and an execution mode identifier, the data table identifier is used for identifying an event executed by a data table corresponding to the data table identifier, and the execution mode identifier is used for specifying the target execution mode corresponding to the event; the third determining module is configured to determine, if it is determined that the first sub-query statement includes the hit prompt statement, a target execution event of the first sub-query statement based on the data table identifier carried by the hit prompt statement, and determine, based on the execution manner identifier, a target execution manner corresponding to the target execution event; the first adjusting sub-module is used for adjusting the cost estimation value of the target execution mode corresponding to the target execution event to 0 and taking the cost estimation value as the adjusted cost estimation value of the target execution mode; Or a second adjustment sub-module, configured to increase the cost estimation values of the execution modes corresponding to the target execution event by a preset value to obtain adjusted cost estimation values corresponding to the execution modes respectively, where the magnitude of the preset value is greater than the magnitude of the cost estimation value of any execution mode; And the execution module is used for determining the adjusted cost estimation values corresponding to the execution modes respectively as the input of an optimizer, and selecting the execution mode corresponding to the minimum cost estimation value as the characteristic of the final execution mode corresponding to the target execution event based on the optimizer, so that the target execution mode is selected as the final execution mode corresponding to the target execution event by the optimizer, wherein the optimizer is used for triggering the execution of the target execution event based on the target execution mode.
  7. 7. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein instructions, which when run on a terminal device, cause the terminal device to implement the method according to any of claims 1-5.
  8. 8. An apparatus comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method of any of claims 1-5 when the computer program is executed.

Description

Execution mode control method, device, equipment and storage medium Technical Field The disclosure relates to the technical field of databases, and in particular relates to a control method, a device, equipment and a storage medium of an execution mode. Background With the continuous development of database technology, database systems are increasingly applied, and with the importance of performance of database systems, the importance of performance of database systems is also becoming more prominent, and the optimizer determines the performance of a database system to a great extent. For example, a CBO (Cost-Based optimization) is a Cost-Based Optimizer, and can calculate a corresponding Cost estimate for each execution mode depending on statistical information and a Cost model, and select an execution mode with the smallest Cost estimate as an optimal execution mode. Currently, in the related art, due to diversity of usage scenarios of customer site query, manual intervention may be required to select an execution mode, and when manual intervention is required to select an execution mode, a solution is generally adopted in which a database system provides global parameters for global control, for example, setting a certain global parameter may prohibit a CBO optimizer from selecting a certain execution mode. However, the processing manner in the related art can only perform global control, but cannot control the execution manner corresponding to the single execution event in a finer granularity, so that the control is not flexible enough. Therefore, how to control the execution mode corresponding to a single execution event in a finer granularity, so as to improve the control flexibility, is a technical problem to be solved in the present day. Disclosure of Invention In order to solve the technical problems, the present disclosure provides a control method for an execution mode, which can control the execution mode corresponding to a single execution event in a finer granularity, and improve the flexibility of control. In a first aspect, the present disclosure provides a method for controlling an execution mode, where the method includes: determining an execution event corresponding to each sub-query statement in the SQL statement of the first structured query language, and an execution mode corresponding to each execution event; Determining whether a first sub-query statement comprises a preset hit prompt statement or not, wherein the hit prompt statement is used for designating a target execution event and a target execution mode corresponding to the target execution event; if the first sub-query statement contains the hit prompt statement, determining a target execution event of the first sub-query statement and a target execution mode corresponding to the target execution event based on the hit prompt statement; adjusting the cost estimation value of the execution mode corresponding to the target execution event to obtain adjusted cost estimation values respectively corresponding to the execution modes, wherein the adjusted cost estimation value corresponding to the target execution mode belongs to the minimum value in the adjusted cost estimation values of the execution mode corresponding to the target execution event; And determining the adjusted cost estimation values corresponding to the execution modes respectively as input of an optimizer, wherein the optimizer is used for triggering the execution of the target execution event based on the target execution mode. In an optional implementation manner, the hit prompt statement carries a data table identifier and an execution mode identifier, where the data table identifier is used to identify an event executed for a data table corresponding to the data table identifier, and the execution mode identifier is used to specify a target execution mode corresponding to the event; The determining, based on the hit hint statement, a target execution event of the first sub-query statement and a target execution mode corresponding to the target execution event includes: And determining a target execution event of the first sub-query statement based on the data table identifier carried by the hit prompt statement, and determining a target execution mode corresponding to the target execution event based on the execution mode identifier. In an alternative embodiment, the execution mode identifier includes an execution mode key and a number of parallel processes; The determining the target execution mode corresponding to the target execution event based on the execution mode identification comprises the following steps: and determining a target execution mode corresponding to the target execution event based on the execution mode key words and the parallel process quantity. In an alternative embodiment, the target execution event includes a parallel scan event performed with respect to the data table identification corresponding to the data table. In an alternati