Database statistical information updating method, device, equipment and medium

By introducing a cache mechanism of local statistical information database and local memory in the database, the problem of high concurrency lock conflict in the database is solved, efficient statistical information updates and queries are realized, and the efficiency of database usage is improved.

CN114253985BActive Publication Date: 2025-08-22CETC JINCANG (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111519868.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-13
Publication Date
2025-08-22
Estimated Expiration
2041-12-13

AI Technical Summary

Technical Problem

In the case of high concurrency of the database, traditional statistical information update methods lead to serious lock conflicts, resulting in waste of database performance and resources.

Method used

By cached the statistical information generated by the session process in the local statistical information database, and when the preset conditions are met, it is collected into data packets and sent to the statistical process for updates, avoiding locking operations on local memory and using local memory for updates.

Benefits of technology

It effectively avoids lock conflicts, saves system resources, and improves database usage efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114253985B_ABST
    Figure CN114253985B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, apparatus, device, and medium for updating database statistical information. The method comprises: the session process caches statistical information generated during the execution of user commands in a local statistical information repository; when a preset condition is met, the session process aggregates the statistical information in the local statistical information repository into a data packet and sends the data packet to the statistical process; the statistical process receives the data packet sent by the session process and updates the statistical information in the data packet to the local memory. The present disclosure caches the statistical information generated during the session process in the local statistical information repository, further introduces the statistical process, and allocates local memory to it. Therefore, when updating the statistical information in the local memory based on the statistical information in the local statistical information repository, there is no need to lock it, effectively avoiding lock conflicts when updating statistical information in the database, saving system resources, and effectively improving the efficiency of database use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of database technology, and in particular to a method, apparatus, device, and medium for updating database statistical information. Background Art

[0002] Statistical information plays a very important role in relational databases. It not only provides the optimizer with a basis for selecting access paths, but also helps the database administrator (DBA) analyze possible problems in the database.

[0003] As the complexity of database services increases, more and more statistical information is generated during system operation. The traditional method of updating statistical information is to directly update the statistical information in real time to the global shared memory. The statistical information exists in the form of elements in the hash table.

[0004] However, since the hash table needs to be locked when updating or reading statistical information, lock conflicts are serious when the database is highly concurrency-prone, resulting in a waste of database performance and resources. Summary of the Invention

[0005] In order to solve the above technical problems, the present disclosure provides a database statistical information updating method, apparatus, device and medium to avoid serious lock conflicts in high concurrency situations of the database, save system resources and effectively improve database usage efficiency.

[0006] In a first aspect, an embodiment of the present disclosure provides a method for updating database statistical information, characterized in that it is applied to an electronic device in which a statistical process and at least one session process are running, and the method includes:

[0007] The session process caches the statistical information generated during the execution of user commands in a local statistical information database;

[0008] When a preset condition is met, the session process aggregates the statistical information in the local statistical information base into a data packet and sends the data packet to the statistical process;

[0009] The statistical process receives the data packet sent by the session process and updates the statistical information in the data packet into the local memory.

[0010] In a second aspect, an embodiment of the present disclosure provides a database statistical information updating device, characterized in that the device is provided in an electronic device, wherein a statistical process and at least one session process are running in the electronic device, and the device includes:

[0011] A cache module, configured for the session process to cache statistical information generated during the execution of user commands in a local statistical information database;

[0012] an aggregation module, configured to, when a preset condition is met, cause the session process to aggregate the statistical information in the local statistical information base into a data packet and send the data packet to the statistical process;

[0013] The receiving module is used for the statistical process to receive the data packet sent by the session process and update the statistical information in the data packet into the local memory.

[0014] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0015] Memory;

[0016] processor; and

[0017] computer programs;

[0018] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.

[0019] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.

[0020] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, implements the database statistical information updating method as described above.

[0021] The database statistical information updating method, apparatus, device and medium provided by the embodiments of the present disclosure cache the statistical information generated during the session process in a local statistical information library, further introduce the statistical process and allocate local memory for it. Therefore, when the statistical information in the local memory is updated according to the statistical information in the local statistical information library, there is no need to lock it, which effectively avoids lock conflicts when updating statistical information in the database, saves computing resources, and effectively improves the utilization efficiency of the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0023] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0024] Figure 1 A flowchart of a method for updating database statistical information provided by an embodiment of the present disclosure;

[0025] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;

[0026] Figure 3 A flowchart of a method for updating database statistical information provided by another embodiment of the present disclosure;

[0027] Figure 4 A schematic diagram of a method for updating database statistical information provided by another embodiment of the present disclosure;

[0028] Figure 5 A schematic diagram of the structure of a database statistical information updating device provided in an embodiment of the present disclosure;

[0029] Figure 6 A schematic diagram of the electronic device structure provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0030] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0031] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0032] As database services become increasingly complex, the amount of statistical information generated during system operation is increasing, reaching tens of thousands per second. Traditionally, statistics are updated using shared memory. Each session collects and updates statistics simultaneously, with all statistics being updated in real time to the global shared memory. When a session queries statistics, it also reads directly from this global shared memory. Statistics are typically stored as elements in a hash table, so updating statistics requires locking. For example, adding new statistics requires an exclusive lock on the entire hash table, blocking read and write access by other sessions. Updating existing statistics requires an exclusive lock on the corresponding element, blocking other sessions from reading the statistic. When a session queries statistics, a shared lock on the hash table is required, blocking other processes from updating elements in the hash table. This locking mechanism can lead to severe lock conflicts in high-concurrency scenarios, significantly reducing database performance and even impacting normal database operation. To address this issue, an embodiment of the present disclosure provides a method for updating database statistical information, which is described below in conjunction with specific embodiments.

[0033] Figure 1 This is a flow chart of the database statistical information updating method provided by the embodiment of the present disclosure. This method can be applied to Figure 2 The application scenario shown includes an electronic device 20, a statistics process and at least one conversation process. Figure 2 For example, electronic device 20 includes a conversation process 21 and a statistics process 22. Electronic device 20 may be a terminal, such as a smartphone, a PDA, a tablet computer, a wearable device with a display, a desktop computer, a laptop computer, an all-in-one computer, a smart home device, etc. It is understood that the database statistics information updating method provided in the embodiments of the present disclosure may also be applied in other scenarios.

[0034] The following combination Figure 2 The application scenario shown is Figure 1 The method for updating database statistics is described below. The specific steps of the method are as follows:

[0035] S101: The session process caches statistical information generated during the execution of user commands in a local statistical information database.

[0036] When the database is started, statistics process 22 is started along with the database. During database operation, one or more session processes, such as session process 21, are called based on user commands. User commands can be Structured Query Language (SQL) statements. When executing user commands, session process 21 generates a large amount of statistical information. Because statistical information is auxiliary information in the database and does not require real-time updates, the statistical information generated by session process 21 when executing user commands is not immediately sent to statistics process 22. Instead, it is first cached in a local statistical information repository, which resides in the private memory corresponding to session process 21.

[0037] S102: When a preset condition is met, the session process aggregates the statistical information in the local statistical information base into a data packet, and sends the data packet to the statistical process.

[0038] When the preset conditions are met, the session process 21 packages the statistical information cached in its corresponding local statistical information database into a data packet and sends it to the statistical process 22 via a communication protocol, which may be a User Datagram Protocol (UDP).

[0039] S103: The statistics process receives the data packet sent by the session process, and updates the statistical information in the data packet into the local memory.

[0040] After receiving the data packet sent by the session process 21, the statistical process 22 obtains the statistical information contained therein and updates the statistical information to the local memory corresponding to the statistical process 22. It is understandable that if new statistical information is received, it will be added to the local memory. If a new version of statistical information already in the local memory is received, the old version of the statistical information in the local memory will be updated to the new version of the statistical information. It should be noted that the local memory corresponding to the statistical process 22 is not shared memory. Only the statistical process 22 can read, write, and access the local memory. Therefore, when the statistical process 22 updates the statistical information in the local memory, it does not need to lock it.

[0041] The embodiment of the present disclosure caches the statistical information generated during the execution of user commands in a local statistical information repository through the session process; when a preset condition is met, the session process aggregates the statistical information in the local statistical information repository into a data packet and sends the data packet to the statistical process; the statistical process receives the data packet sent by the session process and updates the statistical information in the data packet to the local memory. By first caching the statistical information generated during the session process in the local statistical information repository, further introducing the statistical process and allocating local memory to it, it is not necessary to lock the statistical information in the local memory when updating the statistical information in the local statistical information repository, thereby effectively avoiding lock conflicts when updating statistical information in the database, saving system resources, and effectively improving the efficiency of database use.

[0042] Based on the above embodiment, the preset conditions include at least: the user command is executed; or the amount of statistical information in the local statistical information library reaches a preset amount; or the cache time reaches a preset time.

[0043] Depending on the user command, session process 21 may include one or more wait events, each of which generates multiple pieces of statistical information. If each piece of statistical information generated were sent to statistics process 22 in real time, system performance would still be affected. Therefore, in this embodiment, the statistical information is first cached in a local statistical information repository. When the user command is executed, that is, when the current database transaction is executed, session process 21 packages the statistical information cached in the local statistical information repository and sends it to statistics process 22.

[0044] However, sometimes user commands are more complex, and the session process 21 takes a long time to execute the command. During this process, an excessive amount of statistical information is generated, which further leads to an excessive amount of statistical information cached in the local statistical information library. The database maintenance personnel can set a threshold for the amount of statistical information cached in the local statistical information library based on actual needs. For example, the preset number can be 1000 or any other integer value. When the amount of statistical information cached in the local statistical information library reaches a preset number, the preset number of statistical information in the local statistical information library is collected into a data packet and sent to the statistical process 22; alternatively, the database maintenance personnel can set a preset time, for example, the preset time can be 30 seconds or any other length of time. When the cache time for the session process 21 to cache the statistical information in the local statistical information library reaches the preset time, the preset number of statistical information in the local statistical information library is collected into a data packet and sent to the statistical process 22. That is, when the session process 21 continues to run for a preset time, all the statistical information in the local statistical information library is collected into a data packet and sent to the statistical process 22. It is understandable that, in actual implementation, database maintenance personnel may select one or more of the above preset conditions as needed, or may set other reasonable preset conditions, which is not limited in the embodiments of the present disclosure.

[0045] The embodiment of the present disclosure caches the statistical information generated when the session process executes user commands in a local statistical information library, and further sets preset conditions to control the frequency of the session process sending statistical information data packets, thereby avoiding the impact of the session process frequently sending statistical information to the statistical process on system performance, and further improving the efficiency of the database statistical information update method.

[0046] Figure 3 A flowchart of a method for updating database statistics information provided by another embodiment of the present disclosure is shown in FIG. Figure 3 As shown, the method includes the following steps:

[0047] S301: The session process caches statistical information generated during the execution of user commands in a local statistical information database.

[0048] S302: When a preset condition is met, the session process aggregates the statistical information in the local statistical information base into a data packet, and sends the data packet to the statistical process.

[0049] S303: The statistics process receives the data packet sent by the session process, and updates the statistical information in the data packet into the local memory.

[0050] Specifically, the implementation process and principle of S301 to S303 are the same as those of S101 to S103 and will not be repeated here.

[0051] S304: The conversation process sends a query request to the statistics process.

[0052] When the database needs to be maintained, the statistical information can be queried through the session process. At this time, the session process 21 sends a query request to the statistical process 22. The query request is also sent to the statistical process 22 in the form of a data packet through the communication protocol.

[0053] S305: The statistical process receives the query request and saves the statistical information in the local memory to a specified directory in the disk.

[0054] After receiving the query request from session process 21, statistics process 22 saves the latest version of the statistical information in its local memory to a specified directory on disk. Only statistics process 22 can access its local memory, while all processes can access the data on disk. Therefore, when querying statistical information, it must first be saved to disk. Furthermore, to save disk search time, a directory can be pre-specified for storing the statistical information saved by statistics process 22.

[0055] It should be noted that the statistics process 22 will exit when the database is closed. Before exiting, the statistics process 22 will save the latest version of the statistics information currently in the local memory to disk. The next time the database is started, the statistics process 22 will also start and read the local memory corresponding to the statistics information saved on disk, and perform subsequent updates based on this.

[0056] S306: After the conversation process waits for a preset time, it reads the files in the specified directory on the disk to obtain the time information of the files.

[0057] Because it takes time for the statistics process 22 to write the statistics in its local memory to the disk, the session process 21 waits for a preset time after sending the query request before reading the file in the specified directory on the disk and obtaining the time information from the timestamp of the file. The preset time can be 1 second or any other length of time.

[0058] S307 , judging whether the version of the file is the latest version according to the time information of the file, if so, executing S308 ; if not, executing S306 .

[0059] Normally, after a preset time, the statistical process 22 can save the statistical information in its corresponding local memory to the disk. However, sometimes due to excessive statistical information that needs to be saved or other reasons, the statistical process 22 may not save the statistical information in the local memory to the disk after the preset time has passed. Therefore, it is necessary to determine the version of the file on the disk. Based on the time information of the file, it can be determined whether the file is the latest version of the statistical information. The closer the time represented by the time information of the file is to the current time, the newer the version of the file is, and the greater the reference value for database maintenance personnel. If the time represented by the time information of the file is close to the current time, it means that the version of the file is the latest version, and S308 is executed; if the time represented by the time information of the file is far from the current time, it means that the version of the file is a historical version and not the latest version, and S306 is executed. In actual situations, a time threshold can be set. If the difference between the time represented by the time information of the file and the current time exceeds the time threshold, it is considered that the statistical information in the version file is not the latest version, and the process returns to S306 and loops through S306-S307 until it is confirmed that the version of the file is the latest version, and S308 is executed.

[0060] S308: Obtain statistical information in the file.

[0061] After determining that the file version is the latest version, the session process 21 reads the file and obtains statistical information in the file.

[0062] The disclosed embodiment sends a query request to the statistical process through the session process; the statistical process receives the query request and saves the statistical information in the local memory to a specified directory on the disk; the session process waits for a preset time, reads the file in the specified directory on the disk, and obtains the time information of the file; determines whether the version of the file is the latest version based on the time information of the file; if the version of the file is the latest version, obtains the statistical information in the file; if the version of the file is not the latest version, waits for a preset time and reads the file in the specified directory on the disk again. By saving the statistical information to the disk for the session process to read, lock conflicts in the process of querying statistical information are avoided, while ensuring that the queried statistical information is the latest version and that the number of times the statistical information is queried occurs is very small, further reducing the impact on system performance and improving query efficiency.

[0063] Figure 4 A schematic diagram of a method for updating database statistical information provided by another embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the method includes the following steps:

[0064] S401: The session process caches the statistical information generated during the execution of user commands in a local statistical information database.

[0065] S402: When a preset condition is met, the session process aggregates the statistical information in the local statistical information base into a data packet, and sends the data packet to the statistical process.

[0066] Specifically, the implementation process and principle of S401-S402 are the same as those of S101-S102, and will not be repeated here.

[0067] S403: The statistics process receives the data packet sent by the session process, and updates the statistical information in the data packet into the local memory.

[0068] Among them, the local memory corresponding to the statistical process includes a global wait event hash table and a global other statistical information storage table. The statistical information generated by the session process executing the wait event exists in the form of elements in the global wait event hash table, and other statistical information is stored in the global other statistical information storage table.

[0069] Specifically, the implementation process and principle of S403 and S103 are the same and will not be repeated here.

[0070] S404: The session process caches the statistical information generated during the execution of the user command in a local statistical information database.

[0071] S405: When a preset condition is met, the session process aggregates the statistical information in the local statistical information base into a data packet, and sends the data packet to the statistical process.

[0072] Specifically, the implementation process and principle of S404-S405 are the same as those of S101-S102, and will not be repeated here.

[0073] S406: The conversation process sends a query request to the statistics process.

[0074] Session process n sends a query request to the statistics process. This query request is also sent to the statistics process via a communication protocol in the form of a data packet. It is understood that this query request can be combined with the previously generated statistical information in session process n into a single data packet and sent to the statistics process, or it can be encapsulated as a separate data packet and sent to the statistics process. Database maintenance personnel can configure this according to actual needs.

[0075] S407: The statistics process receives the data packet sent by the session process, and updates the statistical information in the data packet into the local memory.

[0076] Specifically, the implementation process and principle of S407 and S103 are the same and will not be repeated here.

[0077] S408: The statistical process receives the query request and saves the statistical information in the local memory to a specified directory in the disk.

[0078] The statistics process receives a data packet from session process n. The data packet contains statistical information generated by session process n executing user commands and query requests sent by session process n. The statistics process stores the statistical information generated by session process n in local memory. When it receives a query request from session process n, it saves the statistical information currently in local memory to a specified directory on disk.

[0079] S409: After the session process waits for a preset time, it reads the files in the specified directory on the disk to obtain statistical information.

[0080] Optionally, after the session process waits for a preset time, it reads a file in a specified directory on the disk to obtain time information of the file;

[0081] Determine whether the version of the file is the latest version according to the time information of the file;

[0082] If the version of the file is the latest version, obtaining statistical information in the file;

[0083] If the version of the file is not the latest version, the system will wait for a preset time and then read the file in the specified directory on the disk again.

[0084] Specifically, the implementation process and principle of S408 to S409 are consistent with those of S305 to S308, and will not be repeated here.

[0085] The embodiment of the present disclosure caches the statistical information generated by the session process executing the user command into a local statistical information library first, and sends the statistical information to the statistical process in the form of a data packet when the preset conditions are met. The statistical process saves the statistical information into the local memory; when querying the statistical information, the statistical process stores the statistical information in the local memory to the disk for the session process to access, thereby realizing local caching and asynchronous updating of statistical information without the need to use global shared memory, completely avoiding the lock conflicts caused by centralized shared memory access, and effectively reducing the waste of system resources.

[0086] It should be noted that, for the sake of simplicity, the aforementioned method embodiments are all expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.

[0087] Figure 5This is a schematic diagram of the structure of the database statistical information updating device provided in the embodiment of the present disclosure. The database statistical information updating device can be the device to be upgraded as described in the above embodiment, or the database statistical information updating device can be a component or assembly in the device to be upgraded. The database statistical information updating device provided in the embodiment of the present disclosure can execute the processing flow provided in the embodiment of the database statistical information updating method, such as Figure 5 As shown, the database statistical information updating device 500 includes: a cache module 510, a collection module 520, and a receiving module 530. The cache module 510 is used by the session process to cache the statistical information generated during the execution of user commands in a local statistical information database; the collection module 520 is used by the session process to collect the statistical information in the local statistical information database into a data packet and send the data packet to the statistical process when a preset condition is met; the receiving module 530 is used by the statistical process to receive the data packet sent by the session process and update the statistical information in the data packet to the local memory. The preset conditions include at least: the user command is executed; the number of statistical information in the local statistical information database reaches a preset number; or the cache time reaches a preset time.

[0088] The database statistical information updating device 500 further includes: a query module 540, a storage module 550, and an acquisition module 560. The query module 540 is configured for the session process to send a query request to the statistics process; the storage module 550 is configured for the statistics process to receive the query request and save the statistical information in the local memory to a specified directory on the disk; and the acquisition module 560 is configured for the session process to wait for a preset time and then read the file in the specified directory on the disk to obtain the statistical information.

[0089] Optionally, the acquisition module 560 is also used for: after the session process waits for a preset time, reading the file in the specified directory on the disk to obtain the time information of the file; judging whether the version of the file is the latest version based on the time information of the file; if the version of the file is the latest version, obtaining the statistical information in the file; if the version of the file is not the latest version, waiting for a preset time, and then reading the file in the specified directory on the disk again.

[0090] Figure 5 The database statistical information updating device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0091] Figure 6 The electronic device provided by the embodiment of the present disclosure can execute the processing flow provided by the embodiment of the method for updating database statistical information, such as Figure 6As shown, the electronic device 60 includes: a memory 61, a processor 62, a computer program and a communication interface 63; wherein the computer program is stored in the memory 61 and is configured so that the processor 62 executes the above-mentioned database statistical information updating method.

[0092] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the database statistical information updating method described in the above embodiment.

[0093] In addition, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the database statistical information updating method described above is implemented.

[0094] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0095] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A method for updating database statistical information, characterized in that: Applied to an electronic device, wherein a statistics process and at least one conversation process are running in the electronic device, the method includes: The session process caches the statistical information generated during the execution of user commands in a local statistical information database; When a preset condition is met, the session process aggregates the statistical information in the local statistical information base into a data packet and sends the data packet to the statistical process; The statistical process receives the data packet sent by the session process and updates the statistical information in the data packet into the local memory, which is only read and written by the statistical process.

2. The method according to claim 1, characterized in that The preset conditions at least include: The user command has been executed; or The amount of statistical information in the local statistical information database reaches a preset amount; or The cache time reaches the preset time.

3. The method according to claim 1, characterized in that The method further comprises: The conversation process sends a query request to the statistics process; The statistical process receives the query request and saves the statistical information in the local memory to a specified directory on the disk; After the session process waits for a preset time, it reads the files in the specified directory on the disk to obtain statistical information.

4. The method according to claim 3, characterized in that After waiting for a preset time, the session process reads the files in the specified directory on the disk to obtain statistical information, including: After the session process waits for a preset time, it reads the file in the specified directory on the disk and obtains the time information of the file; Determine whether the version of the file is the latest version according to the time information of the file; If the version of the file is the latest version, obtaining statistical information in the file; If the version of the file is not the latest version, the system will wait for a preset time and then read the file in the specified directory on the disk again.

5. A database statistical information updating device, characterized in that: The device is provided in an electronic device, wherein a statistics process and at least one conversation process are running in the electronic device, and the device includes: A cache module, configured for the session process to cache statistical information generated during the execution of user commands in a local statistical information database; an aggregation module, configured to, when a preset condition is met, cause the session process to aggregate the statistical information in the local statistical information base into a data packet and send the data packet to the statistical process; The receiving module is used for the statistical process to receive the data packet sent by the session process and update the statistical information in the data packet into the local memory, which is only read and written by the statistical process.

6. The device according to claim 5, characterized in that The preset conditions at least include: The user command has been executed; or The amount of statistical information in the local statistical information database reaches a preset amount; or The cache time reaches the preset time.

7. The device according to claim 5, characterized in that The device further comprises: A query module, configured for the conversation process to send a query request to the statistics process; A saving module, configured to save the statistical information in the local memory to a specified directory on the disk upon receipt of a query request by the statistical process; The acquisition module is used for reading files in a specified directory in the disk to obtain statistical information after the session process waits for a preset time.

8. The device according to claim 7, characterized in that The acquisition module is further used for: After the session process waits for a preset time, it reads the file in the specified directory on the disk and obtains the time information of the file; Determine whether the version of the file is the latest version according to the time information of the file; If the version of the file is the latest version, obtaining statistical information in the file; If the version of the file is not the latest version, the system will wait for a preset time and then read the file in the specified directory on the disk again.

9. An electronic device, characterized in that: include: Memory; processor; as well as computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method according to any one of claims 1 to 4.

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

Citation Information

Patent Citations

  • Method, device and system for processing read-write request statistical information

    CN110688231A

  • Optimized collection of just-in-time statistics for database query optimization

    US20090216709A1