Execution method and device for database maintenance operation and storage medium

By judging whether to perform maintenance operations based on the bloat information, fragmented information and performance of the database table, and performing VACUUM FULL at an appropriate time, the problem of VACUUM FULL operations affecting services in the prior art is solved, and the database performance is significantly improved.

CN119537360APending Publication Date: 2025-02-28AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411689731.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The prior art is difficult to perform VACUUM FULL operations of the database in a timely manner without affecting normal services, resulting in a degradation of database performance.

Method used

By determining whether to perform maintenance operations based on at least one of the bloat information, fragmented information and performance of the database table, and performing maintenance operations to completely clean up VACUUM FULL on the database when the current time is within the executable time range.

Benefits of technology

Without affecting normal business, VACUUM FULL can be executed in a timely manner, which significantly improves the performance of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537360A_ABST
    Figure CN119537360A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a database maintenance operation execution method and device and a storage medium. The method comprises the steps of determining whether to execute maintenance operation or not according to at least one of expansion information, fragmentation information and performance of a database table in a database; and under the condition that the maintenance operation is determined to be executed and the current time is within the executable time range, executing the maintenance operation of completely cleaning the VACUUM FULL on the database. According to the method, VACUUM FULL can be executed in time under the condition that normal services are not affected, and the performance of a database system is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to computer technology, and in particular to a method, device and storage medium for executing database maintenance operations. Background Art

[0002] With the advancement of technology and the advent of the big data era, databases are used more and more widely. VACUUM and VACUUM FULL are both important operations for maintaining and optimizing database performance.

[0003] A standard VACUUM operation reclaims space occupied by deleted or updated rows, making that space available for future use. VACUUM does not lock the table, allowing normal read and write operations to continue. VACUUM operations can prevent tables from growing too large, thereby optimizing performance. VACUUM FULL is a more thorough operation that rebuilds the entire table, shrinking the table file size. VACUUM FULL locks the table, preventing other read and write operations until the operation is complete. VACUUM FULL can significantly reduce the physical size of a table, freeing up large amounts of disk space back to the operating system.

[0004] As database tables are constantly updated and deleted, if VACUUM or VACUUM FULL is not performed regularly, the database tables may swell, resulting in reduced performance of index scans and full table scans. Therefore, how to perform VACUUM FULL is a technical problem that technicians in this field need to solve urgently. Summary of the invention

[0005] The embodiments of the present application provide a method, device, and storage medium for executing database maintenance operations, so as to achieve the effect of timely executing VACUUM FULL without affecting normal business, thereby significantly improving the performance of the database system.

[0006] In a first aspect, an embodiment of the present application provides a method for executing a database maintenance operation, including:

[0007] Determining whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database;

[0008] If it is determined to perform the maintenance operation and the current time is within an executable time range, a maintenance operation of VACUUM FULL is performed on the database.

[0009] In a possible implementation manner, the current time is within the executable time range, including:

[0010] The current time is during a business off-peak period or a planned downtime maintenance period.

[0011] In a possible implementation, determining whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database includes:

[0012] When a target condition is met, it is determined to perform a maintenance operation; the target condition includes at least one of the following:

[0013] The expansion information is within a first preset range;

[0014] The fragmented information is within a second preset range;

[0015] The value of the target parameter corresponding to the performance is within a third preset range;

[0016] The target parameters include at least one of the following: query performance, transaction processing performance, throughput, response time, data integrity, data consistency, latency, availability and reliability.

[0017] In a possible implementation manner, before performing the maintenance operation of completely cleaning up the database with VACUUM FULL, the method further includes:

[0018] Determine a target object for performing the maintenance operation according to at least one of the expansion information, fragmentation information, performance, device capability information, and priority of a database table, the target object comprising: at least one database table;

[0019] Perform a VACUUM FULL maintenance operation on the database, including:

[0020] The VACUUM FULL maintenance operation is performed on the target object.

[0021] In a possible implementation, the performing a maintenance operation of completely cleaning up the database using VACUUM FULL includes:

[0022] Receive operation instructions for the target database table;

[0023] In response to the operation instruction, the VACUUM FULL maintenance operation is performed on the target database table.

[0024] In a possible implementation, the method further includes:

[0025] receiving a target maintenance task request, wherein the target maintenance task request is used to request execution of at least one of the following operations: backup, index reconstruction;

[0026] The maintenance operation of performing a complete cleanup VACUUM FULL on the database includes:

[0027] According to the task request, an operation corresponding to the task request and the maintenance operation of VACUUM FULL are executed.

[0028] In a possible implementation, the method further includes:

[0029] When the target condition is met, an alarm message is output and the VACUUM FULL maintenance operation is automatically performed, wherein the alarm message is used to notify the user that the VACUUM FULL maintenance operation needs to be performed.

[0030] In a possible implementation, determining whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database includes:

[0031] Whether to perform a maintenance operation is determined periodically by an automated tool or script based on at least one of expansion information, fragmentation information, and performance of a database table in the database.

[0032] In a second aspect, an embodiment of the present application provides a device for executing a database maintenance operation, including:

[0033] A determination module, configured to determine whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database;

[0034] The processing module is used to perform a maintenance operation of VACUUM FULL on the database when the determining module determines to perform the maintenance operation and the current time is within an executable time range.

[0035] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;

[0036] The memory stores computer-executable instructions;

[0037] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.

[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.

[0039] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.

[0040] The method, device and storage medium for executing database maintenance operations provided in the embodiments of the present application determine whether to execute the maintenance operation according to at least one of the expansion information, fragmentation information and performance of the database table in the database; if it is determined to execute the maintenance operation and the current time is within the executable time range, a maintenance operation of completely cleaning up VACUUM FULL is executed on the database, that is, whether to execute the maintenance operation is determined according to at least one of the expansion information, fragmentation information and performance, and VACUUM FULL can be executed in time when the maintenance operation needs to be executed and normal business is not affected, thereby significantly improving the performance of the database system. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0042] Figure 1 A schematic diagram of a scenario of a method for executing a database maintenance operation provided in this application;

[0043] Figure 2 Schematic diagram of the execution method of the database maintenance operation provided in this application Figure 1 ;

[0044] Figure 3 A schematic diagram of the structure of the execution device of the database maintenance operation provided by this application;

[0045] Figure 4 A schematic diagram of the structure of the electronic device provided in this application.

[0046] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0047] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0048] First, the application scenarios involved in this application are introduced:

[0049] Figure 1 A schematic diagram of a scenario of a method for executing a database maintenance operation provided in this application, such as Figure 1 As shown, the specific application scenario of the present application includes: a database system 101 and an operation and maintenance device 102 , and the operation and maintenance device 102 is connected to the database system 101 .

[0050] In some embodiments, the database system 101 includes a database server and a database, wherein the database server is used to manage transaction processing and data access of the database.

[0051] The operation and maintenance device 102 can monitor and manage the operation status of the database in the database system 101 .

[0052] In the above-mentioned application scenarios, the execution method of the database maintenance operation of the embodiment of the present application can generally be executed by the database server and / or operation and maintenance equipment in the database system 101, for example, by the database server or the operation and maintenance equipment alone, or by the database server and the operation and maintenance equipment cooperating with each other to execute the method.

[0053] It should be noted that Figure 1 What is shown is merely an example of a system architecture to which the method of the embodiment of the present application can be applied, in order to help those skilled in the art understand the technical content of the present application, and the embodiment of the present application is not limited thereto.

[0054] VACUUM FULL can significantly reduce the physical size of a table, freeing up a lot of disk space for the operating system. However, VACUUM FULL locks the table, preventing other read and write operations until the operation is completed. Therefore, how to execute VACUUM FULL is a technical problem that technicians in this field need to solve urgently.

[0055] The method for executing a database maintenance operation provided by the present application determines whether to execute a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database; if it is determined to execute the maintenance operation and the current time is within an executable time range, a maintenance operation of completely cleaning up VACUUM FULL is executed on the database, that is, VACUUM FULL can be executed in time without affecting normal business, thereby significantly improving the performance of the database system.

[0056] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0057] Figure 2 Schematic diagram of the execution method of the database maintenance operation provided in this application Figure 1 ,like Figure 2 As shown, the method includes:

[0058] S201: Determine whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in a database.

[0059] Specifically, database table expansion usually refers to the unnecessary growth of physical storage space due to frequent insert, update or delete operations on the database table. Even if some data has been deleted or updated, the size of the database file may not shrink automatically because the old data space may still be occupied or marked as "used", resulting in a waste of storage resources.

[0060] Fragmentation of database tables refers to the phenomenon that in a database system, due to data insertion, update or deletion operations, data is not stored continuously on the storage medium, thus affecting performance. Fragmentation will lead to an increase in I / O operations of the physical storage medium because the system needs to search for data in multiple locations, thereby reducing the efficiency of query and update operations and causing a waste of storage resources.

[0061] Since the expansion or fragmentation of database tables will waste storage resources and affect the performance of the database, etc., it can be determined whether to perform maintenance operations based on at least one of the expansion information, fragmentation information and performance, such as optimizing the data table or index table, such as rebuilding the index, that is, reorganizing the data by rebuilding the index so that it is stored continuously; or reorganizing the data table, that is, reorganizing the data table to reduce fragmentation.

[0062] In some embodiments, database fragmentation mainly includes the following types:

[0063] 1. Data fragmentation: Data fragmentation occurs when data blocks are not stored contiguously on the physical storage medium. This is usually caused by frequent insertion and deletion operations, especially in fixed-size data blocks.

[0064] 2. Index fragmentation: Index pages are not stored continuously on the physical storage medium, or the index hierarchy is unbalanced, resulting in reduced search efficiency.

[0065] 3. Internal fragmentation: There is unused space in data pages or blocks.

[0066] 4. External fragmentation: There is unused space between data pages or blocks, resulting in discontinuous storage of data on the physical storage medium.

[0067] S202: When it is determined that a maintenance operation is to be performed and the current time is within an executable time range, a maintenance operation of VACUUM FULL is performed on the database.

[0068] Specifically, when it is determined in S201 that a maintenance operation is to be performed, it is further determined whether the current time is within the executable time range to reduce the impact on normal business. If the current time is within the preset executable time range, a maintenance operation of VACUUM FULL is performed on the database.

[0069] Optionally, if the current time is not within the preset executable time range, you can wait for a while and perform a VACUUM FULL maintenance operation on the database within the executable time range.

[0070] Optionally, the database system may be monitored in real time or periodically, for example, by using monitoring tools and SQL queries in real time or periodically to evaluate the expansion and fragmentation of each database table.

[0071] For example, when it is found that the database tables and indexes are severely expanded and the performance is significantly degraded, VACUUM FULL is executed to completely reorganize the database tables and indexes.

[0072] The method for executing a database maintenance operation provided in an embodiment of the present application determines whether to execute a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database; if it is determined to execute the maintenance operation and the current time is within an executable time range, a maintenance operation of completely cleaning up VACUUM FULL is executed on the database, that is, whether to execute the maintenance operation is determined according to at least one of expansion information, fragmentation information, and performance. When the maintenance operation needs to be executed and normal business is not affected, VACUUM FULL can be executed in time, thereby significantly improving the performance of the database system.

[0073] In some embodiments, “determining whether to perform a maintenance operation based on at least one of expansion information, fragmentation information, and performance of a database table in the database” is periodically performed by an automated tool or script.

[0074] Specifically, an automated tool or script that implements the relevant trigger judgment function can be developed and maintained. The automated tool or script can periodically execute the step of determining whether to perform a maintenance operation based on at least one of the expansion information, fragmentation information, and performance of the database table in the database. That is, the step of determining whether to perform a maintenance operation is periodically triggered by the automated tool or script, thereby ensuring that maintenance work is carried out in a timely manner and reducing the workload of database administrators.

[0075] In the above implementation, an automated tool or script is used to periodically determine whether to perform maintenance operations based on at least one of the expansion information, fragmentation information, and performance of the database table in the database, thereby ensuring that maintenance work is performed in a timely manner and reducing the workload of database administrators.

[0076] In some embodiments, the current time is within an executable time range, including:

[0077] The current time is during a business off-peak period or a planned downtime maintenance period.

[0078] Specifically, the off-peak period may refer to a period when the database is less accessed or when the database processes fewer transactions. During this period, the access volume or transaction volume of the database system is significantly lower than the peak level of its designed capacity.

[0079] For example, the business off-peak period is a time when the number of businesses accessing the database is less than a preset number, or a time when the number of database accesses is less than a preset number.

[0080] Because the database utilization rate is low during the business off-peak period and the impact on the business is small, you can perform maintenance operations, such as VACUUM FULL operations, when the current time is in the business off-peak period or during planned downtime maintenance.

[0081] For example, triggering VACUUM FULL can be scheduled according to specific needs and the best executable time, such as during off-peak business hours or during planned downtime maintenance to minimize the impact on normal business. It can be performed after the database administrator has conducted a comprehensive assessment of the database system to ensure that it is executed at the most appropriate time.

[0082] In the above implementation, when performing maintenance operations, the execution time of VACUUM FULL is evaluated, and the time window for the operation execution is reasonably arranged to complete the maintenance operation in an automated manner, thereby improving the robustness of the database.

[0083] In some embodiments, determining whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database includes:

[0084] When a target condition is met, it is determined to perform a maintenance operation; the target condition includes at least one of the following:

[0085] The expansion information is within a first preset range;

[0086] The fragmented information is within a second preset range;

[0087] The value of the target parameter corresponding to the performance is within a third preset range;

[0088] The target parameters include at least one of the following: query performance, transaction processing performance, throughput, response time, data integrity, data consistency, latency, availability and reliability.

[0089] Specifically, when at least one target condition is met, it is determined to perform the maintenance operation:

[0090] The expansion information is within a first preset range;

[0091] The fragmented information is within a second preset range;

[0092] The value of the target parameter corresponding to the performance is within a third preset range;

[0093] The expansion information is within a first preset range, for example, the growth rate of the storage space capacity occupied by the database may be greater than or equal to a preset threshold;

[0094] The fragmentation information is within a second preset range, for example, the fragmentation degree may be greater than or equal to a degree threshold.

[0095] The value of the target parameter corresponding to the performance is within a third preset range. For example, the value of the target parameter may be greater than or equal to (or less than or equal to) a parameter threshold, such as the query speed (or query efficiency) in the query performance, which is less than or equal to the query performance threshold, and the delay is greater than or equal to the delay threshold.

[0096] The target parameters include at least one of the following: query performance, transaction processing performance, throughput, response time, data integrity, data consistency, latency, availability and reliability.

[0097] Among them, transaction processing performance refers to the speed and efficiency of processing transactions, such as inserting, deleting, and updating.

[0098] Response time refers to the time from when a request is sent to when a response is received.

[0099] Throughput refers to the number of transactions that a database system can process per unit time. High throughput means that the system can process a large number of task requests in a short period of time.

[0100] Data consistency and integrity indicate whether the data being operated is consistent or complete under different performance environments, for example, whether the queried data is consistent or complete.

[0101] Availability indicates whether the database is available, for example, whether it is available when it is severely expanded or fragmented.

[0102] Reliability refers to the ability of a database system to continue to provide correct and consistent services under various conditions.

[0103] In the above implementation, whether to perform a maintenance operation is determined by determining whether at least one target condition is met, with high accuracy. VACUUM FULL can be performed when the database is severely bloated, fragmented, and performance is significantly degraded, thereby improving database performance.

[0104] In some embodiments, before "performing a maintenance operation of VACUUM FULL on the database" in S202, the following further includes:

[0105] Determine a target object for performing the maintenance operation according to at least one of the expansion information, fragmentation information, performance, device capability information, and priority of a database table, the target object comprising: at least one database table;

[0106] Perform a VACUUM FULL maintenance operation on the database, including:

[0107] The VACUUM FULL maintenance operation is performed on the target object.

[0108] Specifically, the device capability information refers to, for example, the throughput of the device, the load of the device, and other information.

[0109] It may be determined that the target object is one or more specific database tables, or the entire database, based on at least one of expansion information, fragmentation information, performance, device capability information, and priority of the database table.

[0110] The priority can be determined based on the importance of the database table or the business importance. For example, the database table corresponding to the key business has a higher priority, and the database table with frequent operations has a higher priority, such as the number of operations within a preset time range is greater than or equal to a preset number threshold, such as the database table that is frequently accessed or updated has a higher priority.

[0111] For example, when performing a maintenance operation of VACUUM FULL, VACUUM FULL may be performed on database tables with a higher priority and / or a higher degree of fragmentation;

[0112] Alternatively, you can perform VACUUM FULL on database tables with higher priority and / or greater bloat;

[0113] Alternatively, you can perform VACUUM FULL on database tables that are highly fragmented and / or bloated.

[0114] Alternatively, you can perform VACUUM FULL on higher priority, more fragmented, and more bloated database tables.

[0115] For example, VACUUMFULL can be performed on the tables of the entire database step by step in multiple maintenance time windows to avoid a high load on the database server caused by a one-time operation.

[0116] In the above implementation, the target object for executing the maintenance operation is determined according to at least one of the expansion information, fragmentation information, performance, device capability information, and priority of the database table, that is, the maintenance operation can be executed according to the specific needs of the database table, for example, the maintenance operation is executed on a database table that is severely expanded or fragmented, thereby improving the performance of the database system in a targeted manner. Executing VACUUM FULL can release database space and improve database access efficiency.

[0117] In some embodiments, the performing a maintenance operation of completely cleaning up the database with VACUUM FULL includes:

[0118] Receive operation instructions for the target database table;

[0119] In response to the operation instruction, the VACUUM FULL maintenance operation is performed on the target database table.

[0120] Specifically, before executing the VACUUM FULL maintenance operation, an operation instruction of the target database table may also be received, such as an instruction to maintain one or more specific database tables.

[0121] Therefore, in response to the operation instruction, a VACUUM FULL maintenance operation is performed on the target database table corresponding to the operation instruction.

[0122] For example, a user may manually trigger a maintenance operation on a specific database table based on the needs of the specific database table. For example, a VACUUM FULL operation may be performed separately for a database table that is particularly bloated or severely fragmented.

[0123] In the above implementation, the user can send an operation instruction through the operation and maintenance equipment to specify the target database table to be maintained, which is highly targeted and has greater flexibility in maintenance.

[0124] Optionally, when performing maintenance operations, you can also evaluate whether to perform a VACUUM FULL on the entire database at once, or on specific database tables.

[0125] In some embodiments, the method further comprises:

[0126] receiving a target maintenance task request, wherein the target maintenance task request is used to request execution of at least one of the following operations: backup, index reconstruction;

[0127] The maintenance operation of performing a complete cleanup VACUUM FULL on the database includes:

[0128] According to the task request, an operation corresponding to the task request and the maintenance operation of VACUUM FULL are executed.

[0129] Specifically, the VACUUM FULL operation can be combined with other maintenance tasks (such as backup, index rebuilding, etc.) to optimize the overall database system performance.

[0130] In some embodiments, the method for performing the database maintenance operation further includes:

[0131] When the target condition is met, an alarm message is output, where the alarm message is used to notify the user that the VACUUM FULL maintenance operation needs to be performed.

[0132] Specifically, after the alarm information is output, the maintenance operation of VACUUM FULL may be automatically performed, for example, the alarm information may be output to an operation and maintenance device, and the operation and maintenance device may display the alarm information to a user.

[0133] In the above implementation, by outputting alarm information, the user can be notified in time so that the maintenance operation can be performed as soon as possible to reduce the impact on normal business.

[0134] Optionally, during the execution of the method of the embodiment of the present application, a log is used to record the key links in the implementation process throughout the entire process to facilitate subsequent maintenance processing and optimize maintenance.

[0135] Figure 3 A schematic diagram of the structure of the execution device of the database maintenance operation provided by this application, such as Figure 3 As shown, the execution device of the database maintenance operation provided in this embodiment includes:

[0136] A determination module 301, configured to determine whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database;

[0137] The processing module 302 is configured to perform a maintenance operation of VACUUM FULL on the database if the determining module determines to perform a maintenance operation and the current time is within an executable time range.

[0138] In a possible implementation manner, the current time is within the executable time range, including:

[0139] The current time is during a business off-peak period or a planned downtime maintenance period.

[0140] In a possible implementation manner, the determining module 301 is specifically configured to:

[0141] When a target condition is met, it is determined to perform a maintenance operation; the target condition includes at least one of the following:

[0142] The expansion information is within a first preset range;

[0143] The fragmented information is within a second preset range;

[0144] The value of the target parameter corresponding to the performance is within a third preset range;

[0145] The target parameters include at least one of the following: query performance, transaction processing performance, throughput, response time, data integrity, data consistency, latency, availability and reliability.

[0146] In a possible implementation manner, the processing module 302 is further configured to:

[0147] Before performing a maintenance operation of VACUUM FULL on the database, determining a target object for performing the maintenance operation according to at least one of the expansion information, the fragmentation information, the performance, the device capability information, and the priority of the database table, the target object comprising: at least one database table;

[0148] The processing module 302 is specifically used for:

[0149] The VACUUM FULL maintenance operation is performed on the target object.

[0150] In a possible implementation manner, the processing module 302 is specifically configured to:

[0151] Receive operation instructions for the target database table;

[0152] In response to the operation instruction, the VACUUM FULL maintenance operation is performed on the target database table.

[0153] In a possible implementation manner, the processing module 302 is further configured to:

[0154] receiving a target maintenance task request, wherein the target maintenance task request is used to request execution of at least one of the following operations: backup, index reconstruction;

[0155] The processing module 302 is specifically used for:

[0156] According to the task request, an operation corresponding to the task request and the maintenance operation of VACUUM FULL are executed.

[0157] In a possible implementation manner, the processing module 302 is further configured to:

[0158] When the target condition is met, an alarm message is output, where the alarm message is used to notify the user that the VACUUM FULL maintenance operation needs to be performed.

[0159] In a possible implementation, the determining module 301 is specifically configured to:

[0160] Whether to perform a maintenance operation is determined periodically by an automated tool or script based on at least one of expansion information, fragmentation information, and performance of a database table in the database.

[0161] The execution device of the database maintenance operation provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.

[0162] Figure 4 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 4 As shown, the electronic device 40 provided in this embodiment includes: at least one processor 401 and a memory 402. Optionally, the device 40 also includes a communication component 403. The processor 401, the memory 402 and the communication component 403 are connected via a bus 404.

[0163] In a specific implementation process, at least one processor 401 executes the computer-executable instructions stored in the memory 402, so that at least one processor 401 executes the above method.

[0164] The specific implementation process of the processor 401 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.

[0165] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0166] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0167] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0168] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0169] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.

[0170] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.

[0171] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.

[0172] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0173] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0174] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0175] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0176] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0177] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A method for executing a database maintenance operation, characterized in that: include: Determining whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database; If it is determined to perform the maintenance operation and the current time is within an executable time range, a maintenance operation of VACUUM FULL is performed on the database.

2. The method according to claim 1, characterized in that The current time is within the executable time range, including: The current time is during a business off-peak period or a planned downtime maintenance period.

3. The method according to claim 1, characterized in that: Determining whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database includes: When a target condition is met, it is determined to perform a maintenance operation; the target condition includes at least one of the following: The expansion information is within a first preset range; The fragmented information is within a second preset range; The value of the target parameter corresponding to the performance is within a third preset range; The target parameters include at least one of the following: query performance, transaction processing performance, throughput, response time, data integrity, data consistency, latency, availability and reliability.

4. The method according to any one of claims 1 to 3, characterized in that: Before performing the maintenance operation of VACUUM FULL on the database, the following steps are also included: Determine a target object for performing the maintenance operation according to at least one of the expansion information, fragmentation information, performance, device capability information, and priority of a database table, the target object comprising: at least one database table; Perform a VACUUM FULL maintenance operation on the database, including: The VACUUM FULL maintenance operation is performed on the target object.

5. The method according to any one of claims 1 to 3, characterized in that: The maintenance operation of performing a complete cleanup VACUUM FULL on the database includes: Receive operation instructions for the target database table; In response to the operation instruction, the VACUUM FULL maintenance operation is performed on the target database table.

6. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: receiving a target maintenance task request, wherein the target maintenance task request is used to request execution of at least one of the following operations: backup, index reconstruction; The maintenance operation of performing a complete cleanup VACUUM FULL on the database includes: According to the task request, an operation corresponding to the task request and the maintenance operation of VACUUM FULL are executed.

7. The method according to claim 3, characterized in that The method further comprises: When the target condition is met, an alarm message is output, where the alarm message is used to notify the user that the VACUUM FULL maintenance operation needs to be performed.

8. A device for executing database maintenance operations, characterized in that: include: A determination module, configured to determine whether to perform a maintenance operation according to at least one of expansion information, fragmentation information, and performance of a database table in the database; The processing module is used to perform a maintenance operation of VACUUM FULL on the database when the determining module determines to perform the maintenance operation and the current time is within an executable time range.

9. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.