CN112540897B - Database monitoring method, device, server and medium - Google Patents
Database monitoring method, device, server and medium Download PDFInfo
- Publication number
- CN112540897B CN112540897B CN202011445234.9A CN202011445234A CN112540897B CN 112540897 B CN112540897 B CN 112540897B CN 202011445234 A CN202011445234 A CN 202011445234A CN 112540897 B CN112540897 B CN 112540897B
- Authority
- CN
- China
- Prior art keywords
- statement
- determining
- execution
- stack frame
- database
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/301—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is a virtual computing platform, e.g. logically partitioned systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Computing Systems (AREA)
- Quality & Reliability (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a database monitoring method, a device, a server and a medium, comprising the following steps: when a target virtual machine operates, acquiring monitoring information of a database statement block corresponding to the target virtual machine; acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement; and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type. When the target virtual machine operates, the monitoring information, the instruction offset and the statement type obtained by the method can improve the efficiency of positioning the target statement with the longest execution time in the operation of the target virtual machine on the premise of reducing the operation quantity, and realize the rapid target positioning statement.
Description
Technical Field
The embodiment of the invention relates to a database technology, in particular to a database monitoring method, a database monitoring device, a server and a medium.
Background
The database system is a data management system commonly used by upper-layer applications, and the performance bottleneck problem of statement blocks is frequently encountered in the use process of the database system, so that statements with slower performance in the statement blocks are found out, and analysis and optimization are key to solving the performance bottleneck problem of the database system. For a single SQL statement, it can be split into multiple planning node operators, and then the time involved in the SQL statement operators is counted. However, this approach does not count the time of a particular statement block, where the statement block may include procedure/function calls, dynamic execution, SQL statements, and the like. Therefore, the slow sentence cannot be quickly found. The positioning of slow sentences in a database is still the first technical problem to be solved.
In the prior art, in order to record the execution time of a procedure/function call, an SQL statement or dynamic execution in a statement block, print time information by adding print in codes before and after the procedure/function call, the SQL statement or dynamic execution, thereby determining that the statement is executed slowly. The prior art is similar to dichotomy, and can record procedure/function calls, SQL statements or dynamic execution.
However, the operation amount of the prior art is large, the time spent in locating the slow sentence is long, and the technical problem of slow locating the sentence cannot be effectively solved.
Disclosure of Invention
The invention provides a database monitoring method, a database monitoring device, a server and a medium, which are used for realizing rapid positioning of sentences with longest execution time in the running of a virtual machine.
In a first aspect, an embodiment of the present invention provides a database monitoring method, including:
when a target virtual machine operates, acquiring monitoring information of a database statement block corresponding to the target virtual machine;
acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement;
and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type.
In a second aspect, an embodiment of the present invention further provides a database monitoring apparatus, including:
the first execution module is used for acquiring monitoring information of a database statement block corresponding to a target virtual machine when the target virtual machine runs;
the second execution module is used for acquiring instruction offset and statement types of the statements contained in the database statement block, wherein the database statement block comprises at least one statement;
and the determining module is used for determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type.
In a third aspect, an embodiment of the present invention further provides a server, where the server includes:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the database monitoring method as described in the first aspect.
In a fourth aspect, embodiments of the present invention also provide a storage medium containing computer-executable instructions which, when executed by a computer processor, are used to perform the database monitoring method according to the first aspect.
The method comprises the steps of obtaining monitoring information of a database statement block corresponding to a target virtual machine when the target virtual machine runs; acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement; and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type. According to the database monitoring method provided by the invention, the monitoring information of the database statement block, the instruction offset and the statement type of the statement contained in the database statement block are sequentially obtained, the execution time of a specific statement is determined, and the target statement with the longest execution time in the target virtual machine is determined according to the execution time, so that the problem that the prior art needs to print time information by adding print in codes before and after procedure/function call, SQL statement or dynamic execution is solved, the target statement with the longest execution time in the target virtual machine is further determined, and the efficiency of determining the target statement with the longest execution time in the target virtual machine is improved.
Drawings
FIG. 1 is a flowchart of a database monitoring method according to a first embodiment of the present invention;
FIG. 2a is a diagram illustrating an example of a relationship between a first caller 210a and a first callee 220a in a stack frame of a procedure/function call in a database monitoring method according to an embodiment of the present invention;
FIG. 2b is a diagram illustrating a relationship example of a second caller 210b, a second callee 220b, and a second real callee 230b in a stack frame of an SQL statement and a third caller 210c, a third callee 220c, and a third real callee 230c in a stack frame that is dynamically executed in a database monitoring method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a database monitoring method according to a second embodiment of the present invention;
FIG. 4a is a diagram illustrating an example of an instruction offset in a calling procedure/function in a database monitoring method according to a second embodiment of the present invention;
FIG. 4b is a diagram illustrating an instruction offset in SQL statements in a database monitoring method according to a second embodiment of the present invention;
FIG. 4c is a diagram illustrating an example of an instruction offset in dynamic execution in a database monitoring method according to a second embodiment of the present invention;
fig. 5 is a block diagram of a database monitoring device according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of a server according to a fourth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like. Furthermore, embodiments of the invention and features of the embodiments may be combined with each other without conflict.
The database core execution engine may include a virtual machine that may execute a block of database statements that generated an execution plan. When the virtual machine executes the database statement block, a target virtual machine can be generated, and the target virtual machine can be executed according to the instruction of the execution plan. The virtual machine may include an address space, and when a plurality of database statement blocks are concurrent, each database statement block has a corresponding virtual machine, and instructions included in the database statement blocks may be executed sequentially.
In addition, the instruction can be addressed from 0 address, a stack frame structure can be generated in the execution process of the instruction, the stack frame can be used for forming different kinds of data block sentences, and the stack frame can also be used for storing a recording unit of related information related to calling when a virtual machine executing Method (MTEHOD) is carried out. The current stack frame can be the stack frame currently used when the virtual machine runs, and all stack frames are strung together to form a complete stack of the virtual machine. Of course, procedure/function calls, SQL statements, and dynamic execution may be contained in one total stack frame, which may be the largest stack frame.
Example 1
Fig. 1 is a flowchart of a database monitoring method according to an embodiment of the present invention, where the method may be applied to a situation that a target virtual machine needs to quickly find a target statement with a longest execution time when running, and the method may be executed by a server, and specifically includes the following steps:
and 110, when the target virtual machine operates, acquiring monitoring information of a database statement block corresponding to the target virtual machine.
Specifically, when the database statement block is executed in the target virtual machine, the monitoring information of the execution process of the database statement block can be obtained based on the target virtual machine, the monitoring information can include the execution time of the database statement block, and the database statement block with longer execution time can be found out when the virtual machine runs according to the execution time. The execution time of the database statement block may also be obtained during the instruction generation process.
Wherein, the statement block is a basic unit for composing PL/SQL, and the statement block can comprise: a. dynamically executing SQL, wherein the statement in the dynamic execution is SQL; SQL, in this embodiment SQL statements may refer broadly to common static SQL statements; c. function/procedure call statements. In addition, the statement block may also include other statement types of PL/SQL, such as flow control statements, e.g., if statements and case statements.
The execution time may include a time from a start to an end of the execution of the database statement block, in particular, in a procedure/function call, the execution time may be a time from a start of a stack frame to an end of the stack frame; in the SQL sentence, the execution time can be the time from the start of creating the SQL sentence execution plan tree to the release; in dynamic execution, when executing multiple statements, the statement time sum of generating new stack frame statistics may be the execution time.
The virtual machine can execute the database statement block, so that the execution time can be counted on the structure of the execution engine from the entrance of the execution engine for the database statement block.
The monitoring information may also include an execution number, caller information, and a current method name, and the execution number may be an execution number of a statement included in the database statement block.
In addition, fig. 2a is a diagram illustrating a relationship between a first caller 210a and a first callee 220a in a stack frame of a procedure/function call in a database monitoring method according to an embodiment of the present invention, fig. 2b is a diagram illustrating a relationship between a second caller 210b, a second callee 220b, a second real callee 230b and a third caller 210c, a third callee 220c, and a third real callee 230c in a stack frame of an SQL statement in a database monitoring method according to an embodiment of the present invention, where, as shown in fig. 2a, the first caller 210a in the stack frame of the procedure/function call includes a first instruction sequence, and the first callee 220a includes a second instruction sequence, and the first instruction sequence may be invoked during the execution of the first instruction sequence. As shown in fig. 2b, the second caller 210b in the stack frame of the SQL statement includes a third instruction sequence, the second callee 220b includes a fourth instruction sequence, the second real caller 230b includes a fifth instruction sequence, the fourth instruction sequence may be invoked during execution of the fifth instruction sequence, and the third instruction sequence may be invoked during execution of the fourth instruction sequence. The third caller 210c in the stack frame of the dynamic execution includes a sixth instruction sequence, the third callee 220c includes a seventh instruction sequence, the third real caller 230c includes an eighth instruction sequence, the seventh instruction sequence may be invoked during execution of the eighth instruction sequence, and the sixth instruction sequence may be invoked during execution of the seventh instruction sequence.
Step 120, obtaining instruction offset and statement type of the statement contained in the database statement block, wherein the database statement block comprises at least one statement.
Specifically, after the monitoring information of the database statement block is acquired, the execution time of the specific statement in the database statement block cannot be determined, so that the instruction offset and the statement type of the statement contained in the database statement block can be acquired again. The instruction offset and the statement type can relocate the statement contained in the database statement block, and further determine the target statement with the longest execution time in the running process of the virtual machine.
The instruction offset may include an order of execution of different database statement blocks in the same stack frame, procedure/function calls in the same stack frame, or an order of dynamic execution in the same stack frame, among other things. Statement types may include METHOD, SQL statements, and DYNAMIC SQL statements.
And if the plan of the statement of the database statement block is dynamic execution, determining that the statement type is dynamic execution.
And if the plan of the statement of the database statement block is a function and a procedure call, determining that the statement type is the function procedure call.
If the plan of the statement of the database statement block is an SQL statement, determining that the statement type is an SQL statement type.
And 130, determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type.
Specifically, after the monitoring information, the instruction offset and the sentence type are acquired, the information may be respectively displayed in a preset display screen, and based on the display screen information, the execution time of the sentence is compared, and the sentence with the longest execution time is found out.
According to the technical scheme, when the target virtual machine runs, monitoring information of a database statement block corresponding to the target virtual machine is obtained; acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement; and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type. When the target virtual machine operates, the monitoring information, the instruction offset and the statement type obtained by the method can improve the efficiency of positioning the target statement with the longest execution time in the operation of the target virtual machine on the premise of reducing the operation quantity, and realize the rapid target positioning statement.
Example two
Fig. 3 is a flowchart of a database monitoring method according to a second embodiment of the present invention, where the method is implemented on the basis of the foregoing embodiments. In this embodiment, the method may further include:
and 310, acquiring monitoring information of a database statement block corresponding to the target virtual machine when the target virtual machine operates.
It is appreciated that the database statement block may include procedure/function calls, SQL statements, and dynamic executions, and the monitoring information may include the execution number, caller information, current method name, and execution time of the database statement block.
In one embodiment, if the database statement block includes a procedure/function call, step 310 may include:
and determining the execution number corresponding to the first target virtual machine as a first execution number.
And determining the current method name of the first current stack frame corresponding to the first target virtual machine as the first current method name.
It can be known that the execution sequence of the procedure/function call is that the previous stack frame (caller) is not finished, a new stack frame (callee) is generated first, and the previous stack frame is finished after the new stack frame is finished. The first layer stack frame is the total METHOD, the execution level of the first layer total METHOD is 0, and each layer of calling relation is added, the execution level of the METHOD is added by 1. If the database statement block circularly calls the preset process/function, the stack frame address of the process/function is repeated and can be reused, and the process/function calling different methods can add a stack frame behind the stack frame linked list.
Specifically, in the process of executing the procedure/function call instruction, parameters of the procedure/function call may be pressed into an instruction stream of the virtual machine, then a stack frame is created, execution information such as a method name and the like is recorded on the stack frame, the stack frame is added to a stack frame linked list of the virtual machine when the stack frame is created, and the creation time before the procedure/function call is executed is registered in the stack frame. Specifically, it can be known that when the database statement block includes a procedure/function call, the execution number of the first current stack frame corresponding to the first target virtual machine is the first execution number, and the method name of the first current stack frame is the first current method name.
And determining a first previous stack frame corresponding to the first current stack frame as first caller information.
Specifically, in the procedure/function call, the caller is the previous stack frame of the first current stack frame, i.e. the first previous stack frame can be determined as the first caller information.
In addition, when the process/function is nested non-recursive call, the first current method name and the first caller information change with a change in call order; when a procedure/function is invoked by nested recursion, the instruction offset, statement type, first current method name, and first caller are consistent with the procedure/function call.
When a procedure/function is recursively invoked in a nested manner, the hierarchy monitoring may represent the hierarchy of the stack frame, and the hierarchy of the function/procedure call may be the current length of the stack frame linked list. In addition, the second current stack frame of the SQL statement comprises hierarchy information, and the hierarchy of dynamic execution is different from the hierarchy of the outer layer function/procedure call.
A first execution time is determined based on creating an end and start time difference for the first current stack frame.
Specifically, during the execution of the virtual machine, when creating a stack frame, the start time is registered, and when executing the end clearing stack frame, the end time is registered, and the end time minus the start time is the execution time of the procedure/function call.
If the database statement block includes an SQL statement, step 310 includes:
and determining the execution number corresponding to the second target virtual machine as a second execution number.
And determining the current method name of the second last stack frame corresponding to the second target virtual machine as the second current method name.
Execution of the statement may be accomplished through a statement execution tree. The statement execution tree may be created at the beginning of the statement execution and released at the end of the statement execution. The context of the statement execution tree is one context generated in the virtual machine instruction, and may be a plan tree including a plurality of statement plan nodes.
No new stack frame is generated in the execution process of the SQL statement, and the new stack frame is already contained in the previous stack frame. The second caller information and the second current method name are the same as the last stack frame. For example, a contains an SQL statement. If the METHOD name of A is METHOD_A, the second caller information of the SQL statement and the second current METHOD name are both METHOD_A, and the second caller information of the SQL statement and the second current METHOD name are consistent with the caller of the METHOD and the METHOD name, but are different in type.
And determining the second previous stack frame as second caller information.
The specific manner of determining caller information is not described herein.
And determining a second execution time based on releasing and creating a time difference value of the SQL statement corresponding to the SQL statement execution tree.
The creation time may be recorded when the SQL statement execution tree starts to be created. When the SQL statement execution tree is released, the release time can be recorded, and then the release time minus the creation time can obtain the execution time of the SQL statement.
If the database statement block includes dynamic execution, step 310 includes:
and determining the execution number corresponding to the third target virtual machine as a third execution number.
And determining the name of the caller method of the third last stack frame corresponding to the third target virtual machine as the name of the third current method.
Dynamic execution may be registered twice, once for dynamic execution and once for dynamic execution of the PL/SQL statement, SQL statement or function/procedure contained.
Specifically, since the dynamic execution itself has no method name, the method name of the previous stack frame may be taken as the third current method name. The third caller, the third callee, and the third current method name are all consistent with the last stack frame to find duplicate entries.
When the repeated execution is dynamically executed, the monitoring information of the repeated execution can be kept consistent.
And determining the third previous stack frame as third caller information.
For example, E contains a dynamic SQL statement. Assuming that the METHOD name of E is METHOD_E, then both E and the dynamically executed caller information are METHOD_E.
And determining a third execution time based on the time difference value of deleting and generating the third current stack frame in the dynamic execution.
Dynamic execution generates a new stack frame within which the SQL statement execution tree portion is generated. The dynamic execution starts from the nexe_exec instruction to create a new stack frame, at this time, the generation time of the dynamic execution is recorded, and when the newly generated stack frame is deleted, the deletion time of the dynamic execution is recorded, and the deletion time minus the generation time is the execution time of the dynamic execution.
In one embodiment, when the procedure/function call includes at least one statement,
the step of determining a first execution time based on creating an end and start time difference of the first current stack frame comprises:
determining a first current execution time according to the difference value between the ending time and the starting time of the first current stack frame;
determining the execution times of the process/function call according to the same monitoring information, the same instruction offset and the same hierarchy information;
and determining the first execution time according to the first current execution time and the process/function call execution times.
When the dynamic execution includes at least one statement, determining a third execution time based on a time difference of deleting and generating the third current stack frame in the dynamic execution, including:
determining a third current execution time according to the difference value between the time information of deleting the third current stack frame in the dynamic execution and the time information of generating the third current stack frame;
determining the execution times of dynamic execution according to the monitoring items except time in the monitoring information;
and determining the third execution time according to the third current execution time and the execution times of the dynamic execution.
Specifically, if the virtual machine does not execute the same procedure/function call, the same SQL statement or the same dynamic execution in a nested and recurring manner, the execution time is further determined according to the determined first execution time, second execution time or third execution time and the number of execution times.
Step 320, obtaining instruction offset and statement type of the statement contained in the database statement block, wherein the database statement block comprises at least one statement.
And determining the instruction offset of the statement according to the execution sequence of the statement contained in the database statement block.
The instruction offset may include the order of execution of different monitor objects in the same stack frame, procedure/function calls in the same stack frame, or the order of dynamic execution in the same stack frame. Different monitoring objects of the same type refer to that the multiple sentences are of SQL sentence type, procedure/function call type or dynamic execution type.
In one embodiment, if the database statement block includes a procedure/function call, determining an instruction offset of the statement according to an execution order of the statement included in the database statement block includes:
and determining the ending instruction address of the first current stack frame to the starting instruction address of the first previous stack frame as the instruction offset of the process/function call.
Specifically, fig. 4a is an exemplary diagram of an instruction offset in a calling process/function in the database monitoring method according to the second embodiment of the present invention, as shown in fig. 4a, when the calling process/function is performed, the first caller 410a may call the first callee 420a, ip of the target virtual machine (vm) is callfrm- > ip_base, and after the calling function generates a new stack frame of the called function, an instruction of the new stack frame is executed. After the call ends, vm_ip points to curfrm_ret_ip. The instruction offset of the procedure/function call is curfrrm- > ret_ip-callfrm- > ip_base. curfrm may be the first current stack frame, i.e., the caller stack frame. callfrm may be the first last stack frame, i.e., the callee stack frame. In addition, when a process/function is called multiple times, the instruction offset also changes with the change in the calling order.
For example, when the caller and callee relationship changes, the pointing object of the instruction offset also changes.
In one embodiment, if the database statement block includes an SQL statement, the step of determining an instruction offset of the statement according to an execution order of the statement included in the database statement block includes:
and determining the interrupt address of the second target virtual machine to the initial instruction address of the second current stack frame as the instruction offset of the statement.
Specifically, fig. 4b is an exemplary diagram of instruction offset in a statement in the database monitoring method according to the second embodiment of the present invention, as shown in fig. 4b, for members of a statement tree: the interrupt position of the current virtual machine, i.e. the current vm execution instruction address, is noted from the initial instruction address org_pl_cmd. When the virtual machine is interrupted, the executed instruction is dop_sql. The initial ip address is curfrrm- > ip_base, the offset when the tree destruction is executed is nsql_vm- > org_pl_cmd, so the offset of the sentence can be nsql_vm- > org_pl_cmd-currfrm- > ip_base, which is different from the process/function call, and the second current stack frame is not generated, so the registration of ret_ip is not needed. The instruction offset of the statement may be the location of the virtual machine interrupt-the starting location of the second current stack frame. In addition, the sentences in the database sentence blocks are ordered by sentence NO.
In one embodiment, if the database statement block includes dynamic execution, the step of determining an instruction offset of the statement according to an execution order of the statement included in the database statement block includes:
and determining the ending instruction address of the third current stack frame to the starting instruction address of the third previous stack frame as the instruction offset of the dynamic execution.
Specifically, fig. 4c is an exemplary diagram of an instruction offset in dynamic execution in the database monitoring method according to the second embodiment of the present invention, as shown in fig. 4c, in the dynamic execution, the third caller 410c may call the third callee 420c, and the instruction offset in dynamic execution may be consistent with the instruction offset of the procedure/function call in which the dynamic execution is performed.
If the database statement block includes at least one procedure/function call, SQL statement, and dynamic execution, the statement type may include at least one of METHID, SQL statement, and DYNAMIC SQL statement.
And if the plan of the statement of the database statement block is dynamic execution, determining that the statement type is dynamic execution.
And if the plan of the statement of the database statement block is a function and a procedure call, determining that the statement type is the function procedure call.
If the plan of the statement of the database statement block is an SQL statement, determining that the statement type is an SQL statement type.
And 330, determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type.
And controlling a preset window to display the monitoring information, the instruction offset and the statement type.
Specifically, the execution number, caller information, current method name, execution time, instruction offset, and statement type may be presented in a preset window.
And determining a target statement with the longest execution time in the running of the target virtual machine according to the execution time of the statement in the statement block of the database in the preset window display information.
Specifically, the execution time in the preset window display information is checked, so that a target sentence with the longest execution time in the running process of the target virtual machine can be determined.
And step 340, after the target virtual machine is operated, correspondingly caching the monitoring information, the instruction offset and the statement type into a monitoring cache table.
Specifically, after the target virtual machine is operated, the monitoring information, the instruction offset and the statement type of the corresponding database statement block can be cached in the monitoring cache table.
According to the technical scheme, when the target virtual machine runs, monitoring information of a database statement block corresponding to the target virtual machine is obtained; acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement; and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type. And after the target virtual machine is operated, correspondingly caching the monitoring information, the instruction offset and the statement type into a monitoring cache table. According to the database monitoring method provided by the invention, the monitoring information of the database statement block, the instruction offset and the statement type of the statement contained in the database statement block are sequentially obtained, the execution time of a specific statement is determined, and the target statement with the longest execution time in the target virtual machine is determined according to the execution time, so that the problem that the prior art needs to print time information by adding print in codes before and after procedure/function call, SQL statement or dynamic execution is solved, the target statement with the longest execution time in the target virtual machine is further determined, and the efficiency of determining the target statement with the longest execution time in the target virtual machine is improved.
Example III
Fig. 5 is a block diagram of a database monitoring device according to a third embodiment of the present invention, where the device may be adapted to a server, so as to improve efficiency of the server in determining a target SQL statement with a longest execution time in a running process of a target virtual machine. The apparatus may be implemented in software and/or hardware and is typically integrated in a server.
As shown in fig. 5, the apparatus includes:
the first execution module 510 is configured to obtain monitoring information of a database statement block corresponding to a target virtual machine when the target virtual machine is running;
a second execution module 520, configured to obtain an instruction offset and a statement type of a statement included in the database statement block, where the database statement block includes at least one statement;
and the determining module 530 is configured to determine, according to the monitoring information, the instruction offset, and the statement type, a target statement with a longest execution time in the running of the target virtual machine.
According to the database monitoring device provided by the embodiment, when the target virtual machine operates, monitoring information of a database statement block corresponding to the target virtual machine is obtained; acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement; and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type. When the target virtual machine operates, the monitoring information, the instruction offset and the statement type obtained by the method can improve the efficiency of positioning the target statement with the longest execution time in the operation of the target virtual machine on the premise of reducing the operation quantity, and realize the rapid target positioning statement.
On the basis of the above embodiment, if the database statement block includes a procedure/function call, the first execution module 510 is specifically configured to:
determining an execution number corresponding to the first target virtual machine as a first execution number;
determining a current method name of a first current stack frame corresponding to a first target virtual machine as a first current method name;
determining a first previous stack frame corresponding to the first current stack frame as first caller information;
a first execution time is determined based on creating an end and start time difference for the first current stack frame.
On the basis of the above embodiment, if the database statement block includes an SQL statement, the first execution module 510 is specifically configured to:
determining an execution number corresponding to the second target virtual machine as a second execution number;
determining the current method name of the second last stack frame corresponding to the second target virtual machine as a second current method name;
determining the second previous stack frame as second caller information;
and determining a second execution time based on releasing and creating a time difference value of the SQL statement corresponding to the SQL statement execution tree.
On the basis of the above embodiment, if the database statement block includes dynamic execution, the first execution module 510 is specifically configured to:
Determining an execution number corresponding to the third target virtual machine as a third execution number;
determining the name of a caller method of a third previous stack frame corresponding to a third target virtual machine as a third current method name;
determining the third previous stack frame as third caller information;
and determining a third execution time based on the time difference value of deleting and generating the third current stack frame in the dynamic execution.
In one embodiment, when the procedure/function call includes at least one statement,
determining a first execution time based on creating an end and start time difference for the first current stack frame, comprising:
determining a first current execution time according to the difference value between the ending time and the starting time of the first current stack frame;
determining the execution times of the process/function call according to the same monitoring information, the same instruction offset and the same hierarchy information;
determining the first execution time according to the first current execution time and the process/function call execution times;
when the dynamic execution includes at least one statement,
determining a third execution time based on the time difference of deleting and generating the third current stack frame in the dynamic execution, including:
Determining a third current execution time according to the difference value between the time information of deleting the third current stack frame in the dynamic execution and the time information of generating the third current stack frame;
determining the execution times of dynamic execution according to the monitoring items except time in the monitoring information;
and determining the third execution time according to the third current execution time and the execution times of the dynamic execution.
Based on the above embodiment, the second execution module 520 is specifically configured to:
determining instruction offset of the statement according to the execution sequence of the statement contained in the database statement block;
and determining the statement type according to the plan type of the database statement block.
In one embodiment, if the database statement block includes a procedure/function call, determining the instruction offset and the statement type of the statement includes:
determining an ending instruction address of a first current stack frame to a starting instruction address of a first previous stack frame as an instruction offset of the procedure/function call;
and if the plan of the statement of the database statement block is a function or a procedure call, determining the statement type as the function/procedure call.
In one embodiment, if the database statement block includes an SQL statement, determining an instruction offset and a statement type of the statement includes:
determining the interrupt address of the second target virtual machine to the initial instruction address of the second current stack frame as the instruction offset of the SQL sentence;
and if the plan of the statement of the database statement block is an SQL statement, determining that the statement type is the SQL statement type.
In one embodiment, if the database statement block includes dynamic execution, determining an instruction offset and a statement type of the statement includes:
determining the ending instruction address of the third current stack frame to the starting instruction address of the third previous stack frame as the dynamically executed instruction offset;
and if the plan of the statement of the database statement block is dynamic execution, determining the statement type as dynamic execution.
Based on the above embodiment, the determining module 530 is specifically configured to:
controlling a preset window to display the monitoring information, the instruction offset and the statement type;
and determining a target statement with the longest execution time in the running of the target virtual machine according to the execution time of the statement in the statement block of the database in the preset window display information.
On the basis of the above embodiment, the apparatus may further include:
and the caching module is used for correspondingly caching the monitoring information, the instruction offset and the statement type into a monitoring cache table after the operation of the target virtual machine is finished.
The database monitoring device provided by the embodiment of the invention can execute the database monitoring method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 6 is a schematic structural diagram of a server according to a fourth embodiment of the present invention, and as shown in fig. 6, the server includes a processor 610 and a memory 620; the number of processors 610 in the server may be one or more, one processor 610 being taken as an example in fig. 6; the processor 610 and the memory 620 in the server may be connected by a bus or other means, for example in fig. 6.
The memory 620 serves as a computer-readable storage medium, and may be used to store software programs, computer-executable programs, and modules, such as modules corresponding to the database monitoring method in the embodiment of the present invention (e.g., the first execution module 510, the second execution module 520, and the determination module 530 in the database monitoring device).
Memory 620 may include primarily a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application program required for functionality; the storage data area may store data created according to the use of the terminal, etc. In addition, memory 620 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 620 may further include memory remotely located with respect to processor 610, which may be connected to the server via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The server provided by the embodiment of the invention can execute the database method provided by the embodiment of the invention, and has corresponding functions and beneficial effects.
Example five
A fifth embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing a database monitoring method, the method comprising:
When a target virtual machine operates, acquiring monitoring information of a database statement block corresponding to the target virtual machine;
acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement;
and determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present invention is not limited to the method operations described above, and may also perform the related operations in the database monitoring method provided in any embodiment of the present invention.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the above-mentioned embodiments of the search apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, as long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.
Claims (8)
1. A method of database monitoring, comprising:
when a target virtual machine operates, acquiring monitoring information of a database statement block corresponding to the target virtual machine;
Acquiring instruction offset and statement types of statements contained in the database statement block, wherein the database statement block comprises at least one statement;
determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type;
the database statement block comprises a procedure/function call, an SQL statement and dynamic execution, the monitoring information comprises an execution number, caller information, a current method name and an execution time of the database statement block,
if the database statement block includes a procedure/function call, when the target virtual machine operates, acquiring monitoring information of the database statement block corresponding to the target virtual machine includes:
determining an execution number corresponding to the first target virtual machine as a first execution number;
determining a current method name of a first current stack frame corresponding to a first target virtual machine as a first current method name;
determining a first previous stack frame corresponding to the first current stack frame as first caller information;
determining a first execution time based on creating an end and start time difference value for the first current stack frame;
if the database statement block includes an SQL statement, when the target virtual machine operates, acquiring monitoring information of the database statement block corresponding to the target virtual machine includes:
Determining an execution number corresponding to the second target virtual machine as a second execution number;
determining the current method name of the second last stack frame corresponding to the second target virtual machine as a second current method name; wherein, no new stack frame is generated in the execution process of SQL sentence, and the new stack frame is contained in the previous stack frame, and the method name of the second previous stack frame is determined as the method name of the second current stack frame;
determining the second previous stack frame as second caller information;
determining a second execution time based on releasing and creating a time difference value of the SQL sentence execution tree corresponding to the SQL sentence;
if the database statement block includes dynamic execution, when the target virtual machine operates, acquiring monitoring information of the database statement block corresponding to the target virtual machine includes:
determining an execution number corresponding to the third target virtual machine as a third execution number;
determining the current method name of a third previous stack frame corresponding to the third target virtual machine as a third current method name; dynamically executing the method without a method name, and taking the method name of the third last stack frame as the current method name;
determining the third previous stack frame as third caller information;
Determining a third execution time based on the time difference of deleting and generating the third current stack frame in the dynamic execution;
and determining a target statement with the longest execution time in the running of the target virtual machine according to the monitoring information, the instruction offset and the statement type, wherein the determining comprises the following steps:
controlling a preset window to display the monitoring information, the instruction offset and the statement type;
and determining a target statement with the longest execution time in the running of the target virtual machine according to the execution time of the statement in the statement block of the database in the preset window display information.
2. The method for monitoring a database according to claim 1, wherein,
when the procedure/function call includes at least one statement,
determining a first execution time based on creating an end and start time difference for the first current stack frame, comprising:
determining a first current execution time according to the difference value between the ending time and the starting time of the first current stack frame;
determining the execution times of the process/function call according to the same monitoring information, the same instruction offset and the same hierarchy information; the hierarchical information is the current length of a stack frame linked list;
Determining the first execution time according to the first current execution time and the process/function call execution times;
when the dynamic execution includes at least one statement,
determining a third execution time based on the time difference of deleting and generating the third current stack frame in the dynamic execution, including:
determining a third current execution time according to the difference value between the time information of deleting the third current stack frame in the dynamic execution and the time information of generating the third current stack frame;
determining the execution times of dynamic execution according to the monitoring items except time in the monitoring information;
and determining the third execution time according to the third current execution time and the execution times of the dynamic execution.
3. The method of claim 1, wherein obtaining the instruction offset and the statement type of the statement contained in the database statement block comprises:
determining instruction offset of the statement according to the execution sequence of the statement contained in the database statement block;
and determining the statement type according to the plan type of the database statement block.
4. A method for monitoring a database according to claim 3,
If the database statement block includes a procedure/function call, determining an instruction offset and a statement type of the statement includes:
determining an ending instruction address of a first current stack frame to a starting instruction address of a first previous stack frame as an instruction offset of the procedure/function call;
if the plan of the statement of the database statement block is a function and a procedure call, determining the statement type as a function/procedure call;
if the database statement block comprises an SQL statement, determining the instruction offset and the statement type of the statement comprises:
determining the interrupt address of the second target virtual machine to the initial instruction address of the second current stack frame as the instruction offset of the SQL sentence;
if the plan of the statement of the database statement block is an SQL statement, determining that the statement type is an SQL statement type;
if the database statement block comprises dynamic execution, determining the instruction offset and the statement type of the statement comprises:
determining the ending instruction address of the third current stack frame to the starting instruction address of the third previous stack frame as the dynamically executed instruction offset;
and if the plan of the statement of the database statement block is dynamic execution, determining the statement type as dynamic execution.
5. The database monitoring method according to claim 1, further comprising, after determining a target statement having a longest execution time in the target virtual machine run based on the monitoring information, the instruction offset, and the statement type:
and after the target virtual machine is operated, correspondingly caching the monitoring information, the instruction offset and the statement type into a monitoring cache table.
6. A database monitoring apparatus, comprising:
the first execution module is used for acquiring monitoring information of a database statement block corresponding to a target virtual machine when the target virtual machine runs;
the second execution module is used for acquiring instruction offset and statement types of the statements contained in the database statement block, wherein the database statement block comprises at least one statement;
the determining module is used for determining a target statement with the longest execution time in the running process of the target virtual machine according to the monitoring information, the instruction offset and the statement type;
if the database statement block includes a procedure/function call, the first execution module is specifically configured to:
determining an execution number corresponding to the first target virtual machine as a first execution number;
Determining a current method name of a first current stack frame corresponding to a first target virtual machine as a first current method name;
determining a first previous stack frame corresponding to the first current stack frame as first caller information;
determining a first execution time based on creating an end and start time difference value for the first current stack frame;
if the database statement block includes an SQL statement, the first execution module is specifically configured to:
determining an execution number corresponding to the second target virtual machine as a second execution number;
determining the current method name of the second last stack frame corresponding to the second target virtual machine as a second current method name; wherein, no new stack frame is generated in the execution process of SQL sentence, and the new stack frame is contained in the previous stack frame, and the method name of the second previous stack frame is determined as the method name of the second current stack frame;
determining the second previous stack frame as second caller information;
determining a second execution time based on releasing and creating a time difference value of the SQL sentence execution tree corresponding to the SQL sentence;
if the database statement block includes dynamic execution, the first execution module is specifically configured to:
determining an execution number corresponding to the third target virtual machine as a third execution number;
Determining the current method name of a third previous stack frame corresponding to the third target virtual machine as a third current method name; dynamically executing the method without a method name, and taking the method name of the third last stack frame as the current method name;
determining the third previous stack frame as third caller information;
determining a third execution time based on the time difference of deleting and generating the third current stack frame in the dynamic execution;
the determining module is specifically configured to:
controlling a preset window to display the monitoring information, the instruction offset and the statement type;
and determining a target statement with the longest execution time in the running of the target virtual machine according to the execution time of the statement in the statement block of the database in the preset window display information.
7. A server, the server comprising:
one or more processors;
a storage means for storing one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the database monitoring method of any of claims 1-5.
8. A storage medium containing computer executable instructions which, when executed by a computer processor, are for performing the database monitoring method of any of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011445234.9A CN112540897B (en) | 2020-12-08 | 2020-12-08 | Database monitoring method, device, server and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011445234.9A CN112540897B (en) | 2020-12-08 | 2020-12-08 | Database monitoring method, device, server and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112540897A CN112540897A (en) | 2021-03-23 |
CN112540897B true CN112540897B (en) | 2023-08-25 |
Family
ID=75018312
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011445234.9A Active CN112540897B (en) | 2020-12-08 | 2020-12-08 | Database monitoring method, device, server and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112540897B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106157129A (en) * | 2015-04-17 | 2016-11-23 | 阿里巴巴集团控股有限公司 | One realizes distributed system across time domain coherence method and device |
CN108664359A (en) * | 2018-05-23 | 2018-10-16 | 上海达梦数据库有限公司 | A kind of database restoring method, device, equipment and storage medium |
CN110297814A (en) * | 2019-05-22 | 2019-10-01 | 中国平安人寿保险股份有限公司 | Method for monitoring performance, device, equipment and the storage medium of database manipulation |
CN110866031A (en) * | 2019-11-08 | 2020-03-06 | 中国工商银行股份有限公司 | Database access path optimization method and device, computing equipment and medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10649987B2 (en) * | 2017-01-31 | 2020-05-12 | Salesforce.Com, Inc. | Systems, methods, and apparatuses for implementing conditional statement execution within a multi-tenant aware structured query language |
-
2020
- 2020-12-08 CN CN202011445234.9A patent/CN112540897B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106157129A (en) * | 2015-04-17 | 2016-11-23 | 阿里巴巴集团控股有限公司 | One realizes distributed system across time domain coherence method and device |
CN108664359A (en) * | 2018-05-23 | 2018-10-16 | 上海达梦数据库有限公司 | A kind of database restoring method, device, equipment and storage medium |
CN110297814A (en) * | 2019-05-22 | 2019-10-01 | 中国平安人寿保险股份有限公司 | Method for monitoring performance, device, equipment and the storage medium of database manipulation |
CN110866031A (en) * | 2019-11-08 | 2020-03-06 | 中国工商银行股份有限公司 | Database access path optimization method and device, computing equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN112540897A (en) | 2021-03-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111124906B (en) | Tracking method, compiling method and device based on dynamic embedded points and electronic equipment | |
JP4436036B2 (en) | Information processing apparatus, trace processing method, program, and recording medium | |
US9767007B2 (en) | Efficient method data recording | |
US10102046B2 (en) | In-memory data analytic system that provides an integrated tracking mechanism for explicit memory resources | |
CN110750315B (en) | Class loading method, device, equipment and storage medium in Android system | |
US20160321036A1 (en) | Dynamically monitoring code execution activity to identify and manage inactive code | |
EP2256633A2 (en) | Service provider management device, service provider management program, and service provider management method | |
CN113254470A (en) | Data change method and device, computer equipment and storage medium | |
CN115269631A (en) | Data query method, data query system, device and storage medium | |
EP2224381A1 (en) | Method and apparatus for case-based service composition | |
CN113065084B (en) | Data loading method and device, computer equipment and storage medium | |
CN112540897B (en) | Database monitoring method, device, server and medium | |
CN107526690B (en) | Method and device for clearing cache | |
CN115705294B (en) | Method, device, electronic equipment and medium for acquiring function call information | |
CN113495723B (en) | Method, device and storage medium for calling functional component | |
CN106776302A (en) | Calculate method, the device of method execution time in JAVA projects | |
CN115185921B (en) | Database fault loss stopping method, device, electronic equipment, medium and program product | |
CN118035042B (en) | Application program performance analysis method and device, electronic equipment and storage medium | |
CN113114493B (en) | Network element configuration constraint checking method and system | |
CN111796972B (en) | File hot-repair method, device, equipment and storage medium | |
CN113918595A (en) | Data query method and device | |
CN109710408B (en) | Memory management method and device | |
CN117762967A (en) | Data redistribution initiation method and device, electronic equipment and storage medium | |
CN117667862A (en) | Inotify file monitoring management method and system, electronic equipment and storage medium | |
CN115658430A (en) | Event monitoring processing method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |