SQL (Structured Query Language) statement management method and system and related product
By using shared memory in the database system to collect SQL statements and their execution information, the problem of excessive resource usage in high load scenarios is solved, and efficient SQL information collection and management are achieved.
Patent Information
- Application Number
- CN202411926742.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-01-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In high load or large traffic scenarios, the existing technology will occupy more database system resources when collecting full SQL statements, affecting the normal operation of the business.
By collecting SQL statements and its execution information in the database system, additional resource occupation and operation steps are reduced. When performing SQL statements, the database system writes relevant information into shared memory and storage is performed through the storage device.
Realize the collection of full SQL information while performing the SQL statement, reducing the cost of resource occupation and management, and improving the query efficiency of SQL information.
Smart Images

Figure CN119357218A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of databases, and in particular to a structured query language (SQL) statement management method, system and related products. Background Art
[0002] All SQL statements refer to all SQL statements executed on the database system. By analyzing all SQL statements, you can identify abnormalities in the database system.
[0003] Currently, the full amount of SQL statements can be obtained in the following ways: a SQL statement collection plug-in can be configured on the database system. The plug-in will detect the TCP traffic received by the database system based on the Transmission Control Protocol (TCP) traffic detection method, and then determine whether the TCP traffic is an SQL statement through analysis. If so, the SQL statement is stored, so that the full amount of SQL statements of the database system can be collected. It can be understood that in high-load or high-traffic scenarios, the implementation of the above solution will occupy more resources in the database system, thereby affecting the normal operation of the business. Summary of the invention
[0004] The present application provides a SQL statement management method, system and related products, which can reduce the resources occupied by the database system when collecting a full amount of SQL statements.
[0005] In a first aspect, the present application provides a method for managing SQL statements. The method may include the following steps: a database system receives an SQL information collection command, the SQL information collection command includes the size of a shared memory, and then creates a shared memory according to the size of the shared memory. When executing an SQL statement, the database system writes the SQL information corresponding to the SQL statement into the shared memory, wherein the SQL information corresponding to the SQL statement includes the SQL statement and the execution information of the SQL statement.
[0006] In the technical solution provided in the present application, the database system can collect SQL information corresponding to SQL statements while executing SQL statements based on shared memory, without the need to perform additional operations such as capturing SQL statements and parsing SQL statements, thereby reducing the resources occupied by the database system when collecting a full amount of SQL statements.
[0007] In a possible implementation, the SQL information collection command also includes an identifier of the storage device. The method further includes: the database system further reads the SQL information from the shared memory, and writes the read SQL information into the storage device according to the identifier of the storage device.
[0008] In a possible implementation, the storage device includes one or more of an object storage service (OBS) or a network attached storage (NAS).
[0009] Through the above implementation, the SQL information corresponding to all SQL statements of the database system can be persistently stored at low cost, reducing the memory resource usage in the database system and saving the cost of SQL information management.
[0010] In a possible implementation, before the database system receives the SQL information collection command, the method further includes: the control device provides a first configuration interface, receives the user's SQL information collection strategy through the first configuration interface, and the SQL information collection strategy includes the size of the shared memory and the identifier of the storage device. Afterwards, the control device generates the SQL information collection command according to the SQL information collection strategy, and sends the SQL information collection command to the database system.
[0011] It can be seen that in the above-mentioned process of enabling the full amount of SQL information collection of the database system, the user's operation is simple, thus improving the user's usage experience.
[0012] In a possible implementation, the SQL information collection strategy also includes a first storage time range for the SQL information, and the method further includes: the control device instructs the storage device to clean up the SQL information whose storage time exceeds the first storage time range. In this way, storage resources in the storage device can be saved.
[0013] In a possible implementation, after the database system writes the read SQL information into the storage device, the method further includes: the control device provides a second configuration interface, receives the user's SQL information parsing request through the second configuration interface, and the SQL information parsing request includes the target time period where the SQL information required by the user is located. Afterwards, the control device obtains the SQL information of the target time period from the storage device, and sends the SQL information of the target time period to the query device. The control device also provides a third configuration interface, receives the user's query conditions through the third configuration interface, and then reads the SQL information that meets the query conditions from the query device, and displays the read SQL information. In this way, the query efficiency of SQL information can be improved.
[0014] In a possible implementation, the SQL information parsing request also includes a second storage time range of the SQL information, and the method further includes: the control device instructs the query device to clean up the SQL information whose storage time exceeds the second storage time range. In this way, resource usage in the query device can be saved and the query efficiency of the SQL information can be improved.
[0015] In a second aspect, the present application provides a SQL statement management system. The system includes a control device and a database system. The control device is used to send an SQL information collection command to the database system, and the SQL information collection command includes the size of the shared memory. The database system is used to receive the SQL information collection command, create a shared memory according to the size of the shared memory in the command, and write the SQL information corresponding to the SQL statement into the shared memory when executing the SQL statement, wherein the SQL information corresponding to the above-mentioned SQL statement includes the SQL statement and the execution information of the SQL statement.
[0016] In a possible implementation, the SQL information collection command also includes an identifier of a storage device. The above system also includes a storage device. The database system is also used to read SQL information from the shared memory and write the read SQL information to the storage device according to the identifier of the storage device. The storage device is used to store SQL information from the database system.
[0017] In a possible implementation, the storage device includes one or more of an object storage service (OBS) or a network attached storage (NAS).
[0018] In a possible implementation, the control device is further used to provide a first configuration interface, receive the user's SQL information collection strategy through the first configuration interface, generate an SQL information collection command according to the SQL information collection strategy, and send the SQL information collection command to the database system. The SQL information collection strategy includes the size of the shared memory and the identifier of the storage device.
[0019] In a possible implementation, the SQL information collection strategy further includes a first storage time range for the SQL information. The control device is further configured to instruct the storage device to clean up SQL information whose storage time exceeds the first storage time range.
[0020] In a possible implementation, the control device is further configured to provide a second configuration interface, and receive a user's SQL information parsing request through the second configuration interface, wherein the SQL information parsing request includes a target time period in which the SQL information required by the user is located. The control device is further configured to obtain the SQL information of the target time period from the storage device, and send the SQL information of the target time period to the query device. The control device is further configured to provide a third configuration interface, and receive a user's query condition through the third configuration interface, and then read the SQL information that meets the query condition from the query device, and display the read SQL information.
[0021] In a possible implementation, the SQL information parsing request further includes a second storage time range of the SQL information. The control device is further configured to instruct the query device to clean up SQL information whose storage time exceeds the second storage time range.
[0022] In a third aspect, the present application provides a computing device cluster. The computing device cluster includes at least one computing device, and each computing device includes a processor and a memory. The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs part or all of the method described in the first aspect and any implementation thereof.
[0023] In a fourth aspect, the present application provides a computer program product comprising instructions. The computer program product may be software or a program product comprising instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device is caused to perform part or all of the method described in the first aspect and any one of its implementations.
[0024] In a fifth aspect, the present application provides a computer-readable storage medium. The computer storage medium includes computer program instructions, and when the computer program instructions are executed by a computing device, the computing device executes part or all of the method described in the first aspect and any implementation thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 This is a structural diagram of a SQL statement management system provided by this application; FIG. 2A to FIG. 2C It is a structural diagram of a database system provided by this application; Figure 3 It is a schematic diagram of an application scenario provided by this application; Figure 4 It is a flowchart of a SQL statement management method provided by this application; Figure 5 is a schematic diagram of a first configuration interface provided by the present application; Figure 6 is a schematic diagram of a second configuration interface provided by the present application; Figure 7 It is a structural diagram of a computing device cluster provided by this application; Figure 8 It is a structural diagram of another computing device cluster provided by this application. DETAILED DESCRIPTION
[0026] In order to reduce the resources occupied by the database system when collecting full SQL statements, the present application provides a SQL statement management method, which can be applied to a SQL statement management system. The above-mentioned SQL statement management system may include a control device and a database system. In a specific implementation, the control device may send a SQL information collection command to the database system. After the database system receives the above-mentioned SQL information collection command, it will create a shared memory according to the command, and when executing the SQL statement, it will also write the SQL statement and its execution information into the shared memory, thereby obtaining the full SQL statements of the database system and the execution information of the full SQL statements. It can be understood that in the above scheme, the database system can directly complete the collection of SQL statements and their execution information while executing SQL statements, and the collection process is simple and resource-saving. On the other hand, through the above scheme, not only the full SQL statements will be collected, but also the execution information of the full SQL statements will be collected, so that the user can more accurately determine the abnormality of the database system in combination with the full SQL statements and the execution information of the full SQL statements.
[0027] The technical solution provided by this application is introduced below in conjunction with the accompanying drawings.
[0028] See also Figure 1 , Figure 1 The following is a schematic diagram showing the structure of a SQL statement management system provided by the present application. Figure 1 As shown, the SQL statement management system 100 includes a control device 110 , a database system 120 , a storage device 130 and a query device 140 .
[0029] 1) Control device 110 The control device 110 is used to receive the user's SQL information collection strategy, and instruct the database system 120 to collect full SQL information according to the user's SQL information collection strategy and send the collected full SQL information to the storage device 130. The full SQL information here refers to the full SQL statements of the database system 120 and the execution information of each SQL statement. The full SQL statements include the SQL statements being executed by the database system 120 and the SQL statements that have been received but not executed. The execution information of the SQL statements refers to information related to the execution of the SQL statements, such as the execution time of the SQL statements, the execution status (such as execution success or execution failure), the waiting time, the input and output (IO) time, the CPU time, etc.
[0030] The control device 110 is also used to receive a user's SQL information parsing request, and according to the user's SQL information parsing request, obtain one or more SQL information required by the user from the storage device 130, wherein each SQL information includes an SQL statement and the execution information of the SQL statement, and then send the obtained SQL information to the query device 140 for the user to conduct further queries later.
[0031] The control device 110 is further used to instruct the storage device 130 and the query device 140 to clean up the locally stored SQL information.
[0032] 2) Database System 120 The database system 120 includes an agent module 121 and a database kernel 122. The agent module 121 can receive the SQL information collection command sent by the control device 110, and send the command to the database kernel 122, and then the database kernel 122 creates a shared memory 123. Afterwards, when the database kernel 122 executes the SQL statement, it will also write the SQL information corresponding to the SQL statement into the shared memory 123. The agent module 121 can also read the SQL information from the shared memory 123, and write the read SQL information into the storage device 130.
[0033] It is worth noting that the database system 120 can be deployed in a centralized manner or in a distributed manner. FIG. 2A to FIG. 2C , further introducing the deployment forms of various parts of the above-mentioned database system 120.
[0034] Figure 2A FIG. 1 shows a database system 120 that adopts centralized deployment. Figure 2A As shown, the database system 120 may include an engine and at least one hard disk. The engine includes at least one controller, Figure 2ATake the example that the engine includes a controller. The controller includes at least a front-end interface, a back-end interface, a memory, an agent module 121 and a database kernel 122. Among them, the front-end interface is used to receive requests sent by other controllers, as well as requests from outside the database system 120. Here, the request from outside the database system 120 can specifically include an SQL information collection command from the control device 110 and an SQL statement from the client of the database system 120. For the received SQL information collection command, the front-end interface will send the command to the agent module 121, and then the agent module 121 will send the command to the database kernel 122, and then the database kernel 122 will create a shared memory 123 in the memory. For the received SQL statement, the front-end interface will send the SQL statement to the database kernel 122, and then the database kernel 122 will execute the above SQL statement, and manage the data in the hard disk through the back-end interface. The database kernel 122 will also write the SQL information corresponding to the above SQL statement into the shared memory 123.
[0035] Figure 2B FIG. 1 shows a database system 120 using distributed deployment. Figure 2B As shown, the database system 120 includes a plurality of database nodes, and the database nodes can communicate with each other to realize data backup. Each database node includes at least a network card, a memory, an agent module 121, a database kernel 122, and at least one hard disk. Among them, the network card is used to receive requests sent by other database nodes, as well as requests from outside the database system 120. Here, the requests from outside the database system 120 can specifically include SQL information collection commands from the control device 110 and SQL statements from the client of the database system 120. For the received SQL information collection command, the network card will send the command to the agent module 121, and then the agent module 121 will send the command to the database kernel 122, and then the database kernel 122 will create a shared memory 123 in the memory. For the received SQL statement, the network card will send the SQL statement to the database kernel 122, and then the database kernel 122 will execute the above SQL statement to manage the data in the hard disk, and the database kernel 122 will also write the SQL information corresponding to the above SQL statement into the shared memory 123.
[0036] Figure 2C Another distributed database system 120 is shown. Figure 2CAs shown, the database system 120 includes multiple computing nodes and multiple storage nodes, and the multiple computing nodes can communicate with each other, and any computing node can access any storage node. Each computing node includes at least a network card, a memory, an agent module 121, and a database kernel 122, and each storage node includes at least a network card and at least one hard disk. Among them, the network card in the computing node is used to receive requests sent by other computing nodes, as well as requests from outside the database system 120. Here, the request from outside the database system 120 can specifically include an SQL information collection command from the control device 110 and an SQL statement from the client of the database system 120. For the received SQL information collection command, the network card in the computing node will send the command to the agent module 121, and then the agent module 121 will send the command to the database kernel 122, and then the database kernel 122 will create a shared memory 123 in the memory. For the received SQL statement, the network card in the computing node will send the SQL statement to the database kernel 122, and then the database kernel 122 will execute the above SQL statement and manage the data in the hard disk of the above storage node through the local network card and the network card in the storage node. The database kernel 122 will also write the SQL information corresponding to the above SQL statement into the shared memory 123.
[0037] Understandably, FIG. 2A to FIG. 2C Several possible database systems 120 are shown only as examples. In actual applications, the database system 120 may have other structures, which are not limited in this application.
[0038] 3) Storage device 130 The storage device 130 is used to store the SQL information read by the proxy module 121 from the shared memory 123. The storage device 130 is also used to receive the SQL information parsing request sent by the control device 110, and determine the SQL information required by the user according to the request, and then return the determined SQL information to the control device 110. The storage device 130 is also used to clean up the SQL information stored locally. In a specific implementation, the storage device 130 can be implemented by a low-cost storage device that supports long-term storage, such as OBS or NAS.
[0039] 4) Query device 140 The query device 140 is used to store the SQL information obtained by the control device 110 from the storage device 130. The query device 140 is also used to receive the SQL information query request sent by the control device 110, and return the corresponding SQL information to the control device 110 according to the request. The query device 140 is also used to clean up the locally stored SQL information.
[0040] In a specific implementation, the control device 110, the database system 120, the storage device 130, and the query device 140 may be implemented by software or by hardware. By way of example, the implementation of the control device 110 is described below by taking the control device 110 as an example. Similarly, the implementation of the database system 120, the storage device 130, and the query device 140 may refer to the implementation of the control device 110.
[0041] As an example of a software functional unit, the control device 110 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the control device 110 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with similar geographical locations. Generally, a region may include multiple AZs.
[0042] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0043] As an example of a hardware functional unit, the control device 110 may include at least one computing device, such as a server, etc. The control device 110 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The above-mentioned PLD may be implemented by a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0044] The multiple computing devices included in the control device 110 can be distributed in the same region or in different regions. The multiple computing devices included in the control device 110 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the control device 110 can be distributed in the same VPC or in multiple VPCs. The above-mentioned multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0045] Understandably, Figure 1 This is only an exemplary division method of the structure of the SQL statement management system 100. In actual applications, the SQL statement management system 100 may also have other division methods, which are not limited in this application. Figure 1 The structure shown is introduced.
[0046] As a possible implementation, Figure 3 As shown, when the SQL statement management system 100 is deployed in a data center, the SQL statement management system 100 can be provided to users as a cloud service based on the basic resources (including computing resources, storage resources, and network resources) provided by the data center. Users can register an account on the cloud management platform through a local client, log in to the cloud management platform through the account, and purchase the above cloud services on the cloud management platform. After the purchase is successful, the user can log in to the configuration interface provided by the control device 110 through the local client and operate on the above configuration interface. Subsequently, the control device 110 will instruct other parts of the SQL statement management system 100 to complete the management of SQL statements according to the user's operation.
[0047] Next, combine Figure 4 The flowchart of the SQL statement management method shown in the figure introduces the functions of the above-mentioned SQL statement management system 100 in more detail.
[0048] Step 101: The control device 110 receives a SQL information collection strategy.
[0049] The SQL information collection strategy may include the identifier of the database system 120, the identifier of the storage device 130, the time range for the storage device 130 to store the full amount of SQL information of the database system 120 (hereinafter referred to as the "first storage time range"), and the size of the shared memory 123. The identifier of the database system 120 may be the name, number, or other related information of the database system 120 that can identify the database system 120. Similarly, the identifier of the storage device 130 may be the Internet Protocol (IP) address, name, or other related information of the storage device 130 that can identify the storage device 130.
[0050] In a specific implementation, the control device 110 may provide a first configuration interface, which may be implemented through an application programming interface (API) or a graphical user interface (GUI). The user may configure the SQL information collection strategy on the first configuration interface, and accordingly, the control device 110 may receive the user's SQL information collection strategy through the above configuration interface.
[0051] For example, Figure 5 As shown, the first configuration interface includes an "on / off" option for full SQL information collection. When the user selects the "on" option for the database system 120, the first configuration interface also displays a "save time range" configuration box, a "storage device" configuration box, and a "shared memory" configuration box. The user can select a suitable save time range in the "save time range" configuration box, select a suitable storage device 130 in the "storage device" configuration box, and enter the size of the shared memory 123 in the "shared memory" configuration box according to business needs. After that, the user clicks the "confirm" option. As a result, the control device 110 can receive the user's SQL information collection strategy.
[0052] In step 102 , the control device 110 sends a SQL information collection command to the database system 120 according to the SQL information collection strategy. Accordingly, the database system 120 receives the SQL information collection command sent by the control device 110 .
[0053] The SQL information collection request is used to instruct to start the collection of the full amount of SQL information of the database system 120. The SQL information collection command may include the identifier of the storage device 130 and the size of the shared memory 123.
[0054] In the specific implementation, the control device 110 parses the SQL information collection strategy to obtain the identifier of the database system 120, the identifier of the storage device 130 and the size of the shared memory 123, and then generates an SQL information collection command according to the identifier of the storage device 130 and the size of the shared memory 123, and then sends the above-mentioned SQL information collection command to the database system 120 according to the identifier of the database system 120.
[0055] In step 103, the database system 120 performs a full SQL information collection operation according to the SQL information collection command, and sends the collected SQL information to the storage device 130. Accordingly, the storage device 130 receives and stores the SQL information sent by the database system 120.
[0056] In a specific implementation, the database system 120 obtains the identifier of the storage device 130 and the size of the shared memory 123 according to the SQL information collection command, then creates the shared memory 123 according to the size of the shared memory 123, and then writes the full amount of SQL information into the shared memory 123. Afterwards, the database system 120 sends the SQL information in the shared memory 123 to the storage device 130.
[0057] More specifically, the database system 120 can implement the above process through the following sub-steps: Step 103a: the proxy module 121 performs an initialization operation according to the SQL information collection command, and forwards the SQL information collection command to the database kernel 122. Accordingly, the database kernel 122 receives the SQL information collection command sent by the proxy module 121.
[0058] Step 103b: the database kernel 122 creates and configures the shared memory 123 according to the SQL information collection command.
[0059] In the specific implementation, the database kernel 122 obtains the size of the shared memory 123 according to the SQL information collection command, and then creates the shared memory 123 in the local memory according to the size of the shared memory 123, and then performs an initialization operation on the shared memory 123, and then configures the readable flag of the initialized shared memory 123 to be readable, so that the shared memory 123 is in a readable state.
[0060] Step 103c: when executing an SQL statement, the database kernel 122 writes the SQL information corresponding to the SQL statement into the shared memory 123. Accordingly, the shared memory 123 receives and stores the SQL information sent by the database kernel 122.
[0061] Step 103d: the proxy module 121 reads SQL information from the shared memory 123 .
[0062] In a specific implementation, the proxy module 121 determines that the shared memory 123 is currently in a readable state according to the readable flag bit of the shared memory 123 , and then reads the SQL information from the shared memory 123 .
[0063] As a possible implementation manner, the proxy module 121 may refresh the readable flag of the shared memory 123 at a preset time, and read the SQL information from the shared memory 123 when the readable flag of the shared memory 123 is readable.
[0064] Step 103e: the proxy module 121 sends the SQL information read above to the storage device 130. Accordingly, the storage device 130 receives and stores the SQL information sent by the proxy module 121.
[0065] In a specific implementation, the proxy module 121 obtains the identifier of the storage device 130 according to the SQL information collection command, and then writes the above-read SQL information into the storage device 130 according to the identifier of the storage device 130 .
[0066] As a possible implementation method, the proxy module 121 can write the above-read SQL information into the storage device 130 in an appending manner. The "appending" method here refers to adding the new SQL information to the existing SQL information of the storage device 130, so that the storage device 130 can obtain the full SQL information of the database system 120.
[0067] Furthermore, after the proxy module 121 sends the SQL information read from the shared memory 123 to the storage device 130, the proxy module 121 may also send a notification message to the database kernel 122, so that the database kernel 122 cleans up the SQL information in the shared memory 123 that has been sent to the storage device 130 by the proxy module 121. In this way, the resource occupation of the shared memory 123 can be saved.
[0068] Optionally, in order to improve the writing speed of SQL information and save resources occupied by the storage device 130, the proxy module 121 may also perform a format conversion operation (such as converting it into a binary file) on the SQL information read from the shared memory 123 before sending it to the storage device 130, and then send the format-converted SQL information to the storage device 130.
[0069] Step 104 : The control device 110 receives a SQL information parsing request.
[0070] In a specific implementation, the control device 110 provides a second configuration interface, which can be implemented through an API or a GUI. The user can configure the SQL information parsing request on the second configuration interface, and accordingly, the control device 110 can receive the user's SQL information parsing request through the second configuration interface. The SQL information parsing request may include an identifier of the database system 120 and a time period (hereinafter referred to as a "target time period") in which the SQL statement required by the user is located.
[0071] For example, Figure 6 As shown, the second configuration interface includes a "database system" configuration box and a "time" configuration box. The user can select the database system 120 in the "database system" configuration box and select the target time period in the "time" configuration box according to business needs. After that, the user clicks the "confirm" option. As a result, the control device 110 can receive the user's SQL information parsing request.
[0072] In step 105 , the control device 110 obtains the SQL information of the target time period from the storage device 130 according to the SQL information parsing request, and sends the SQL information of the target time period to the query device 140 . Accordingly, the query device 140 receives and stores the SQL information of the target time period sent by the control device 110 .
[0073] In a specific implementation, the control device 110 obtains the identifier and the target time period of the database system 120 by parsing the SQL information parsing request. After that, the control device 110 determines the identifier of the storage device 130 associated with the identifier of the database system 120, and then reads the SQL information of the target time period from the SQL information contained in the storage device 130, and then sends the SQL information of the target time period to the query device 140.
[0074] As can be seen from the foregoing, the SQL information in the storage device 130 may be SQL information after format conversion (such as a binary file). In this case, after the control device 110 reads the SQL information of the target time period from the storage device 130, it is necessary to parse the SQL information to obtain the SQL information before format conversion, and then send the parsed SQL information of the target time period to the query device 140.
[0075] Step 106 : The control device 110 receives the query condition.
[0076] In a specific implementation, the control device 110 provides a third configuration interface, which can be implemented through an API or a GUI. The user can provide query conditions to the control device 110 through the third configuration interface, and accordingly, the control device 110 can receive the user's query conditions through the third configuration interface. The query conditions refer to the conditions that the SQL information that the user wants to view satisfies.
[0077] Step 107 : The control device 110 reads SQL information satisfying the query condition from the query device 140 according to the query condition.
[0078] In a specific implementation, the control device 110 generates a query request by assembling query conditions, wherein the query request includes the query conditions. Afterwards, the control device 110 sends the query request to the query device 140, and the query device 140 can use a built-in query engine (such as an ES engine) to execute the query request after receiving the query request, and then determine the SQL information that meets the query conditions. Afterwards, the query device 140 returns the determined SQL information to the control device 110.
[0079] Step 108: The control device 110 displays the SQL information satisfying the query condition.
[0080] In a specific implementation, the control device 110 provides a display interface, which can be implemented through an API or a GUI. The control device 110 can display SQL information that meets the query conditions to the user through the above display interface, so that the user can analyze the above SQL information and determine the abnormality of the database system 120.
[0081] Step 109 : The control device 110 instructs the storage device 130 to clean up the locally stored SQL information.
[0082] As can be seen from the foregoing, the SQL information collection strategy includes a first storage time range, so the control device 110 can instruct the storage device 130 to clean up SQL information whose storage time exceeds the first storage time range.
[0083] Specifically, the control device 110 sends a first cleanup command including a first storage time range to the storage device 130. After receiving the first cleanup command, the storage device 130 scans the locally stored SQL information, determines the SQL information whose storage time exceeds the first storage time range, and then deletes the determined SQL information.
[0084] Furthermore, the control device 110 may perform this step periodically, thereby saving storage resources in the storage device 130 .
[0085] Step 110 , the control device 110 instructs the query device 140 to clean up the locally stored SQL information.
[0086] As can be seen from the foregoing, the SQL information parsing request may include a second storage time range, so the control device 110 may instruct the query device 140 to clean up the SQL information whose storage time exceeds the second storage time range.
[0087] Specifically, the control device 110 sends a second cleanup command including a second storage time range to the query device 140. After receiving the second cleanup command, the storage device 130 scans the locally stored SQL information, determines the SQL information whose storage time exceeds the second storage time range, and then deletes the determined SQL information.
[0088] Furthermore, the control device 110 may perform this step periodically, thereby saving storage resources in the query device 140 and improving the query efficiency of SQL information.
[0089] It can be seen from the above steps 101 to 110 that the SQL statement management method provided by the present application has the following advantages: First, the database system 120 can directly complete the collection of SQL statements and the execution information of SQL statements while executing SQL statements, and the collection process is simple and consumes less resources.
[0090] Secondly, the above solution not only collects all SQL statements of the database system 120, but also collects the execution information of all SQL statements, so that users can more accurately determine the abnormalities of the database system 120 by combining the full SQL statements of the database system 120 and the execution information of the full SQL statements.
[0091] Thirdly, the database system 120 will also write the SQL information in the shared memory 123 into the storage device 130 to achieve persistent storage. Since the cost of the storage device 130 is relatively low, the above solution can also save the cost of SQL information management.
[0092] Fourthly, the shared memory 123 can be flexibly configured by the user according to actual business needs, thereby ensuring the appropriate use of memory resources in the database system 120.
[0093] Fifthly, the above solution performs query of SQL information based on the query device 140 , which can improve the query efficiency of SQL information compared with directly querying SQL information in the storage device 130 .
[0094] Sixth, in the above solution, the user's operation is simple for the process of managing SQL statements, which improves the user experience.
[0095] The present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0096] like Figure 7 As shown, the computing device cluster includes at least one computing device 200. Each computing device 200 includes a bus 201, a processor 202, a memory 203, and a communication interface 204, wherein the processor 202, the memory 203, and the communication interface 204 communicate with each other through the bus 201. It should be understood that the present application does not limit the number of processors 202 and memories 203 in the computing device 200, that is, the computing device 200 may include one or more processors 202, and one or more memories 203, but for the convenience of description Figure 7 Only one processor 202 and one memory 203 are shown. The following describes each part of the computing device 200 in detail.
[0097] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 7 Although only one line is used in the figure, this does not mean that the computing device 200 has only one bus or one type of bus. The bus 201 may include a path for transmitting information between various components of the computing device 200 (eg, the processor 202, the memory 203, and the communication interface 204).
[0098] The processor 202 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0099] The memory 203 may include a volatile memory, such as a random access memory (RAM). The memory 203 may also include a non-volatile memory, such as a flash memory, a read-only memory (ROM), a hard disk drive (HDD), or a solid state drive (SSD).
[0100] The memory 203 stores executable codes. The processor 202 executes the codes stored in the memory 203 to respectively implement the functions of the control device 110, the database system 120, the storage device 130 and the query device 140, thereby implementing the above-mentioned SQL statement management method. In other words, the memory 203 stores instructions for executing the above-mentioned SQL statement management method.
[0101] The communication interface 204 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 200 and other devices or a communication network.
[0102] The memory 203 of one or more computing devices 200 in the computing device cluster may store the same instructions for executing the above-mentioned SQL statement management method.
[0103] In some possible implementations, the memory 203 of one or more computing devices 200 in the computing device cluster may also store partial instructions for executing the above-mentioned SQL statement management method. In other words, the combination of one or more computing devices 200 can jointly execute the instructions of the above-mentioned SQL statement management method.
[0104] It should be noted that the memory 203 in different computing devices 200 in the computing device cluster may store different instructions, which are respectively used to execute part of the functions of the SQL statement management system 100. That is, the instructions stored in the memory 203 in different computing devices 200 may implement the functions of one or more modules in the above-mentioned control device 110, database system 120, storage device 130 and query device 140.
[0105] In some possible implementations, one or more computing devices 200 in the computing device cluster may be connected via a network, which may be a wide area network or a local area network, etc. Figure 8 A possible implementation is shown. Figure 8As shown, the computing device 200A and the computing device 200B are connected via a network. Specifically, the computing device 200A and the computing device 200B are connected to the network via communication interfaces in the computing device 200A and the computing device 200B. In this implementation, the memory 203 of the computing device 200A may store instructions for implementing the functions of the control device 110, the storage device 130, and the query device 140, and the memory 203 of the computing device 200B may store instructions for implementing the functions of the database system 120.
[0106] Figure 8 The connection mode between the computing devices 200 in the computing device cluster shown may be that considering that the database system 120 needs to execute a large number of SQL statements, it is considered to hand over the functions implemented by the database system 120 to the computing device 200B for execution.
[0107] It should be understood that Figure 8 The functionality of the computing device 200A shown may also be performed by multiple computing devices 200. Similarly, the functionality of the computing device 200B may also be performed by multiple computing devices 200.
[0108] The present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device is caused to execute the SQL statement management method described above.
[0109] The present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device such as a data center that includes one or more available media. The above-mentioned available media may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the SQL statement management method described above.
[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, a person skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A structured query language SQL statement management method, characterized in that: The method comprises: The database system receives an SQL information collection command, wherein the SQL information collection command includes the size of the shared memory; The database system creates the shared memory according to the size of the shared memory; When executing an SQL statement, the database system writes SQL information corresponding to the SQL statement into the shared memory, wherein the SQL information includes the SQL statement and execution information of the SQL statement.
2. The method according to claim 1, characterized in that The SQL information collection command also includes an identifier of the storage device, and the method further includes: The database system reads SQL information from the shared memory; The database system writes the read SQL information into the storage device according to the identification of the storage device.
3. The method according to claim 2, characterized in that The storage device includes one or more of an object storage service OBS and a network attached storage NAS.
4. The method according to claim 3, characterized in that: Before the database system receives the SQL information collection command, the method further includes: The control device provides a first configuration interface, and receives a user's SQL information collection policy through the first configuration interface, wherein the SQL information collection policy includes the size of the shared memory and the identifier of the storage device; The control device generates the SQL information collection command according to the SQL information collection strategy, and sends the SQL information collection command to the database system.
5. The method according to claim 4, characterized in that The SQL information collection strategy also includes a first storage time range of the SQL information, and the method further includes: The control device instructs the storage device to clean up SQL information whose storage time exceeds the first storage time range.
6. The method according to claim 5, characterized in that After the database system writes the read SQL information into the storage device, the method further includes: The control device provides a second configuration interface, and receives a SQL information parsing request from the user through the second configuration interface, wherein the SQL information parsing request includes a target time period in which the SQL information required by the user is located; The control device obtains the SQL information of the target time period from the storage device, and sends the SQL information of the target time period to the query device; The control device provides a third configuration interface, and receives the query condition of the user through the third configuration interface; The control device reads the SQL information satisfying the query condition from the query device and displays the read SQL information.
7. The method according to claim 6, characterized in that The SQL information parsing request further includes a second storage time range of the SQL information, and the method further includes: The control device instructs the query device to clean up SQL information whose storage time exceeds the second storage time range.
8. A structured query language SQL statement management system, characterized in that: The system comprises: A control device, used for sending SQL information collection commands to the database system; A database system is used to receive the SQL information collection command, wherein the SQL information collection command includes the size of the shared memory; create the shared memory according to the size of the shared memory; when executing the SQL statement, write the SQL information corresponding to the SQL statement into the shared memory, wherein the SQL information includes the SQL statement and the execution information of the SQL statement.
9. The system according to claim 8, characterized in that The SQL information collection command also includes an identifier of the storage device; the system also includes the storage device; The database system is further configured to read SQL information from the shared memory and write the read SQL information into the storage device according to the identifier of the storage device; The storage device is used to store SQL information from the database system.
10. The system according to claim 9, characterized in that The storage device includes one or more of an object storage service OBS and a network attached storage NAS.
11. The system according to claim 10, characterized in that The control device is also used to provide a first configuration interface, receive a SQL information collection strategy provided by a user through the first configuration interface, and the SQL information collection strategy includes the size of the shared memory and the identifier of the storage device; and generate the SQL information collection command according to the SQL information collection strategy.
12. The system according to claim 11, characterized in that The SQL information collection strategy also includes a first storage time range for the SQL information; The control device is further used to instruct the storage device to clean up SQL information whose storage time exceeds the first storage time range.
13. The system according to claim 12, characterized in that The system also includes a query device; The control device is further configured to provide a second configuration interface, receive a SQL information parsing request from the user through the second configuration interface, the SQL information parsing request including a target time period in which the SQL information required by the user is located; obtain the SQL information of the target time period from the storage device, and send the SQL information of the target time period to the query device; Providing a third configuration interface, and receiving the user's query conditions through the third configuration interface; Reading SQL information satisfying the query condition from the query device, and displaying the read SQL information; The query device is used to receive the SQL information of the target time period; and return the SQL information that meets the query condition to the control device.
14. The system according to claim 13, characterized in that The SQL information parsing request also includes a second storage time range of the SQL information; The control device is further used to instruct the query device to clean up SQL information whose storage time exceeds the second storage time range.
15. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 7.
16. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 7.
17. A computer-readable storage medium, characterized in that: The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Information acquisition method and system of SQL (Structured Query Language) statement
CN105653647A
Autonomous transaction implementation method and system based on concurrent mechanism and application
CN114003353A
Database intelligent management method and device, equipment and storage medium
CN118585362A
Method for realing sharing internal stored data base and internal stored data base system
CN1740978A