A User-Facing Non-Administrative Database Portfolio Cleanup Method
By querying storage time in the database, users choose cleaning time ranges and building an automatic cleaning process, the database cleaning problem with limited hard disk space is solved, and data deletion is realized independently controlled by users to ensure stable operation of the equipment and data storage.
Patent Information
- Application Number
- CN202210605982.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-05-31
AI Technical Summary
The historical data in the equipment software database cannot be cleaned efficiently, the hard disk space is limited and management tools are not installed, which makes it difficult for users to operate and may affect the stable operation of the equipment.
By querying the database historical information storage time, arranging it in sequence, users select the data cleaning time range, and construct an automatic cleaning process to detect disk utilization, and implement data deletion operations to control the hard disk utilization below the threshold.
It realizes that users can choose the data deletion time range independently, avoid one-size-fits-all cleaning, ensure that the hard disk utilization is within the security threshold, and maximize the storage of useful data.
Smart Images

Figure CN114936210B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of software data management, and particularly relates to a non - management - type database combination cleaning method for users. Background Art
[0002] The equipment software database efficiently stores the historical data of each device for users to query. However, the hard disk space of the equipment is limited and cannot store unlimitedly. Moreover, the equipment is restricted by the hardware configuration and cannot install management tools, so professional software personnel need to regularly clean the historical data in the database.
[0003] The length of the historical data stored in the database is related to the size of the hard disk space. Therefore, the database needs to be cleaned at an appropriate time. The cleaning steps for a database without installed management tools are relatively cumbersome. It is not only difficult for users to directly operate the database, but also likely to affect the stable operation of the equipment. Summary of the Invention
[0004] The purpose of the present invention is to overcome the deficiencies of the prior art and propose a non - management - type database combination cleaning method for users, which can avoid the one - size - fits - all cleaning method in equipment software, grant users the right to choose. When the hard disk space is limited, users can freely select the time range of data to be deleted, and the equipment software realizes the data deletion operation, so that the utilization rate of the equipment hard disk is always controlled below the automatic deletion threshold, achieving the purpose of saving useful data to the greatest extent.
[0005] The present invention solves its technical problems by adopting the following technical solutions:
[0006] A non - management - type database combination cleaning method for users includes the following steps:
[0007] Step 1: Query the storage time of historical information in the database and arrange it in order.
[0008] Step 2: Obtain the time range of data cleaning selected by the user, and perform data cleaning on the historical information sorted in step 1.
[0009] Step 3: Construct an automatic data cleaning process and detect whether automatic data cleaning is required.
[0010] Moreover, step 1 includes the following steps:
[0011] Step 1.1: The database executes the command "select tablename from pg_tables" to query the names of all data tables in the database, and stores the data table names in the form of strings into the tableNames variable.
[0012] Step 1.2: Traverse the content in the tableNames variable, obtain the index value of the position where the string "_20" is located, denote it as n, and determine whether n is less than 0. If it is less than 0, end the operation; otherwise, proceed to Step 1.3.
[0013] Step 1.3: Take the string content of the 6 consecutive digits after this index value to obtain a time information YYYYMM, and assign it to tableTimeNames.
[0014] Step 1.4: Determine whether the same time information exists in the QStringList time variable. If this information exists, set the index value n = n + 6, and return to Step 1.2 to continue traversing the tableNames variable from n; otherwise, store tableTimeNames in the QStringList time variable.
[0015] Moreover, Step 2 includes the following steps:
[0016] Step 2.1: Create a new QTableWidget object and set its operation property to be selectable.
[0017] Step 2.2: Create a new QTreeWidgetItem object item, make item the parent node of the tree structure, and display the name as "Select All".
[0018] Step 2.3: Traverse the historical information sorted in order in Step 1, create multiple QTreeWidgetItem objects to construct the child nodes of the tree structure, and display the names of the child nodes as time information.
[0019] Step 2.4: Use the childCount() function in the QWidgetItem class to determine whether the parent node is selected. If the return value of the function is greater than 0, it means the parent node is selected, and at the same time, output the time information of all historical information; otherwise, it means it is not selected, and proceed to Step 2.5.
[0020] Step 2.5: Use the childCount() function in the QWidgetItem class to determine whether the child node is selected. If the return value of the function is greater than 0, it means the child node is selected, output the time information corresponding to the child node; otherwise, it means it is not selected, and return to Step 2.4.
[0021] Step 2.6: Control the database to delete the historical information within the corresponding time according to the time information obtained in Step 2.4 and Step 2.5.
[0022] Moreover, Step 3 includes the following steps:
[0023] Step 3.1: Regularly detect the disk utilization rate and determine whether it is greater than 90%. If it is greater than 90%, proceed to Step 3.2; otherwise, end.
[0024] Step 3.2: Query the historical information storage time in the database according to the method in Step 1.
[0025] Step 3.3: Delete the data of the earliest month in the database according to the principle of first in first out.
[0026] Step 3.4: Detect the disk utilization rate. If the disk utilization rate is greater than the set value of 50%, if it is greater, return to Step 3.3; otherwise, end.
[0027] The advantages and positive effects of the present invention are:
[0028] The present invention queries the historical information storage time in the database, arranges it in order; obtains the data cleaning time range selected by the user, performs data cleaning on the historical information; constructs an automatic data cleaning process, and detects whether automatic data cleaning is required, realizing the database combination cleaning process. The present invention can avoid the one-size-fits-all cleaning method, authorizes the user to choose, and when the hard disk space is limited, the user can freely choose the time range of the data to be deleted, and the equipment software realizes the data deletion operation, so that the hard disk utilization rate of the equipment is always controlled below the automatic deletion threshold, achieving the purpose of saving useful data to the greatest extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is the flowchart of the present invention;
[0030] Figure 2 is the flowchart of querying the historical information storage time in the database of the present invention and arranging it in order
[0031] Figure 3 is the schematic diagram of the time selection attribute structure of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0032] The following further describes the present invention with reference to the accompanying drawings.
[0033] A user-oriented non-managerial database combination cleaning method, as Figure 1 shown, includes the following steps:
[0034] Step 1: Query the historical information storage time in the database and arrange it in order.
[0035] The present invention performs data cleaning operations according to the principle of first in, first out. First, it is necessary to query the storage time of the historical information of each device in the database. When the equipment software receives a query instruction, it controls the database to execute the command "select tablename from pg_tables;", which can query the names of all data tables in the database and store the data table names in the tableNames variable in the form of a string.
[0036] The database adopts a table partitioning structure. The name format of each data sub-table is table_YYYYMM, and the table name contains the year and month information of the storage time. Assuming that the storage time range of the historical information is between 2000 and 2099, the storage time information can be obtained by searching for the string "_20" in the tableNames variable. Define a QStringList variable to store the query time information. As Figure 1 shown, the specific search process of this step is as follows:
[0037] Step 1.1: The database executes the command "select tablename from pg_tables" to query the names of all data tables in the database and stores the data table names in the tableNames variable in the form of a string.
[0038] Step 1.2: Traverse the content in the tableNames variable to obtain the index value of the position where the string "_20" is located, denoted as n. Determine whether n is less than 0. If it is less than 0, end the operation; otherwise, proceed to Step 1.3.
[0039] Step 1.3: Take the consecutive 6-bit string content after this index value to obtain a time information YYYYMM and assign it to tableTimeNames.
[0040] Step 1.4: Determine whether the same time information exists in the QStringList time variable. If it exists, set the index value n = n + 6 and return to Step 1.2 to continue traversing the tableNames variable from n; otherwise, store tableTimeNames in the QStringList time variable.
[0041] Step 2: As Figure 3 shown, obtain the data cleaning time range selected by the user and perform data cleaning on the historical information sorted in Step 1.
[0042] Set a "Data Cleaning" button in the equipment software. After clicking the "Data Cleaning" button, the equipment software obtains the historical information storage time in the database according to Step 1. The software draws a tree structure of the data storage time through QTreeWidget. See Figure 2As shown, the user can freely select the time range for data cleaning according to needs. This step includes the following steps:
[0043] Step 2.1: Create a new QTableWidget object and set its operation property to be selectable;
[0044] Step 2.2: Create a new QTreeWidgetItem object item, make item the parent node of the tree structure, and display the name as "Select All";
[0045] Step 2.3: Traverse the historical information sorted in order in Step 1, create multiple QTreeWidgetItem objects to construct the child nodes of the tree structure, and display the name of the child nodes as "Time Information";
[0046] Step 2.4: Use the childCount() function in the QWidgetItem class to determine whether the parent node is selected. If the return value of the function is greater than 0, it means the parent node is selected, and at the same time, output the time information of all historical information. Otherwise, it means it is not selected, and proceed to Step 2.5;
[0047] Step 2.5: Use the childCount() function in the QWidgetItem class to determine whether the child node is selected. If the return value of the function is greater than 0, it means the child node is selected, output the time information corresponding to the child node. Otherwise, it means it is not selected, and return to Step 2.4;
[0048] Step 2.6: Control the database to delete the historical information within the corresponding time according to the time information obtained in Step 2.4 and Step 2.5.
[0049] Step 3: Construct an automatic data cleaning process and detect whether automatic data cleaning is required.
[0050] Assume that the equipment software detects the disk space utilization rate every 24 hours. If the disk space utilization rate exceeds 90%, execute Step 1 to query the storage time of historical information, and delete the historical data in the database month by month according to the principle of first in first out. After each deletion operation is completed, detect the disk space utilization rate until the disk space is lower than the set threshold. This step includes the following steps:
[0051] Step 3.1: Regularly detect the disk utilization rate, determine whether the disk utilization rate is greater than 90%. If it is greater than 90%, proceed to Step 3.2. Otherwise, end;
[0052] Step 3.2: Query the storage time of historical information in the database according to the method in Step 1;
[0053] Step 3.3: Delete the data of the earliest month in the database according to the principle of first in first out;
[0054] Step 3.4: Detect the disk utilization rate. If the disk utilization rate is greater than the set value of 50%, return to Step 3.3 if it is greater; otherwise, end.
[0055] It should be emphasized that the embodiments described in the present invention are illustrative rather than restrictive. Therefore, the present invention includes but is not limited to the embodiments described in the specific embodiments. Any other embodiments obtained by those skilled in the art based on the technical solution of the present invention also fall within the scope of protection of the present invention.
Claims
1. A user-oriented non-administrative database combination cleaning method, characterized in that: It includes the following steps: Step 1: Query the storage time of historical information in the database and sort it in order; Step 2: Obtain the time range selected by the user for data cleaning, and perform data cleaning on the historical information sorted in Step 1; Step 2 includes the following steps: Step 2.1: Create a new QTableWidget object and set its operation property to be selectable; Step 2.2: Create a new QTreeWidgetItem object item, make item the parent node of the tree structure, and display the name as "Select All"; Step 2.3: Traverse the historical information sorted in Step 1, create multiple QTreeWidgetItem objects to construct the child nodes of the tree structure, and display the name of the child nodes as "Time Information"; Step 2.4: Use the childCount() function in the QWidgetItem class to determine whether the parent node is selected. If the return value of the function is greater than 0, it means the parent node is selected, and at the same time output the time information of all historical information. Otherwise, it means it is not selected, and proceed to Step 2.5; Step 2.5: Use the childCount() function in the QWidgetItem class to determine whether the child node is selected. If the return value of the function is greater than 0, it means the child node is selected, output the time information corresponding to the child node. Otherwise, it means it is not selected, and return to Step 2.4; Step 2.6: Control the database to delete the historical information within the corresponding time according to the time information obtained in Step 2.4 and Step 2.5; Step 3: Construct an automatic data cleaning process and detect whether automatic data cleaning is required.
2. A method for cleaning a non - managed database combination for users according to claim 1, characterized in that: The said Step 1 includes the following steps: Step 1.1: The database executes the command "select tablename from pg_tables" to query the names of all data tables in the database, and store the data table names in the tableNames variable in the form of a string; Step 1.2: Traverse the content in the tableNames variable, obtain the index value of the position where the string "_20" is located, make it n, and judge whether n is less than 0. If it is less than 0, end the operation. Otherwise, proceed to Step 1.3; Step 1.3: Take the consecutive 6 - bit string content after the index value to get a time information YYYYMM, and assign it to tableTimeNames; Step 1.4: Judge whether the same time information exists in the QStringList time variable. If the information exists, make the index value n = n + 6, and return to Step 1.2 to continue traversing the tableNames variable from n. Otherwise, store tableTimeNames in the QStringList time variable.
3. A user-oriented non-administered database portfolio cleaning method according to claim 1, characterized in that: The said Step 3 includes the following steps: Step 3.1: Regularly detect the disk utilization rate, and judge whether the disk utilization rate is greater than 90%. If it is greater than 90%, proceed to Step 3.
2. Otherwise, end; Step 3.2: Query the storage time of historical information in the database according to the method of Step 1; Step 3.3: Delete the data of the earliest month in the database according to the principle of first - in - first - out; Step 3.4: Detect the disk utilization rate. If the disk utilization rate is greater than the set value of 50%, if it is greater, then return to Step 3.3; otherwise, end.
Citation Information
Patent Citations
Automatic update system, automatic updating method, and program therefor
US20080077315A1
Incremental garbage collection of data in a secondary storage
US7451168B1