Data display method and device, electronic equipment and readable medium
By obtaining process statistics information of database processes to calculate resource utilization and generating a resource utilization view, the problem of excessive resource consumption in existing technologies is solved, and accurate display and management of database resource consumption is achieved.
Patent Information
- Application Number
- CN202510572016.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2026-11-06
AI Technical Summary
In existing technologies, third-party plugins cannot accurately display the resource consumption status of the database environment, leading to excessive resource consumption and affecting the normal operation of the database.
By obtaining process statistics information of database processes, processor utilization and memory utilization are calculated, a resource utilization view is generated, and the resource consumption status is displayed in response to user query commands.
Accurately display the database's resource consumption status in the environment, avoid excessive resource consumption, and ensure the normal operation of the database.
Smart Images

Figure CN123048334A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data display method, apparatus, electronic device, and readable medium. Background Technology
[0002] In the current era of booming big data and cloud computing, database systems, as core components for data storage and processing, are becoming increasingly critical in terms of performance and resource management capabilities. With the continuous increase in data volume and business complexity, the ability to accurately grasp the status of database resource consumption is receiving significant attention.
[0003] In related technologies, database users can install third-party plugins on the database to collect database status data and combine it with the database's own status monitoring capabilities to statistically analyze and display the resource consumption in the database.
[0004] However, in such solutions, third-party plugins can generally only provide data statistics at the database statement level. They have a poor ability to perceive the resource consumption of the database environment and cannot accurately display the resource consumption status of the database environment, which can easily lead to excessive resource consumption and affect the normal operation of the database. Summary of the Invention
[0005] To address the aforementioned technical issues, this application provides a data display method, apparatus, electronic device, and readable medium to accurately display the resource consumption status of the database in its environment, avoid excessive resource consumption, and ensure the normal operation of the database.
[0006] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0007] According to one aspect of the embodiments of this application, a data display method is provided, including:
[0008] Based on the identification information of the database process, process statistics information of the database process is obtained from the database, and the process statistics information includes the runtime information of the database process;
[0009] Based on the process statistics of the database process, the resource usage information of the database process is calculated, and the resource usage information includes the processor utilization rate determined based on the runtime information;
[0010] A resource usage view is generated based on the active session information of the database process and the resource usage information, wherein the active session information includes the current active state of the database process in the database;
[0011] In response to a resource usage query command for the database, the resource usage view is displayed.
[0012] According to one aspect of the embodiments of this application, a data display device is provided, comprising:
[0013] The information acquisition module is configured to acquire process statistics information of the database process from the database based on the identification information of the database process, wherein the process statistics information includes the runtime information of the database process.
[0014] The resource usage calculation module is configured to calculate the resource usage information of the database process based on the process statistics information of the database process, wherein the resource usage information includes the processor utilization rate determined based on the runtime information.
[0015] The information merging module is configured to generate a resource usage view based on the active session information of the database process and the resource usage information, wherein the active session information includes the current active status of the database process in the database;
[0016] The view display module is configured to display the resource usage view in response to a resource usage query command for the database.
[0017] In some embodiments of this application, based on the technical solution of this application, the occupancy calculation module is specifically configured to: obtain the first runtime of the database process in user mode and the second runtime in kernel mode from the process statistics information of the database process; calculate the process runtime of the database process at the current moment according to the process start time in the process statistics information; calculate the sum of the durations between the first runtime and the second runtime, and determine the processor occupancy rate of the database process according to the ratio of the sum of the durations to the process runtime.
[0018] In some embodiments of this application, based on the technical solution of this application, the occupancy calculation module is specifically configured to: obtain first sampling data of the database process at a first sampling time from the process statistics information of the database process, wherein the first sampling data includes the first user-mode duration of the database process in user mode and the first kernel-mode duration in kernel mode; obtain second sampling data of the database process at a second sampling time from the process statistics information, wherein the second sampling data includes the second user-mode duration of the database process in user mode and the second kernel-mode duration in kernel mode, wherein the first sampling time is earlier than the second sampling time; calculate the sum of the first user-mode duration and the first kernel-mode duration to obtain a first occupancy duration, and calculate the sum of the second user-mode duration and the second kernel-mode duration to obtain a second occupancy duration; calculate the duration difference between the first occupancy duration and the second occupancy duration, and determine the processor occupancy rate of the database process according to the ratio between the duration difference and the sampling interval.
[0019] In some embodiments of this application, based on the technical solution of this application, the occupancy calculation module is further configured to: if the process start time in the process statistics is later than the first sampling time, calculate the process runtime of the database process at the second sampling time according to the process start time; and determine the processor occupancy rate of the database process according to the ratio between the second occupancy time and the process runtime.
[0020] In some embodiments of this application, based on the technical solution of this application, the resource occupancy information further includes the memory occupancy rate of the database process, and the occupancy calculation module is further configured to: obtain the page occupancy data of the database process from the process statistics information of the database process; and determine the memory occupancy rate of the database process based on the page occupancy data and the memory page space used by the database.
[0021] In some embodiments of this application, based on the technical solution of this application, the process statistics information of the database process includes the first sampled data and the second sampled data. The information acquisition module is specifically configured to: receive an information acquisition instruction for the database, the information acquisition instruction including sampling interval information; and sample the process status data of the database in the process file in the specified directory according to the identification information of the database process and the sampling interval information to obtain the first sampled data and the second sampled data.
[0022] In some embodiments of this application, based on the technical solution of this application, the information acquisition module is specifically configured to: acquire the first process group identifier of the database process in the database; traverse the process files in the specified system directory; if the file name in the specified system directory conforms to the specified format, then acquire the second process group identifier according to the file name of the process file; if the first process group identifier matches the second process group identifier, then read the process statistics information from the process file.
[0023] In some embodiments of this application, based on the technical solution of this application, the activity session information includes a correspondence between database processes and database accounts. The view display module is further configured to: determine the resource usage data of each database account in the database based on the resource usage information of the database processes in the resource usage view and the correspondence; cluster the database accounts based on the resource usage data of each database account to obtain account clusters; and determine the billing data of the database accounts in each account cluster based on the average resource usage of each account cluster and the pre-designed billing strategy.
[0024] In some embodiments of this application, based on the technical solution of this application, the view display module is further configured to: obtain the change trend information of resource usage information of each database process in the database within a specified time according to the resource usage view; determine the usage threshold corresponding to the resource usage information within the specified time according to the change trend information and a predetermined alarm strategy; and generate alarm information for the database process if the resource usage information of the database process in the resource usage view is higher than the usage threshold in response to the status monitoring instruction for the database.
[0025] In some embodiments of this application, based on the technical solution of this application, the view display module is further configured to: obtain resource usage information and active session information of each database process from the resource usage view, wherein the active session information includes database statements running in the database process; determine the execution duration of each database statement according to the resource usage information; and terminate the database process of the database statement if the execution duration of the database statement is greater than the execution duration threshold.
[0026] In some embodiments of this application, based on the technical solution of this application, the view display module is specifically configured to: predict the cause of the database process's anomaly using a pre-trained prediction model based on the activity session information and the change trend information, wherein the pre-trained prediction model is trained based on historical data of the resource occupancy view; and generate alarm information for the database process based on the cause of the anomaly and the change trend information.
[0027] According to one aspect of the embodiments of this application, an electronic device is provided, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the data display method as described above by executing the executable instructions.
[0028] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the data display method as described in the above technical solutions.
[0029] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data display methods provided in the various optional implementations described above.
[0030] In the embodiments of this application, the data display device obtains the process statistics information of the database process from the database based on the database process's identification information. The process statistics information includes the runtime information of the database process. Then, based on the process statistics information, the data display device calculates the resource usage information of the database process, including the processor utilization rate determined based on the runtime information. Finally, based on the active session information of the database process and the resource usage information, a resource usage view is generated. The active session information includes the current activity status of the database process in the database. In response to a resource usage query command for the database, the data display device displays the resource usage view. In this way, the system reads the process statistics information from the database process's identification information, further calculates the resource usage information of the database process, and presents it to the user in a view. This accurately displays the database's resource consumption status in the environment, avoids excessive resource consumption, and ensures the normal operation of the database.
[0031] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0033] Figure 1 The system structure of the data display method according to an embodiment of this application applied to a data display system is shown.
[0034] Figure 2 A general flowchart of the data display process in an embodiment of this application is shown.
[0035] Figure 3 A flowchart of a data display method according to an embodiment of this application is shown.
[0036] Figure 4 A flowchart of a data display method according to an embodiment of this application is shown.
[0037] Figure 5 This is a schematic diagram of the process state in an embodiment of this application.
[0038] Figure 6 This is a schematic diagram of the overall data display process in the embodiments of this application.
[0039] Figure 7 A schematic block diagram illustrating the composition of the data display device in an embodiment of this application is shown.
[0040] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation
[0041] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0042] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0043] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve the predetermined function, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0044] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0045] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0046] It should be understood that the solution in this application can be applied to database management processes, specifically in scenarios involving the collection, viewing, and monitoring of database resource consumption. In this application, the data display process refers to the process of displaying database resource consumption through database management tools. For example, database administrators remotely log into the database to view its resource usage. It is important to note that the administrator or operator of the database and the system environment in which it resides may not be the same, and a database administrator's login to the database does not necessarily mean they possess all relevant information about the system environment. The solution in this application allows obtaining the resource consumption of relevant database processes within the current database instance through views within the database. Understanding this type of data is beneficial for making corresponding business adjustments based on resource consumption in specific business operations. For example, in the e-commerce field, order processing is one of the core businesses of an e-commerce platform. During promotional activities, such as public holidays, weekends, or shopping festivals, order volume increases dramatically. By assessing the database's resource consumption during runtime, developers can optimize order query and stored procedures in advance to ensure that the system can process orders quickly under high concurrency, avoiding order processing delays or system crashes due to insufficient resources. Furthermore, e-commerce platforms can provide personalized product recommendations based on an account's browsing and purchase history. This involves the analysis and querying of large amounts of consumer and product data. Through resource consumption assessment, technicians can optimize the database query statements of the recommendation algorithm, allocate resources rationally, and improve the response speed of the recommendation system, thereby enhancing the user experience of the platform. In the financial sector, the core business systems of financial trading platforms have extremely high requirements for data accuracy and system stability. By assessing the resource consumption of the database during runtime in real time, technicians can promptly identify potential performance issues, make optimizations and adjustments in advance, and ensure that the system can operate stably when handling a large number of transactions, avoiding problems such as financial losses or service interruptions. Logistics and distribution systems need to track the transportation status of goods in real time and handle business such as order allocation and vehicle dispatch. During peak business periods, such as the logistics and distribution peak after e-commerce promotional activities, the system needs to process a large amount of logistics data. By assessing the resource consumption of the database during runtime, logistics company technicians can optimize database queries and storage processes in advance, ensuring that the system can quickly respond to logistics information query and update requests, improving the efficiency and accuracy of logistics and distribution.
[0047] In the current era of booming big data and cloud computing, database systems, as core components for data storage and processing, are becoming increasingly critical in terms of performance and resource management capabilities. With the continuous increase in data volume and business complexity, the ability to accurately grasp the resource consumption status of databases has gained attention. In related technologies, database users can install third-party plugins to collect database status data and combine it with the database's own status monitoring capabilities to statistically analyze and display resource consumption. However, in such solutions, third-party plugins generally only provide database statement-level data statistics, lacking a strong ability to perceive the resource consumption of the database's environment. This inaccurate display of the resource consumption status of the database environment can easily lead to excessive resource consumption, affecting the normal operation of the database.
[0048] Based on this, the technical solution of this application embodiment proposes a data display scheme. Specifically, please refer to... Figure 1 The system architecture of the data display method applied to the data display system according to the embodiments of this application can mainly include a terminal device 110, a network 120, and a database server 130. The terminal device 110 can include smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. A database client for accessing the database is typically installed on the terminal device 110. A database program 131 and an operating system 132 are deployed on the database server 130. The database program 131 itself is an application installed in the operating system 132, and its process runs within the environment of the operating system 132. The database server 130 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal device 110 and the database server 130 are connected via various types of communication media through the communication link of the network 120, such as a wired communication link or a wireless communication link.
[0049] Depending on the implementation requirements, the system architecture in this application embodiment can have any number of terminal devices and servers. For example, the devices such as the database server 130 can be a server group composed of multiple server devices. In addition, the technical solutions provided in this application embodiment can be applied to a computing platform, or can be implemented jointly by various parts of the system, and this application does not impose any special limitations on this.
[0050] like Figure 1 As shown, in the scheme of this application, the terminal device 110 is mainly used for interaction with the user, including receiving user input commands and displaying database resource usage information to the user. A database program is installed on the database server 130 to provide database-related services to the terminal device 110. A database plugin for resource consumption assessment is also installed on the database server 130. This database plugin can create a resource consumption view in the database, which includes the resource consumption status of each database process. The terminal device 110 can query this resource consumption view through commands to obtain the resource consumption status of the database processes.
[0051] Figure 2 A general flowchart of the data display process in an embodiment of this application is shown. Figure 2 As shown, the user triggers data collection for the resource consumption view via a view query command. Subsequently, in step 210, the database triggers a command to collect database integration resources. Based on this command, in step 220, the database retrieves the process list of the current database instance. Then, in step 230, the database calculates the processor and memory usage for each process, and in step 240, it collects further supplementary information about the database processes. Finally, in step 250, the calculated data and supplementary information are combined to generate the final view result, which is then fed back to the user.
[0052] The implementation details of the technical solutions in the embodiments of this application are described in detail below: Figure 3 A flowchart illustrating a data display method according to an embodiment of this application is shown. This data display method can be executed by a device with computing processing capabilities, such as a server in a database system. The embodiments of this application use a database server as an example. (Refer to...) Figure 3 As shown, this data display method includes at least steps S310 to S340, which are described in detail below:
[0053] Step S310: Based on the identifier information of the database process, obtain the process statistics information of the database process from the database. The process statistics information includes the runtime information of the database process.
[0054] In this embodiment, the identification information of the database process can be the process identifier of the database process, such as the process ID. This process identifier can be directly retrieved from data tables such as state views in the database. The process statistics information of the database process can be obtained from the database itself or the operating system on which the database resides. For example, depending on the specific type of database, the database usually contains data tables or views that provide process-related information. The relevant information can be obtained by querying these data tables or views using database query statements. In some embodiments, the database can obtain database process information from the operating system through a database plugin. For example, the database can access a directory in the operating system used to store process-related files. Such directories store process status files related to each operating system process. The database can obtain process-related information by reading the contents of the process status files in the directory. The process statistics information includes at least the runtime information of the database process. The runtime information generally includes the process start time, the time spent in the running state, or the time spent in the suspended state. The process statistics information may also include information such as process name, process ID, process state, and process group identifier.
[0055] Step S320: Calculate the resource usage information of the database process based on the process statistics information of the database process. The resource usage information includes the processor utilization rate determined based on the runtime information.
[0056] The data display device can calculate the resource usage information of the database process based on the process statistics. This resource usage information includes at least processor utilization. Resource usage information can be calculated based on runtime, such as the ratio between the database process's execution time, suspension time, and startup time. Alternatively, resource usage information can also be calculated based on resource utilization ratios. For example, for processors, processor utilization can be calculated as the ratio of the number of threads to the number of cores used, or as the ratio of active threads recorded by performance counters.
[0057] Step S330: Generate a resource usage view based on the active session information of the database process and the resource usage information. The active session information includes the current active status of the database process in the database.
[0058] Active session information contains the current activity status of the database session corresponding to the database process within the database. This information can be obtained directly from the database. Typically, a corresponding table exists in the database to store this information. For example, in a PostgreSQL database, session information is stored in `pg_stat_activity`. The data display device can merge resource usage information and active session information into the same table to form a resource usage view. The merging is done by process ID, and the information for the corresponding process can be further sorted according to predetermined rules, such as sorting by process ID order and grouping by process group for display.
[0059] Step S340: In response to a resource usage query command for the database, display the resource usage view.
[0060] The resource usage view is stored in the database with a predetermined name. The data in the resource usage view can be updated periodically or according to user instructions. In the first embodiment, the database's resource usage query instruction generates a query statement for the resource usage view in the database. After receiving the query statement, the database first triggers an update of the resource usage view, and then sends the updated resource usage view to the client for display.
[0061] In the embodiments of this application, the data display device obtains the process statistics information of the database process from the database based on the database process's identification information. The process statistics information includes the runtime information of the database process. Then, based on the process statistics information, the data display device calculates the resource usage information of the database process, including the processor utilization rate determined based on the runtime information. Finally, based on the active session information of the database process and the resource usage information, a resource usage view is generated. The active session information includes the current activity status of the database process in the database. In response to a resource usage query command for the database, the data display device displays the resource usage view. In this way, the system reads the process statistics information from the database process's identification information, further calculates the resource usage information of the database process, and presents it to the user in a view. This accurately displays the database's resource consumption status in the environment, avoids excessive resource consumption, and ensures the normal operation of the database.
[0062] In some embodiments of this application, based on the technical solution of this application, during the process of calculating the resource usage information of the database process according to the process statistics information of the database process, the data display device can obtain the first runtime in user mode and the second runtime in kernel mode of the database process from the process statistics information of the database process. Then, based on the process start time in the process statistics information, it calculates the process runtime of the database process at the current moment, calculates the sum of the first runtime and the second runtime, and determines the processor utilization rate of the database process based on the ratio of the sum of the durations to the process runtime. In this embodiment, the data display device can calculate the processor utilization rate of a database process from its start to the current moment based on the data in the process statistics information. Specifically, the data display device obtains the first runtime in user mode and the second runtime in kernel mode of the database process from the process statistics information. Both the first runtime and the second runtime are used as the processor usage time of the database process. The data display device can obtain the process start time of the database process from the process statistics information, thereby calculating the process runtime of the database process at the current moment. The calculation method of processor utilization rate is as follows:
[0063]
[0064] Among them, jiffies starttime The value is the number of clock ticks elapsed since the operating system started, jiffies. starttime The value is the number of clock ticks elapsed since the process started, from the time the operating system started. A clock tick can be considered a unit of time calculation used by the operating system and can be converted into a daily unit of time measurement using calculation commands. `utime` represents the time the process has been running in user mode since startup, and `stime` represents the time the process has been running in kernel mode since startup. Using this method, the data display device can calculate processor utilization based on the runtime of the process in user mode and kernel mode, thereby calculating the accurate CPU utilization of a single database process, which helps improve the accuracy and comprehensiveness of the data display results.
[0065] In some embodiments of this application, based on the technical solution of this application, during the process of obtaining process statistics information of the database process according to the identifier information of the database process in the database, the data display device can obtain the first process group identifier of the database process in the database, and then traverse the process files in the specified system directory. If the file name in the specified system directory conforms to the specified format, the second process group identifier is obtained according to the file name of the process file. If the first process group identifier matches the second process group identifier, the data display device can read the process statistics information from the process file. In this embodiment, the data display device reads the process file of the database process from the operating system where the database is located, thereby obtaining the process statistics information. Specifically, the data display device obtains the first process group identifier of the database process from the database. Subsequently, in the predetermined process file storage directory, the file names of all process files in the specified directory of the current system are retrieved. It can be understood that the specified directory of the current system will contain the process files of all processes, such as the processes of the current database instance, the processes of other database instances, the processes of other applications, and system processes, and may also contain other related files besides process files. During the traversal of process files, the data display device checks whether the file name of the current file conforms to the specified format of the process file file name. For example, a process file's filename can consist entirely of numbers, while a filename containing characters other than numbers does not conform to the specified format. For filenames that conform to the specified format, the data display device directly uses the filename as the process ID and attempts to obtain the corresponding second process group ID. If the file is not actually a process file but a non-process file with a purely numeric filename, the process group ID will not be obtained based on its filename, and the data display device can proceed directly to the next file. If the second process group ID is obtained, the data display device matches it with the first process group ID. If the match is successful, it indicates that the process file belongs to a process in the current database instance, and the process statistics information of the database process can be read from the process file. If the match fails, it indicates that the process in the process file does not belong to the current database instance, and the device continues to process the next file. Process files typically store data in a fixed format, so the data display device can directly parse the process file and obtain the required data in a predetermined manner. Through the above method, the data display device can query the process statistics information of each database process from the operating system where the database resides, without the need for additional data statistics methods to perform database process statistics, thereby reducing the system resource overhead of the solution and improving the system's resource utilization.
[0066] In some embodiments of this application, based on the technical solution of this application, the activity session information includes the correspondence between database processes and database accounts. After displaying the resource usage view in response to a resource usage query instruction for the database, the data display device can further determine the resource usage data of each database account in the database based on the resource usage information of the database processes in the resource usage view and the correspondence. Then, it clusters the database accounts based on the resource usage data of each database account to obtain account clusters. Finally, it determines the billing data of the database accounts in each account cluster based on the average resource usage of each account cluster and a pre-designed billing strategy. In this embodiment, the data display device can generate resource usage data for each database account according to the resource usage information. It can be understood that the database usage process of a database account can generate multiple processes. The resource usage data of these processes are merged to obtain the resource usage data of the account's database usage process. Then, the data display device clusters the database accounts based on the resource usage data of each database account to obtain account clusters. Specifically, the clustering can adopt various suitable clustering methods, such as clustering into two clusters: high-usage accounts and low-usage accounts. Accounts clustered with different average resource usage values correspond to different pre-designed billing strategies. Billing is applied to accounts within each cluster according to these strategies, thus determining the billing data for each database account. For example, account A has a processor utilization rate of 10%, and according to the pre-designed billing strategy, the corresponding rate is set at 2000 per day. Account B has a processor utilization rate of 60%, and according to the pre-designed billing strategy, the corresponding rate is set at 10000 per day. The system can bill accounts daily or weekly to obtain billing data. In this way, the solution can determine billing data based on the actual resource usage of accounts, thereby improving the matching degree between billing data and resource usage, increasing billing accuracy, and reducing the probability of billing errors.
[0067] In some embodiments of this application, based on the technical solution of this application, after displaying the resource usage view in response to a resource usage query instruction for the database, the data display device can also obtain the changing trend information of the resource usage information of each database process in the database within a specified time period according to the resource usage view, and then determine the usage threshold corresponding to the resource usage information within the specified time period according to the changing trend information and a predetermined alarm strategy. In response to a status monitoring instruction for the database, if the resource usage information of the database process in the resource usage view is higher than the usage threshold, the data display device generates alarm information for the database process. In this embodiment, the data display device dynamically adjusts the usage threshold according to the changing trend information of the resource usage information within a specified time period. Specifically, the data display device can obtain the changing trend information of the resource usage information of each database process in the database within a specified time period according to the resource usage view. For example, it can obtain the change in resource usage information from 8 am to 12 pm every day of a month, and then determine the corresponding threshold adjustment value according to the change. For example, if the change is an average daily increase of 5%, the usage threshold can also be increased by 5% accordingly. When a database status monitoring command is triggered, the data display device can compare the resource usage information of the database process in the resource usage view with the usage threshold corresponding to the current time. If it exceeds the threshold, an alarm can be issued to the database process. In this way, the data display device can dynamically determine the usage threshold and issue alarms based on the dynamic threshold, thereby improving the data display device's adaptability to data changes and thus improving alarm accuracy.
[0068] In some embodiments of this application, based on the technical solution of this application, the data display device can also obtain resource usage information and active session information of each database process from the resource usage view. The active session information includes database statements running in the database process, and then the execution duration of each database statement is determined according to the resource usage information. If the execution duration of a database statement exceeds an execution duration threshold, the database process of that database statement is terminated. In this embodiment, the data display device can obtain resource usage information and active session information of each database process from the resource usage view, and then calculate the execution duration of the database statements in the active session information based on the resource usage information. For example, if the active session information of a process indicates that the process is executing a query statement, and the resource usage information indicates that the process has occupied the processor for more than 10 minutes, the process may have poor execution efficiency and may affect the task execution of other processes, then the process of the query statement can be terminated. In some embodiments, the data display device can further calculate the duration for which the processor utilization rate of a process exceeds a certain threshold based on the resource usage view to determine whether to terminate the database process. In this way, when there is an anomaly in the database, the data display device can automatically stop the execution of statements that take too long based on the execution time of the database statements in the database process, thereby improving the solution's ability to handle anomalies.
[0069] In some embodiments of this application, based on the technical solution of this application, during the generation of alarm information for the database process, the data display device can predict the cause of the database process's anomaly using a pre-trained prediction model based on the activity session information and the trend information. The pre-trained prediction model is trained using historical data from the resource usage view, and then generates alarm information for the database process based on the cause of the anomaly and the trend information. In this embodiment, the data display device can input the activity session information and trend information into the pre-trained prediction model for root cause prediction to obtain the predicted cause of the anomaly. The pre-trained prediction model is trained based on historical activity session information and trend information. Specifically, if the resource usage information of the database process in the resource usage view is higher than the usage threshold, indicating that the database process may be in an abnormal state, the data display device can collect the activity session information and trend information of the database process from the resource usage view and associate them with the cause of the anomaly as training data to train the pre-trained prediction model. This allows the pre-trained prediction model to predict possible causes of the anomaly based on the activity session information and trend information. The pre-trained prediction model can employ various suitable classification models. The data visualization device can generate alarm messages for database processes based on the predicted trends of anomaly causes. These alarm messages can include a description of the database process's status and a description of the predicted anomaly cause. For example, an alarm message might include the message "Process XXX has high processor usage, XX statement execution time exceeds 10 minutes" and a predicted cause such as "Possible anomaly: Lock anomaly occurred during the query process." Through this method, the data visualization device can further predict the causes of database process anomalies based on resource usage view data, reducing the difficulty of anomaly analysis and thus improving the efficiency of anomaly handling.
[0070] In embodiments of this application, a method for... Figure 3 Other detailed embodiments of the technical solution shown in the example are as follows: Figure 4 As shown, in one embodiment of the data display method of this application, the solution of this application may include the following steps:
[0071] Step S410: Based on the identifier information of the database process, obtain the process statistics information of the database process from the database. The process statistics information includes the runtime information of the database process.
[0072] Optionally, the implementation details of step S410 are the same as those of... Figure 3 The steps S310 shown are the same and will not be repeated here.
[0073] Step S420: Obtain the first sampled data of the database process from the process statistics information of the database process at the first sampling time. The first sampled data includes the first user mode duration of the database process in user mode and the first kernel mode duration in kernel mode.
[0074] Step S430: Obtain the second sampling data of the database process at the second sampling time from the process statistics information. The second sampling data includes the second user mode duration of the database process in user mode and the second kernel mode duration in kernel mode. The first sampling time is earlier than the second sampling time.
[0075] Step S440: Calculate the sum of the first user-mode duration and the first kernel-mode duration to obtain the first occupied duration; and calculate the sum of the second user-mode duration and the second kernel-mode duration to obtain the second occupied duration.
[0076] Step S450: Determine the processor utilization rate of the database process based on the ratio of the first occupied duration and the difference between the first occupied duration and the second occupied duration to the specified sampling interval.
[0077] In this embodiment, the data display device can calculate resource usage information within a specified sampling interval. Specifically, the data display device can obtain the first sampled data of the database process at the first sampling time from the process statistics information of the database process. The first sampling time is generally the start time of a specified sampling interval. The first sampled data includes the first user-mode duration of the database process in user mode and the first kernel-mode duration in kernel mode. The first user-mode duration and the first kernel-mode duration can generally be directly read from the process statistics information. The first user-mode duration refers to the duration the database process is in user mode from startup to the first sampling time, and the first kernel-mode duration refers to the duration the database process is in kernel mode from startup to the first sampling time. Similarly, the data display device can obtain the second sampled data of the database process at the second sampling time from the process statistics information. The first sampling time is earlier than the second sampling time; that is, the second sampling time is generally the end time of a specified sampling interval. The second sampled data includes the second user-mode duration of the database process in user mode and the second kernel-mode duration in kernel mode. The second user-mode duration and the second kernel-mode duration can also be directly read from the process statistics information. The second user-mode duration refers to the duration the database process is in user mode from startup to the second sampling time, and the second kernel-mode duration refers to the duration the database process is in kernel mode from startup to the second sampling time. The data display device calculates the sum of the first user-mode duration and the first kernel-mode duration to obtain the first occupied duration, and calculates the sum of the second user-mode duration and the second kernel-mode duration to obtain the second occupied duration. Then, based on the ratio of the difference between the first and second occupied durations to a specified sampling interval, the processor utilization rate of the database process within the specified sampling interval is determined, thus obtaining resource utilization information. The difference between the first and second occupied durations can be considered as the occupied duration within the specified sampling interval, and the ratio of this difference to the specified sampling interval can be considered as the processor utilization rate of the database process within the specified sampling interval. Specifically, process statistics can be sampled according to a specified sampling interval to obtain the first and second sampled data. For example, to obtain the processor utilization rate within the time interval [t1, t2], with an interval of t2-t1 seconds, the calculation method is as follows:
[0078]
[0079] Among them, jiffies t2 The value is the number of clock ticks elapsed since the operating system started at time t2, jiffies t1 The value is the number of clock ticks elapsed since the operating system started at time t1. t1 and utime t2Let stime be the time the process runs in user mode from startup to time t1 and time t2, respectively. t1 and stime t2 These represent the time the process runs in kernel mode from startup to time t1 and time t2, respectively. Using this method, the scheme can calculate the processor utilization of the database process within a specified time period, thereby calculating the processor utilization at different time dimensions, which improves the flexibility of the scheme.
[0080] Step S460: Merge the active session information and resource usage information of the database process to generate a resource usage view, wherein the resource usage information includes at least the processor utilization rate.
[0081] Optionally, the implementation details of step S460 are the same as those of step S460. Figure 3 The steps S330 shown are the same and will not be repeated here.
[0082] Step S440: In response to a resource usage query command for the database, display the resource usage view.
[0083] Optionally, the implementation details of step S440 are the same as those of... Figure 3 The steps S340 shown are the same and will not be repeated here.
[0084] In the embodiments of this application, the data display device obtains the process statistics information of the database process from the database based on the database process's identification information. The process statistics information includes the runtime information of the database process. Then, based on the process statistics information, the data display device calculates the resource usage information of the database process, including the processor utilization rate determined based on the runtime information. Finally, based on the active session information of the database process and the resource usage information, a resource usage view is generated. The active session information includes the current activity status of the database process in the database. In response to a resource usage query command for the database, the data display device displays the resource usage view. In this way, the system reads the process statistics information from the database process's identification information, further calculates the resource usage information of the database process, and presents it to the user in a view. This accurately displays the database's resource consumption status in the environment, avoids excessive resource consumption, and ensures the normal operation of the database.
[0085] In some embodiments of this application, based on the technical solution of this application, if the process start time in the process statistics is later than the first sampling time, the data display device can also calculate the process runtime of the database process at the second sampling time based on the process start time, and then determine the processor utilization rate of the database process based on the ratio between the second occupied time and the process runtime. In this embodiment, when a process starts during a specified sampling interval, the data display device will calculate the processor utilization rate according to the process start time of that process. Specifically, if the process start time is later than the first sampling time, there are usually two situations: the process end time is earlier than or later than the second sampling time. For the case where the end time is earlier than the second sampling time, since no relevant data for the process will be collected at either time point, the data display device may not calculate its resource usage information. For the case where the end time is later than the second sampling time, only the processor utilization rate within the specified sampling interval can be calculated. Please refer to [link to relevant documentation]. Figure 5 , Figure 5 This is a schematic diagram of the process states in an embodiment of this application. For example... Figure 5 As shown, for the time interval formed between time t1 and time t2, if the database process terminates before time t2, then the process statistics information for that process cannot be sampled at time t2, and therefore its occupancy rate can be disregarded. For example... Figure 5 Processes 1 and 5 in the database. If the database process has not terminated at time t2, but started after time t1, calculate the processor utilization of the database process from the start time to time t2, for example... Figure 5 In processes 2 and 4, the data display device calculates the processor utilization from the start of the processes to time t2. If the database process starts before t1 and has not ended at t2, the processor utilization from t1 to t2 is calculated, for example... Figure 5 Process 3 in the above embodiments. The calculation method can be adopted as appropriate in the above embodiments. Through the above method, a method for calculating the processor utilization rate within a specified interval under different process startup conditions is provided, thereby improving the operability of the solution.
[0086] In some embodiments of this application, based on the technical solution of this application, the resource usage information also includes the memory usage rate of the database process. The data display device can also obtain the page usage data of the database process from the process statistics information of the database process, and then determine the memory usage rate of the database process based on the page usage data and the memory page space used by the database. In this embodiment, the data display device also calculates the memory usage rate. The process statistics information includes the page usage data of the database process, such as the actual memory size (rss) occupied by the process. Specifically, in some embodiments, the actual memory size (rss) occupied by the process can be directly read from the process status file in the operating system where the database resides. The actual memory size is generally counted according to the number of memory pages. The data display device can multiply the number of occupied pages by the size of each page to calculate the memory usage rate of the database process. Typically, the memory usage rate of the database process is calculated using the process statistics data corresponding to the second sampling time in the above embodiments. In this way, the data display device can simultaneously display the processor usage rate and memory usage rate of the database process, thereby improving the completeness and diversity of the displayed data.
[0087] In some embodiments of this application, based on the technical solution of this application, the process statistics information of the database process includes the first sampled data and the second sampled data. During the process of obtaining the process statistics information of the database process from the database according to the database process's identification information, the data display device can receive an information collection instruction for the database, the information collection instruction containing sampling interval information. Then, according to the database process's identification information and the sampling interval information, it samples the process status data of the database in the process file under the specified directory to obtain the first sampled data and the second sampled data. In this embodiment, the user can configure the data sampling time interval through the information collection instruction. Specifically, the user can input the information collection instruction through an instruction or graphical interface, which includes the user-set specified sampling interval. After receiving the information collection instruction, the data display device samples the process status data of the database in the process file under the specified directory according to the database process's identification information and the specified sampling interval in the information collection instruction to obtain the first sampled data and the second sampled data. For example, if the specified sampling interval is 10 seconds, the data display device can immediately sample the process status data of the database in the process file under the specified directory to obtain the first sampled data. In addition, the data display device starts a 10-second counter, and after the counter expires, it samples the process status data in the process file in the specified directory of the database again to obtain a second sample data. In this way, the data display can set a specified sampling interval according to the information collection instructions entered by the user, thereby allowing the user to flexibly set the sampling interval and thus allow the user to collect resource usage information according to a custom sampling duration.
[0088] The following describes an overall implementation of the technical solution of this application in one embodiment. Please refer to... Figure 6 , Figure 6 This is a schematic diagram illustrating the overall data display process in an embodiment of this application. Figure 6As shown, the user first creates a plugin for data display in the database in step 601 and sets database parameters. These parameters include the time interval for retrieving database process status data. The plugin installed in step 602 retrieves a list of processes for the current database instance, and in step 603, based on this list, reads the system process files of each database process through the server's operating system interface. The system process files contain processor and memory usage data. In step 604, the database plugin calculates processor and memory usage based on the data read from the server's system process files. Subsequently, in step 605, a resource usage view is created based on the calculated processor and memory usage and the process-related information provided by the database itself. After the view is created, the user can retrieve the data from the resource usage view by entering a view query command on the client in step 606. The database then feeds back the data resource usage view to the client for display in step 607.
[0089] It should be noted that although the steps of the method in this application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0090] The following describes the implementation of the apparatus of this application, which can be used to execute the data display method in the above embodiments of this application. Figure 7 A schematic block diagram illustrating the composition of the data display device in an embodiment of this application is shown. For example... Figure 7 As shown, the data display device 700 mainly includes:
[0091] The information acquisition module 710 is configured to acquire process statistics information of the database process from the database based on the identification information of the database process, wherein the process statistics information includes the runtime information of the database process.
[0092] The resource utilization calculation module 720 is configured to calculate the resource utilization information of the database process based on the process statistics information of the database process, wherein the resource utilization information includes the processor utilization rate determined based on the runtime information.
[0093] The information merging module 730 is configured to generate a resource usage view based on the active session information of the database process and the resource usage information, wherein the active session information includes the current active status of the database process in the database;
[0094] The view display module 740 is configured to display the resource usage view in response to a resource usage query command for the database.
[0095] In some embodiments of this application, based on the technical solution of this application, the occupancy calculation module 720 is specifically configured to: obtain the first runtime of the database process in user mode and the second runtime in kernel mode from the process statistics information of the database process; calculate the process runtime of the database process at the current moment according to the process start time in the process statistics information; calculate the sum of the durations between the first runtime and the second runtime, and determine the processor occupancy rate of the database process according to the ratio of the sum of the durations to the process runtime.
[0096] In some embodiments of this application, based on the technical solution of this application, the occupancy calculation module 720 is specifically configured to: obtain first sampled data of the database process at a first sampling time from the process statistics information of the database process, wherein the first sampled data includes the first user-mode duration of the database process in user mode and the first kernel-mode duration in kernel mode; obtain second sampled data of the database process at a second sampling time from the process statistics information, wherein the second sampled data includes the second user-mode duration of the database process in user mode and the second kernel-mode duration in kernel mode, wherein the first sampling time is earlier than the second sampling time; calculate the sum of the first user-mode duration and the first kernel-mode duration to obtain a first occupancy duration, and calculate the sum of the second user-mode duration and the second kernel-mode duration to obtain a second occupancy duration; calculate the duration difference between the first occupancy duration and the second occupancy duration, and determine the processor occupancy rate of the database process according to the ratio between the duration difference and the sampling interval.
[0097] In some embodiments of this application, based on the technical solution of this application, the occupancy calculation module 720 is further configured to: if the process start time in the process statistics information is later than the first sampling time, calculate the process runtime of the database process at the second sampling time according to the process start time; and determine the processor occupancy rate of the database process according to the ratio between the second occupancy time and the process runtime.
[0098] In some embodiments of this application, based on the technical solution of this application, the resource occupancy information further includes the memory occupancy rate of the database process, and the occupancy calculation module 720 is further configured to: obtain the page occupancy data of the database process from the process statistics information of the database process; and determine the memory occupancy rate of the database process based on the page occupancy data and the memory page space used by the database.
[0099] In some embodiments of this application, based on the technical solution of this application, the process statistics information of the database process includes the first sampled data and the second sampled data; the information acquisition module 710 is specifically configured to: receive an information acquisition instruction for the database, the information acquisition instruction including sampling interval information; and sample the process status data of the database in the process file in the specified directory according to the identification information of the database process and the sampling interval information to obtain the first sampled data and the second sampled data.
[0100] In some embodiments of this application, based on the technical solution of this application, the information acquisition module 710 is specifically configured to: acquire the first process group identifier of the database process in the database; traverse the process files in the specified system directory; if the file name in the specified system directory conforms to the specified format, then acquire the second process group identifier according to the file name of the process file; if the first process group identifier matches the second process group identifier, then read the process statistics information from the process file.
[0101] In some embodiments of this application, based on the technical solution of this application, the activity session information includes a correspondence between database processes and database accounts. The view display module 740 is further configured to: determine the resource usage data of each database account in the database based on the resource usage information of the database processes in the resource usage view and the correspondence; cluster the database accounts based on the resource usage data of each database account to obtain account clusters; and determine the billing data of the database accounts in each account cluster based on the average resource usage of each account cluster and the pre-designed billing strategy.
[0102] In some embodiments of this application, based on the technical solution of this application, the view display module 740 is further configured to: obtain the change trend information of resource usage information of each database process in the database within a specified time according to the resource usage view; determine the usage threshold corresponding to the resource usage information within the specified time according to the change trend information and a predetermined alarm strategy; and generate alarm information for the database process if the resource usage information of the database process in the resource usage view is higher than the usage threshold in response to the status monitoring instruction for the database.
[0103] In some embodiments of this application, based on the technical solution of this application, the view display module 740 is further configured to: obtain resource usage information and active session information of each database process from the resource usage view, wherein the active session information includes database statements running in the database process; determine the execution duration of each database statement according to the resource usage information; and terminate the database process of the database statement if the execution duration of the database statement is greater than the execution duration threshold.
[0104] In some embodiments of this application, based on the technical solution of this application, the view display module 740 is specifically configured to: predict the cause of the database process's abnormality based on the activity session information and the change trend information using a pre-trained prediction model, wherein the pre-trained prediction model is trained based on historical data of the resource occupancy view; and generate alarm information for the database process based on the cause of the abnormality and the change trend information.
[0105] It should be noted that the apparatus provided in the above embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module performs the operation has been described in detail in the method embodiments, and will not be repeated here.
[0106] Figure 8 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.
[0107] It should be noted that, Figure 8 The computer system 800 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0108] like Figure 8 As shown, the computer system 800 includes a Central Processing Unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 802 or programs loaded from Storage Unit 808 into Random Access Memory (RAM) 803. The RAM 803 also stores various programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An Input / Output (I / O) interface 805 is also connected to the bus 804.
[0109] The following components are connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 810 as needed so that computer programs read from it can be installed into storage section 808 as needed.
[0110] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit (CPU) 801, it performs various functions defined in the system of this application.
[0111] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0112] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0113] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0114] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
[0115] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0116] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A data display method, characterized in that, Based on the identification information of the database process, process statistics information of the database process is obtained from the database, and the process statistics information includes the runtime information of the database process; Based on the process statistics of the database process, the resource usage information of the database process is calculated, and the resource usage information includes the processor utilization rate determined based on the runtime information; A resource usage view is generated based on the active session information of the database process and the resource usage information, wherein the active session information includes the current active state of the database process in the database; In response to a resource usage query command for the database, the resource usage view is displayed.
2. The method according to claim 1, characterized in that, The step of calculating the resource usage information of the database process based on the process statistics information of the database process includes: Obtain the first runtime of the database process in user mode and the second runtime of the database process in kernel mode from the process statistics information of the database process; Calculate the runtime of the database process at the current moment based on the process start time in the process statistics information; Calculate the sum of the durations between the first runtime and the second runtime, and determine the processor utilization rate of the database process based on the ratio of the sum of durations to the process runtime.
3. The method according to claim 1, characterized in that, The step of calculating the resource usage information of the database process based on the process statistics information of the database process includes: The first sampled data of the database process is obtained from the process statistics information of the database process at the first sampling time. The first sampled data includes the first user mode duration of the database process in user mode and the first kernel mode duration in kernel mode. The second sampling data of the database process at the second sampling time is obtained from the process statistics information. The second sampling data includes the second user mode duration of the database process in user mode and the second kernel mode duration in kernel mode. The first sampling time is earlier than the second sampling time. The first occupied time is obtained by calculating the sum of the first user-mode duration and the first kernel-mode duration, and the second occupied time is obtained by calculating the sum of the second user-mode duration and the second kernel-mode duration; Calculate the duration difference between the first occupied duration and the second occupied duration, and determine the processor utilization rate of the database process based on the ratio between the duration difference and the sampling interval.
4. The method according to claim 3, characterized in that, The method further includes: If the process start time in the process statistics is later than the first sampling time, then the process runtime of the database process at the second sampling time is calculated based on the process start time. The processor utilization rate of the database process is determined based on the ratio between the second occupied time and the process runtime.
5. The method according to claim 1, characterized in that, The resource usage information also includes the memory usage rate of the database process, and the method further includes: Obtain the page usage data of the database process from the process statistics information of the database process; The memory usage rate of the database process is determined based on the page occupancy data and the memory page space used by the database.
6. The method according to claim 3, characterized in that, The process statistics of the database process include the first sampled data and the second sampled data; The step of obtaining process statistics information of the database process from the database based on the database process's identifier information includes: Receive an information collection instruction for the database, the information collection instruction including sampling interval information; Based on the identification information of the database process and the sampling interval information, data sampling is performed on the process status data of the database in the process file under the specified directory to obtain the first sampled data and the second sampled data.
7. The method according to claim 1, characterized in that, The step of obtaining process statistics information of the database process from the database based on the database process's identifier information includes: Obtain the first process group identifier of the database process in the database; Iterate through the process files in the specified system directory; If the filenames existing in the specified system directory conform to the specified format, then the second process group identifier is obtained based on the filenames of the process files; If the first process group identifier matches the second process group identifier, then process statistics information is read from the process file.
8. The method according to claim 1, characterized in that, The activity session information includes the correspondence between database processes and database accounts. After displaying the resource usage view in response to a resource usage query command for the database, the method further includes: Based on the resource usage information of the database processes in the resource usage view and the corresponding relationship, the resource usage data of each database account in the database is determined; The database accounts are clustered based on their resource usage data to obtain account clusters; Based on the average resource consumption of each account cluster and the pre-designed billing strategy, determine the billing data for the database accounts in each account cluster.
9. The method according to claim 1, characterized in that, After displaying the resource usage view in response to a resource usage query command for the database, the method further includes: Based on the resource usage view, obtain the trend information of resource usage of each database process in the database over a specified period of time; Based on the change trend information and the predetermined alarm strategy, determine the occupancy threshold corresponding to the resource occupancy information within the specified time period; In response to a status monitoring command for the database, if the resource usage information of the database process in the resource usage view is higher than the usage threshold, an alarm message is generated for the database process.
10. The method according to claim 1, characterized in that, The method further includes: Obtain resource usage information and active session information for each database process from the resource usage view. The active session information includes database statements running in the database process. Based on the resource usage information, determine the execution time of each database statement; If the execution time of a database statement exceeds the execution time threshold, the database process of that database statement will be terminated.
11. The method according to claim 9, characterized in that, The generation of alarm information for the database process includes: Using a pre-trained prediction model, the cause of the database process's anomaly is predicted based on the activity session information and the trend information. The pre-trained prediction model is trained based on historical data from the resource usage view. Based on the cause of the anomaly and the trend information, an alarm message is generated for the database process.
12. A data display device, characterized in that, include: The information acquisition module is configured to acquire process statistics information of the database process from the database based on the identification information of the database process, wherein the process statistics information includes the runtime information of the database process. The resource usage calculation module is configured to calculate the resource usage information of the database process based on the process statistics information of the database process, wherein the resource usage information includes the processor utilization rate determined based on the runtime information. The information merging module is configured to generate a resource usage view based on the active session information of the database process and the resource usage information, wherein the active session information includes the current active status of the database process in the database; The view display module is configured to display the resource usage view in response to a resource usage query command for the database.
13. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute the data display method of any one of claims 1 to 11 by executing the executable instructions.
14. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the data display method as described in any one of claims 1 to 11.
15. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions to cause the computer device to perform the data display method as described in any one of claims 1 to 11.
