Request processing method and device, computer equipment, readable storage medium and program product

By receiving non-first execution SQL requests, and using the execution plan generated during the first execution to determine and call the dynamic library file execution request, the problem of inefficient execution of stored procedures is solved and a more efficient execution process is achieved.

CN119576973APending Publication Date: 2025-03-07CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411768329.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

When executing SQL statement instructions, existing stored procedures need to be parsed and interpreted, resulting in inefficient execution.

Method used

By receiving structured query language requests that are not executed for the first time, the target dynamic library file is determined based on the execution plan generated at the first time, and the dynamic library file execution request is called to avoid the process of parsing and generating the execution plan every time.

Benefits of technology

Simplifies the process of analyzing and executing plan generation, and improves the execution efficiency of stored procedures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576973A_ABST
    Figure CN119576973A_ABST
Patent Text Reader

Abstract

The invention relates to a request processing method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the steps that a first structured query language request is received, wherein the first structured query language request represents a request which is not executed for the first time and calls a storage process; under the condition that a corresponding execution plan exists in the first structured query language request, a target dynamic library file is determined according to the execution plan, and the execution plan is generated when the first structured query language request is executed for the first time; and calling the target dynamic library file to execute the first structured query language request. By adopting the method, the efficiency can be improved, and the database performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a request processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] Stored procedures are common objects in databases. They are essentially named code segments. They are widely used in databases and can simplify client code and improve database security.

[0003] In traditional technology, when a stored procedure is interpreted and executed, it generates interpretation instructions and interprets these instructions in the face of compilation tasks. These instructions are stored in the data dictionary in the form of instruction sequences. When executing, it starts from the first instruction. If it encounters control syntax such as branches and loops, it is uniformly converted into conditional jump or unconditional jump instructions. Otherwise, it is interpreted sequentially. When interpreting instructions, the corresponding action can be executed according to the instruction type, and an execution context corresponding to the interpretation instruction needs to be configured.

[0004] However, in current stored procedures, each execution of a Structured Query Language (SQL) statement instruction is parsed and then executed, resulting in low efficiency in executing SQL statement instructions. Summary of the invention

[0005] Based on this, it is necessary to provide a request processing method, apparatus, computer device, computer-readable storage medium and computer program product that can improve execution efficiency in response to the above technical problems.

[0006] In a first aspect, the present application provides a request processing method, the method comprising:

[0007] receiving a first structured query language request, wherein the first structured query language request represents a request that is not executed for the first time and calls a stored procedure;

[0008] In the case that there is an execution plan corresponding to the first structured query language request, determining a target dynamic library file according to the execution plan, wherein the execution plan is generated when the first structured query language request is executed for the first time;

[0009] The target dynamic library file is called to execute the first structured query language request.

[0010] In one embodiment, before receiving the first structured query language request, the method further includes:

[0011] Get the structured query language compilation task;

[0012] Generate a compilation instruction corresponding to the structured query language compilation task, wherein the compilation instruction includes a first parameter, and the first parameter represents a parameter required when generating a high-level language code snippet;

[0013] The first parameter is compiled to generate a dynamic library file.

[0014] In one embodiment, the generating of the compilation instruction corresponding to the structured query language compilation task includes:

[0015] Identifying a second parameter in the structured query language compilation task; the second parameter includes at least one of a control statement, a variable declaration, an operator, a call of a built-in function, and a character of the structured query language;

[0016] Convert the second parameter into the first parameter of a high-level language equivalently to obtain the corresponding compilation instruction;

[0017] The step of compiling the first parameter to generate a dynamic library file includes:

[0018] Determine the high-level language code fragment according to the first parameter;

[0019] The high-level language code fragment is compiled to generate a dynamic library file.

[0020] In one embodiment, before determining the target dynamic library file according to the execution plan, the method further includes:

[0021] receiving a second structured query language request, where the second structured query language request represents a request for calling a stored procedure and carries structure information;

[0022] In the case that the second structured query language request is a first request, the structural information is parsed when the second structured query language request is executed to generate an execution plan.

[0023] In one embodiment, after calling the target dynamic library file to execute the first structured query language request, the method further includes:

[0024] If the execution of the first structured query language request fails, parsing the structure information of the first structured query language request to generate a new execution plan;

[0025] Determine the target dynamic library according to the new execution plan;

[0026] Re-execute the step of calling the target dynamic library file to execute the first structured query language request.

[0027] In one embodiment, before calling the target dynamic library file to execute the first structured query language request, the method further includes:

[0028] Verify the effective period information of the execution plan;

[0029] The calling of the target dynamic library to execute the first structured query language request includes:

[0030] When the validity period information is verified, the parameter information of the first structured query language request is transferred to the target dynamic library, and the target dynamic library including the parameter information is run to execute the first structured query language request.

[0031] In a second aspect, the present application further provides a request processing device, the device comprising:

[0032] A first receiving module is used to receive a first structured query language request, where the first structured query language request represents a request that is not executed for the first time and calls a stored procedure;

[0033] a first determining module, configured to determine a target dynamic library file according to an execution plan corresponding to the first structured query language request, when the execution plan corresponds to the first structured query language request, wherein the execution plan is generated when the first structured query language request is executed for the first time;

[0034] An execution module is used to call the target dynamic library file to execute the first structured query language request.

[0035] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0036] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.

[0037] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.

[0038] The request processing method, device, computer equipment, computer-readable storage medium and computer program product first receive a first structured query language request, wherein the first structured query language request represents a request that is not executed for the first time and calls a stored procedure; secondly, when there is a corresponding execution plan for the first structured query language request, the target dynamic library file is determined according to the execution plan, wherein the execution plan is generated when the first structured query language request is executed for the first time; finally, the target dynamic library file is called to execute the first structured query language request. By calling a stored procedure, i.e., a process of calling a dynamic library file, according to the first structured query language request, determining the target dynamic library file according to the execution plan, and calling the target dynamic library file to execute the first structured query language request, it is avoided that the first structured query language request needs to be parsed each time before an execution plan can be generated, and the process of parsing and generating an execution plan is simplified, thereby improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 A schematic diagram of a request processing method in one embodiment;

[0041] Figure 2 A schematic diagram of a flow chart of a method for generating a dynamic library file in one embodiment;

[0042] Figure 3 A timing diagram for explaining the execution of a stored procedure in one embodiment;

[0043] Figure 4 A timing diagram of compiling and executing a stored procedure in one embodiment;

[0044] Figure 5 A schematic diagram of a process for generating a compilation instruction corresponding to a structured query language compilation task in an embodiment;

[0045] Figure 6 A schematic diagram of a process flow for executing plan generation in one embodiment;

[0046] Figure 7 A schematic diagram of a flow chart of regenerating and executing an execution plan in an embodiment;

[0047] Figure 8 A schematic diagram of a flow chart of verifying effective period information of an execution plan in one embodiment;

[0048] Fig. 9 is a flow chart of a method for determining effective period information in one embodiment;

[0049] Fig.10 is a structural block diagram of a request processing device in one embodiment;

[0050] Fig.11 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] In one embodiment, Figure 1 As shown, a request processing method is provided. This embodiment uses the method applied to a terminal as an example for illustration. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps S102 to S106:

[0053] Step S102: receiving a first structured query language request, where the first structured query language request represents a request that is not executed for the first time and calls a stored procedure.

[0054] The first structured query language request may also be referred to as the first structured query language statement instruction, which is a structured query language request or a structured query language statement instruction that occurs during the call of the stored procedure. The first structured query language request represents a request that is not executed for the first time, and includes at least one of a data manipulation language (DML) and a query. DML specifically refers to a statement that modifies the data content (excluding metadata) of a database.

[0055] Optionally, before the server receives the first structured query language request, the server loads the target dynamic library file when the database starts or calls the stored procedure for the first time. The server receives the first structured query language request, that is, an SQL request or an SQL instruction; for example, the first structured query language request is the second occurrence of query request A, and is a request to call a stored procedure. The server receives the second occurrence of query request A.

[0056] Optionally, the server receives an initial first structured query language request, and determines whether the initial first structured query language request appears for the first time through records, and if it does not appear for the first time, the initial first structured query language request is used as the first structured query language request. For example, the server receives a first SQL request A', and determines whether the first SQL request A' appears for the first time through records, and if the first SQL request A' can be queried from the records, the first SQL request A' is used as the first SQL request A.

[0057] Step S104 , when there is an execution plan corresponding to the first structured query language request, determining the target dynamic library file according to the execution plan, wherein the execution plan is generated when the first structured query language request is executed for the first time.

[0058] The database may have multiple different algorithms that can achieve the same result. The database will select the algorithm with the best performance based on the current data set. The execution plan is an execution plan generated based on the SQL query statement and the optimal algorithm. The execution plan describes the specific operation process of the database system when executing a query, including information such as data access path, operation sequence, and operation mode.

[0059] Dynamic library, also known as shared library, is a library file that is loaded only when the program is running. Dynamic library file is the specific manifestation of dynamic library, which is a binary file stored on disk. Dynamic library file contains the functions and data in the dynamic library, as well as the necessary metadata, so that the operating system can load and use it correctly when the program is running.

[0060] Optionally, before the server receives the first structured query language request and determines the target dynamic library file according to the execution plan, when the server executes the first structured query language request for the first time, the server parses the first structured query language to generate a parse tree, and generates an execution plan according to the parse tree. The server will skip SQL parsing and execution plan generation, and directly obtain the execution plan corresponding to the first structured query language request.

[0061] Optionally, in the case that there is a corresponding execution plan for the first structured query language request, the server loads the execution plan, and the server determines the target dynamic library file corresponding to the first structured query language request according to the execution plan.

[0062] Step S106: calling the target dynamic library file to execute the first structured query language request.

[0063] Optionally, the server calls the target dynamic library file to execute the first structured query language request, passes the request parameters of the first structured query language request to the target dynamic library file, and the target dynamic library file outputs the result.

[0064] In the above request processing method, firstly, a first structured query language request is received, and the first structured query language request represents a request that is not executed for the first time and calls a stored procedure; secondly, when there is a corresponding execution plan for the first structured query language request, the target dynamic library file is determined according to the execution plan, wherein the execution plan is generated when the first structured query language request is executed for the first time; finally, the target dynamic library file is called to execute the first structured query language request. By calling a stored procedure, i.e., a process of calling a dynamic library file, according to the first structured query language request, determining the target dynamic library file according to the execution plan, and calling the target dynamic library file to execute the first structured query language request, it is avoided that the first structured query language request needs to be parsed each time before the execution plan can be generated, and the process of parsing and generating the execution plan is simplified, thereby improving efficiency.

[0065] In an exemplary embodiment, Figure 2 As shown, a method for generating a dynamic library file is provided, comprising the following steps S202 to S206. Wherein:

[0066] Step S202: Obtain a structured query language compilation task.

[0067] Optionally, before calling the stored procedure, the server needs to create the stored procedure. Creating the stored procedure includes the server obtaining a structured query language compilation task.

[0068] Step S204: Generate a compilation instruction corresponding to the structured query language compilation task, wherein the compilation instruction includes a first parameter, and the first parameter represents a parameter required when generating a high-level language code snippet.

[0069] Compilation instructions are different from traditional interpretation instructions. Interpretation instructions are executed line by line, and the current context needs to be switched. Compilation instructions are converted into machine codes that can be directly executed at one time without switching contexts. For example, a SQL compilation task is A+B. The generated compilation instruction regards A+B as a whole; while the generated interpretation instruction interprets A and executes A; interprets + and executes +; interprets B and executes B.

[0070] Optionally, the server generates a compilation instruction corresponding to the structured query language compilation task, and the generation of the compilation instruction focuses on how to provide the parameters required when generating the high-level language source code fragment. The high-level language source can be C++, C language, etc. When generating the interpretation instruction, the focus is on providing the parameters required for interpretation (such as the condition of the conditional transfer instruction).

[0071] Step S206, compile the first parameter to generate a dynamic library file.

[0072] Optionally, the server compiles the first parameter in the compile instruction to generate a dynamic library file. The dynamic library file includes generated high-level language source code.

[0073] Optionally, after generating the dynamic library file, the server associates the dynamic library file with a data dictionary, thereby completing the creation of the stored procedure. The data dictionary refers to a data set in the database used to store and describe database objects, and the data in the data dictionary is called metadata.

[0074] Explain the timing diagram of executing a stored procedure, such as Figure 3 As shown. After successfully connecting to the database, the structured query language compilation task is received, and a message for parsing and executing the compilation task is sent to the database main context. In the main context, the interpretation instructions in the data dictionary are queried, and the context is switched from the main context to the stored procedure context. In the stored procedure context, the interpretation instructions are interpreted according to the SQL compilation task. When the first structured query language request is subsequently executed and the stored procedure is called, the stored procedure context needs to be switched from the context to the query context to complete the execution of the first structured query language request. Among them, the survival domain and visible domain of the variables in the context language, and the grammatical components of each word in the language are determined by the grammar, but what a variable or operator refers to must be determined by the context. In different contexts, each grammatical component can have different interpretations.

[0075] On the one hand, the interpretation and execution process of stored procedures is lengthy, and there are complex and multiple context switches, which makes the performance of executing multiple DML or queries in stored procedures even worse than splitting these SQL statements into independent single statements and executing them in sequence by high-level languages. On the other hand, stored procedures do not record the structural information of DML and queries in them. Each time an SQL statement is executed, it has to be re-parsed and prepared before it can be executed, and the commonality of each SQL execution is not utilized. This is particularly obvious when the stored procedure is executed frequently and multiple times.

[0076] Compile and execute the timing diagram of the stored procedure, such as Figure 4 As shown. After successfully connecting to the database, the structured query language compilation task is received, and a message for parsing and executing the compilation task is sent to the database main context. The compilation instructions in the data dictionary are queried in the main context, and the target dynamic library file is loaded according to the compilation instructions. The creation of the stored procedure is completed, and the subsequent call to the stored procedure will be interpreted as a call to the dynamic library file. When the first structured query language request is subsequently executed and the stored procedure is called, the dynamic library file needs to be switched to the query context, and the execution of the first structured query language request is completed.

[0077] In this embodiment, the dynamic library file is determined by the compilation instruction generated by the structured query language compilation task. After that, the call to the stored procedure will be interpreted as a call to the dynamic library file. When compiling and executing the stored procedure, it is no longer necessary to set the stored procedure context, nor is it necessary to repeatedly switch the context between the stored procedure context and the main context and the query context, thereby improving database performance and processing efficiency.

[0078] In the previous embodiment, Figure 5 As shown, generating a compilation instruction corresponding to a structured query language compilation task includes steps S502 to S506. Among them:

[0079] Step S502: identifying a second parameter in the structured query language compilation task.

[0080] The second parameter includes at least one of a control statement, a variable declaration, an operator, a call of a built-in function, and a character of a structured query language.

[0081] Optionally, the server recognizes a second parameter in the structured query language compilation task, such as a control statement and a variable declaration.

[0082] Step S504: convert the second parameter into the first parameter of the high-level language equivalently to obtain a corresponding compilation instruction.

[0083] Optionally, the server converts the second parameter into a first parameter of a high-level language, thereby obtaining a corresponding compilation instruction.

[0084] If the second parameter is a control statement (such as branch, loop, jump, etc.), the high-level language used is C++. Since C++ control statements are a superset of SQL control statements, the server converts the second parameter into the first parameter of the high-level language through the mapping relationship between C++ control statements and SQL control statements. For example, for the if statement, SQL (IF statement): IF @condition = 1 BEGIN -- SQL statement END ELSE BEGIN -- other SQL statements END. The server converts SQL (IF statement) into C++ (if-else statement): if (condition == 1) { / / C++ statement} else { / / other C++ statements}.

[0085] If the second parameter is the start and end of a control block, you can directly convert begin and end into { and} by using the mapping relationship between the start and end of a C++ control block and the start and end of a SQL control block. For example, the first parameter BEGIN -- SQL statement END is equivalent to the second parameter { / / C++ statement}.

[0086] If the second parameter is a variable declaration, since the C++ type is a superset of the SQL type, through the mapping relationship between the C++ variable declaration and the SQL variable declaration, the server converts the second parameter into the first parameter of the high-level language, including the type name and the variable name.

[0087] If the second parameter is a logical or arithmetic operation, the C++ operator is a superset of the SQL operator. Through the mapping relationship between the C++ operator and the SQL operator, the server converts the second parameter into the first parameter of the high-level language.

[0088] If the second parameter is a built-in function call, if the call to the built-in function is located in traditional SQL, it is still regarded as a part of the traditional SQL and executed together with the SQL. If the built-in function is called in a stored procedure, since the built-in functions are all interpreted, the context of the interpreted built-in function is lost after compilation. Therefore, a compile-time version must be written for all built-in functions. The second parameter is the function name.

[0089] If the second parameter is a character of the structured query language, for traditional SQL statements (such as SELECT, INSERT, UPDATE, DELETE), these can be saved as text strings, and then in C++, through the pre-established mapping relationship, the second parameter is converted into the first parameter of the high-level language to obtain the corresponding compilation instructions.

[0090] Compiling the first parameter to generate a dynamic library file includes steps S506 to S508.

[0091] Step S506: determine the high-level language code segment according to the first parameter.

[0092] Optionally, the server determines a high-level language code snippet, such as a C++ source code snippet, according to the first parameter.

[0093] Step S508, compile the high-level language code fragment to generate a dynamic library file.

[0094] Optionally, the server compiles the high-level language code fragments, such as the ++ source code fragments, through Just In Time compilation (JIT) to generate a dynamic library file. Here, Just In Time compilation is a technology for dynamically generating executable code fragments when the program is running.

[0095] In this embodiment, by generating compilation instructions and creating a dynamic library file according to the compilation instructions, the performance of the compiled execution stored procedure is significantly improved when executing logical or arithmetic operations compared to the interpreted execution stored procedure.

[0096] In an exemplary embodiment, a method for generating an execution plan, such as Figure 6 As shown, before determining the target dynamic library file according to the execution plan, steps S602 to S604 are included. Among them:

[0097] Step S602: receiving a second structured query language request, where the second structured query language request represents a request for calling a stored procedure and carries structure information.

[0098] The second structured query language request is a structured query language request or a structured query language instruction that appears in the calling storage process. A step performed before obtaining an execution plan corresponding to the first structured query language request from a dynamic library file.

[0099] The structural information may include language elements, SQL statement types, basic query structures, rows, columns, primary keys, etc. The basic query structures include SELECT clauses, FROM clauses, etc.

[0100] Optionally, the server receives the second structured query language request, and extracts structural information carried by the second structured query language request from the second structured query language request.

[0101] Step S604: when the second structured query language request is the first request, the structure information is parsed when the second structured query language request is executed to generate an execution plan.

[0102] Optionally, when the second structured query language request is the first request, the structure information is parsed, and an execution plan is generated according to a parse tree obtained by parsing the structure information, so that when the same structured query language request is subsequently received, the execution plan can be directly obtained, and the process of parsing and generating the execution plan can be skipped.

[0103] In this embodiment, by preparing the execution plans corresponding to the various structured query language requests in advance, the corresponding execution plans can be obtained directly according to the first structured query language request later, and the process of parsing and generating the execution plan can be skipped, thereby improving the execution efficiency and improving the database performance.

[0104] In an exemplary embodiment, Figure 7 As shown, after calling the target dynamic library file to execute the first structured query language request, the execution plan is regenerated and executed, including steps S702 to S706. Among them:

[0105] Step S702: If the execution of the first structured query language request fails, the structure information of the first structured query language request is parsed to generate a new execution plan.

[0106] Optionally, the execution plan may fail, and when the execution plan fails, the execution of the first structured query language request will fail. The server will reparse the structural information of the first structured query language request to obtain a parse tree, and generate a new execution plan based on the parse tree.

[0107] Step S704, determining the target dynamic library according to the new execution plan.

[0108] Optionally, the server determines a target dynamic library for executing the first structured query language request according to the new execution plan.

[0109] Step S706, re-execute the step of calling the target dynamic library file to execute the first structured query language request.

[0110] Optionally, the server calls the target dynamic library to execute the first structured query language request.

[0111] In this embodiment, even if the previous execution plan is invalid, the process of parsing and generating a new execution plan will be re-executed, so that the response rate of the first structured query language request can be improved.

[0112] In an exemplary embodiment, the verification of the effective period information of the execution plan is performed, such as Figure 8 As shown, the execution plan carries the effective period information. Before calling the target dynamic library file to execute the first structured query language request, it includes: step S802, verifying the effective period information of the execution plan.

[0113] The execution plan carries the effective period information. Through the setting of the effective period information, the execution plan will be stored in two types: one is the invalid execution plan; the other is the effective or valid execution plan. The execution plan may become invalid. The first case is that the relevant metadata is changed. In this case, the execution plan must be invalidated immediately. The second case is that with the slow change of the data set, the execution plan is no longer the algorithm with the best performance, but the result is correct. Therefore, when the result is correct but the performance is not optimal, it is necessary to verify the effective period information of the execution plan.

[0114] Optionally, the server verifies the effective period information of the execution plan, and obtains different results according to the verification of the effective period information. If the effective period information passes the verification, the execution plan is a valid execution plan. If the effective period information fails the verification, the execution plan is an invalid execution plan. If it is an invalid execution plan, the execution of the first structured query language request fails, and the server needs to parse the structural information of the first structured query language request and generate a new execution plan. The first structured query language request is executed according to the new execution plan, and the new execution plan is stored in the dynamic library file to replace the invalid execution plan.

[0115] Calling the target dynamic library to execute the first structured query language request includes step S804, in which, when the valid period information is verified, the first structured query language request is executed according to the execution plan.

[0116] Optionally, when the valid period information is verified to be passed, that is, the execution plan is valid, the server executes the first structured query language request according to the execution plan.

[0117] The method of determining the effective period information, such as Fig. 9 As shown, it includes steps S902 to S906:

[0118] Step S902: obtaining a preset mapping relationship table, where the mapping relationship table includes a relationship between the type of the structured query language request and the third parameter.

[0119] Optionally, the server constructs a mapping relationship table, wherein the mapping relationship table includes a relationship between the type of the structured query language request and the third parameter. The third parameter is a parameter used to set the effective period information. The type of the structured query language request is determined according to the query syntax and logic of the first structured query language request, the functions and operators used, etc., the third parameter is determined according to the type of the structured query language request and the statistical information of the database, and a mapping relationship is established between the type of the structured query language request and the third parameter, which is stored in the mapping relationship table.

[0120] Optionally, the server obtains a preset mapping relationship table.

[0121] Step S904: determine a third parameter according to the type of the first structured query language request and the mapping relationship table.

[0122] Optionally, the server extracts the query syntax and logic, used functions and operators, etc. of the first structured query language request to determine the type of the structured query language request, and determines the third parameter according to a preset mapping relationship table.

[0123] Step S906: Generate effective period information of the execution plan according to the third parameter.

[0124] Optionally, the server generates effective period information of the execution plan according to the third parameter.

[0125] In this embodiment, by setting the effective time period information, an expiration time limit can be set for the execution plan, and the execution plan can be invalidated regularly, so as to maintain the execution plan as the optimal solution and improve the accuracy of the execution plan.

[0126] In an exemplary embodiment, the server needs to create a stored procedure before calling the stored procedure. Creating a stored procedure includes the server obtaining a structured query language compilation task. The server identifies the second parameter in the structured query language compilation task, such as a control statement and a variable declaration. The server converts the second parameter into a first parameter of a high-level language, thereby obtaining a corresponding compilation instruction. If the second parameter is a control statement (such as a branch, loop, jump, etc.), the high-level language used is C++. Since the control statement of C++ is a superset of the SQL control statement, the server converts the second parameter into the first parameter of the high-level language through the mapping relationship between the control statement of C++ and the SQL control statement. For example, for an if statement, SQL (IF statement): IF @condition = 1 BEGIN -- SQL statement END ELSE BEGIN -- other SQL statements END. The server converts SQL (IF statement) into C++ (if-else statement): if (condition == 1) { / / C++ statement} else { / / other C++ statements}. If the second parameter is the start and end of the control block, the mapping relationship between the start and end of the C++ control block and the start and end of the SQL control block can be used to directly convert begin and end to { and}. For example, the first parameter BEGIN -- SQL statement END is equivalent to the second parameter { / / C++ statement}. If the second parameter is a variable declaration, since the C++ type is a superset of the SQL type, the server converts the second parameter to the first parameter of the high-level language, including the type name and variable name, through the mapping relationship between the C++ variable declaration and the SQL variable declaration. If the second parameter is a logical or arithmetic operation, the C++ operator is a superset of the SQL operator. Through the mapping relationship between the C++ operator and the SQL operator, the server converts the second parameter to the first parameter of the high-level language. If the second parameter is a built-in function call, if the call to the built-in function is in traditional SQL, it is still regarded as a part of the traditional SQL and executed together with SQL. If the built-in function is called in a stored procedure, since the built-in functions are all interpreted and executed, but the context of the interpreted execution of the built-in function has been lost after compilation, a version used during compilation must be written for each built-in function. The second parameter is the function name. If the second parameter is a structured query language character, for traditional SQL statements (such as SELECT, INSERT, UPDATE, DELETE), these can be saved as text strings, and then in C++, the second parameter is equivalently converted into the first parameter of the high-level language through a pre-established mapping relationship to obtain the corresponding compilation instruction. The server determines the high-level language code fragment, such as the C++ source code fragment, based on the first parameter.The server compiles a high-level language code fragment, such as a JITc++ source code fragment, through Just In Time compilation (JIT) to generate a dynamic library file.

[0127] The server receives a second structured query language request, which represents a request to call a stored procedure and carries structure information; and extracts the structure information carried by the second structured query language request from the second structured query language request. The structure information may include language elements, SQL statement types, basic query structures, rows, columns, primary keys, etc. The basic query structure includes a SELECT clause, a FROM clause, etc. If the second structured query language request is a first request, the structure information is parsed, and an execution plan is generated based on a parse tree obtained by parsing the structure information.

[0128] If the second structured query language request is the same as the first structured query language request, SQL parsing and the generation of the execution plan are skipped, and the execution plan corresponding to the first structured query language request is directly obtained. The execution plan carries valid period information, and before calling the target dynamic library file to execute the first structured query language request, the valid period information of the execution plan is verified. Different results are obtained according to the verification of the valid period information. The valid period information passes the verification, that is, the execution plan is a valid execution plan. If the valid period information does not pass the verification, that is, the execution plan is an invalid execution plan. If it is an invalid execution plan, it will cause the execution of the first structured query language request to fail, then the server needs to parse the structural information of the first structured query language request and generate a new execution plan. According to the new execution plan, the target dynamic library is determined, and the target dynamic library file is called to execute the first structured query language request. If the valid period information is verified, that is, the valid execution plan, the server determines the target dynamic library according to the execution plan, and calls the target dynamic library file to execute the first structured query language request. Wherein, the method for determining the valid period information includes: the server constructs a mapping relationship table, wherein the mapping relationship table includes the relationship between the type of the structured query language request and the third parameter. Among them, the third parameter is a parameter for setting the effective period information. The type of the structured query language request is determined according to the query syntax and logic of the first structured query language request, the functions and operators used, etc., the third parameter is determined according to the type of the structured query language request and the statistical information of the database, and a mapping relationship is established between the type of the structured query language request and the third parameter, and stored in a mapping relationship table. The server extracts the query syntax and logic of the first structured query language request, the functions and operators used, etc. to determine the type of the structured query language request, and determines the third parameter according to the pre-set mapping relationship table. The server generates the effective period information of the execution plan according to the third parameter.

[0129] In this embodiment, the performance of compiled stored procedures is significantly improved when performing logical or arithmetic operations compared to interpreted stored procedures. When compiled stored procedures are executed, there is no need to set the stored procedure context, nor is there a need to repeatedly switch contexts between the stored procedure context and the query context, thereby improving performance. When compiled stored procedures are executed, for traditional SQL in the stored procedures, the structural information of these SQLs can be retained as commonality, eliminating the subsequent steps of parsing SQL and generating execution plans, thereby improving performance.

[0130] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0131] Based on the same inventive concept, the embodiment of the present application also provides a request processing device for implementing the request processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more request processing device embodiments provided below can refer to the limitations on the request processing method above, and will not be repeated here.

[0132] In an exemplary embodiment, Fig.10 As shown, a request processing device is provided, including: a first receiving module 1001, a first determining module 1002 and an executing module 1003, wherein:

[0133] The first receiving module 1001 is used to receive a first structured query language request, where the first structured query language request represents a request that is not executed for the first time and calls a stored procedure.

[0134] The first determination module 1002 is configured to determine a target dynamic library file according to an execution plan corresponding to the first structured query language request if the execution plan exists, wherein the execution plan is generated when the first structured query language request is executed for the first time.

[0135] The execution module 1003 is used to call the target dynamic library file to execute the first structured query language request.

[0136] In an exemplary embodiment, a request processing device is provided, further comprising:

[0137] The acquisition module is used to obtain the structured query language compilation task.

[0138] The compiling instruction generating module is used to generate the compiling instruction corresponding to the structured query language compiling task, wherein the compiling instruction includes a first parameter, and the first parameter represents the parameter required when generating the high-level language code fragment.

[0139] The dynamic library file generation module is used to compile the first parameter to generate a dynamic library file.

[0140] In an exemplary embodiment, the compilation instruction generation module includes:

[0141] The recognition unit is used to recognize the second parameter in the structured query language compilation task; the second parameter includes at least one of a control statement, a variable declaration, an operator, a call of a built-in function and a character of the structured query language.

[0142] The conversion unit is used to convert the second parameter into the first parameter of the high-level language to obtain the corresponding compilation instruction.

[0143] Dynamic library file generation module, including:

[0144] The code segment determining unit is used to determine the high-level language code segment according to the first parameter.

[0145] The compilation unit is used to compile high-level language code fragments and generate dynamic library files.

[0146] In an exemplary embodiment, a request processing device is provided, further comprising:

[0147] The second receiving module is used for a second structured query language request, where the second structured query language request represents a request for calling a stored procedure and carries structure information.

[0148] The execution plan generating module is used for parsing the structure information and generating an execution plan when executing the second structured query language request when the second structured query language request is the first request.

[0149] In an exemplary embodiment, a request processing device is provided, further comprising:

[0150] The execution plan generation module further parses the structural information of the first structured query language request and generates a new execution plan if the execution of the first structured query language request fails.

[0151] The second determination module is used to determine the target dynamic library according to the new execution plan.

[0152] The execution module 1003 is further used to re-execute the step of calling the target dynamic library file to execute the first structured query language request.

[0153] In an exemplary embodiment, the execution plan carries effective period information, and a request processing device is provided, further comprising:

[0154] Verification module, used to verify the effective period information of the execution plan;

[0155] The execution module 1003 is further configured to execute the first structured query language request according to the execution plan when the valid period information is verified.

[0156] Each module in the above request processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0157] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store database storage process data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a request processing method is implemented.

[0158] Those skilled in the art will understand that Fig.11 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0159] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0160] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0161] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0162] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0163] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0164] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A request processing method, characterized in that: The method comprises: receiving a first structured query language request, wherein the first structured query language request represents a request that is not executed for the first time and calls a stored procedure; In the case that the first structured query language request has a corresponding execution plan, determining a target dynamic library file according to the execution plan, wherein the execution plan is generated when the first structured query language request is executed for the first time; The target dynamic library file is called to execute the first structured query language request.

2. The method according to claim 1, characterized in that Before receiving the first structured query language request, the method further includes: Get the structured query language compilation task; Generate a compilation instruction corresponding to the structured query language compilation task, wherein the compilation instruction includes a first parameter, and the first parameter represents a parameter required when generating a high-level language code snippet; The first parameter is compiled to generate a dynamic library file.

3. The method according to claim 2, characterized in that The generating of the compiling instruction corresponding to the structured query language compiling task includes: Identifying a second parameter in the structured query language compilation task; the second parameter includes at least one of a control statement, a variable declaration, an operator, a call of a built-in function, and a character of the structured query language; Convert the second parameter into the first parameter of a high-level language equivalently to obtain the corresponding compilation instruction; The step of compiling the first parameter to generate a dynamic library file includes: Determine the high-level language code fragment according to the first parameter; The high-level language code fragment is compiled to generate a dynamic library file.

4. The method according to claim 1, characterized in that: Before determining the target dynamic library file according to the execution plan, the method further includes: receiving a second structured query language request, where the second structured query language request represents a request for calling a stored procedure and carries structure information; In the case that the second structured query language request is a first request, the structural information is parsed when the second structured query language request is executed to generate an execution plan.

5. The method according to claim 1, characterized in that After calling the target dynamic library file to execute the first structured query language request, the method further includes: If the execution of the first structured query language request fails, parsing the structure information of the first structured query language request to generate a new execution plan; Determine the target dynamic library according to the new execution plan; Re-execute the step of calling the target dynamic library file to execute the first structured query language request.

6. The method according to claim 1, characterized in that Before calling the target dynamic library file to execute the first structured query language request, the method further includes: Verify the effective period information of the execution plan; The calling of the target dynamic library to execute the first structured query language request includes: When the validity period information is verified, the parameter information of the first structured query language request is transferred to the target dynamic library, and the target dynamic library including the parameter information is run to execute the first structured query language request.

7. A request processing device, characterized in that: The device comprises: A first receiving module is used to receive a first structured query language request, where the first structured query language request represents a request that is not executed for the first time and calls a stored procedure; a first determining module, configured to determine a target dynamic library file according to an execution plan corresponding to the first structured query language request, when the execution plan corresponds to the first structured query language request, wherein the execution plan is generated when the first structured query language request is executed for the first time; An execution module is used to call the target dynamic library file to execute the first structured query language request.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.