Tuple processing method, system and device

By extracting the tuple to be cleaned from the tuple processing method on the database server and storing it to the cleaned tuple area, the problem of inefficiency in data recovery is solved, and fast and accurate flashback query is achieved to meet business needs.

CN118550935BActive Publication Date: 2025-05-02HUNDSUN TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411032634.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2025-05-02
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

Existing databases are inefficient and prone to errors when recovering data. In particular, the flashback query of Oracle databases is affected by the undo implementation mechanism, and the error operation of updates and deletion is slower, while the insertion is faster.

Method used

Implement the tuple processing method on the database server. By extracting the tuple to be cleaned from the updated target data table and storing it to the cleaned tuple area, it supports reading the target tuple in the target time interval from the cleaned tuple area and the target data table during flashback query.

Benefits of technology

It improves the efficiency and accuracy of the database during flashback query, ensuring that it can respond quickly and accurately to flashback query statements, meeting the flashback operations under different needs of business parties.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550935B_ABST
    Figure CN118550935B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a tuple processing method, system and device, wherein the tuple processing method is applied to a database server, including: in response to a data operation request submitted to a target data table in a relational database, updating the target data table; extracting tuples to be cleaned from the updated target data table, and storing the tuples to be cleaned in a cleanup tuple area; upon receiving a flashback query statement associated with a target time interval, reading a target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement; and executing a business processing task corresponding to the flashback query statement based on the target tuple.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification relate to the field of database technology, and in particular to a tuple processing method, system, and device. Background Art

[0002] With the development of computer technology, database technology has been applied in more and more scenarios, especially in the environment of complex online business, database is the core technology to support the normal operation of business. In order to ensure that the database can provide stable storage services, most databases can support the recovery of data errors. The need to recover data with errors is a relatively important mechanism in all types of databases. Among them, the flashback query of Oracle database is particularly prominent, which allows you to view the data of the table at a specific point in time, even if the data has been modified or deleted by other transactions. This is particularly useful for operations such as recovering accidentally deleted data, auditing historical data, or performing time point analysis. In databases that do not support flashback, data recovery can be achieved by maintaining a delayed replay standby library, which supports querying data that has not been misoperated from the replay standby library and restoring it to the main library after an exception occurs, thereby meeting the normal operation of upstream and downstream businesses. However, the data recovery mechanism of various databases is affected by the database's own form. For example, the flashback query of Oracle database is affected by the undo implementation mechanism, resulting in slow rollback of update and deletion errors, while fast rollback of insertion; other types of databases will have low rollback efficiency and prone to errors due to the uncertainty of the time of the error operation. Therefore, an effective solution is urgently needed to solve the above problems. Summary of the invention

[0003] In view of this, an embodiment of the present specification provides a tuple processing method. One or more embodiments of the present specification also relate to a tuple processing system, a tuple processing device, a computing device, a computer-readable storage medium and a computer program product to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of this specification, a tuple processing method is provided, which is applied to a database server, and includes:

[0005] In response to a data operation request submitted to a target data table in a relational database, updating the target data table;

[0006] Extracting tuples to be cleaned from the updated target data table, and storing the tuples to be cleaned in a cleaning tuple area;

[0007] In case of receiving a flashback query statement associated with a target time interval, reading a target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement;

[0008] The business processing task corresponding to the flashback query statement is executed based on the target tuple.

[0009] According to a second aspect of an embodiment of this specification, a tuple processing system is provided, the tuple processing system comprising a service terminal and a database server, wherein the database server configures a relational database, including:

[0010] The business terminal is used to construct a data operation request for a target data table in the relational database, and send the data operation request to the database server;

[0011] The database server is used to update the target data table in response to the data operation request, extract the tuples to be cleaned from the updated target data table, and store the tuples to be cleaned in the cleaned tuple area, and when receiving the flashback query statement associated with the target time interval submitted by the business terminal, read the target tuple corresponding to the target time interval in the cleaned tuple area and the updated target data table by executing the flashback query statement, and feed back the target tuple to the business terminal;

[0012] The business terminal is used to execute the business processing task corresponding to the flashback query statement based on the target tuple.

[0013] According to a third aspect of an embodiment of this specification, a tuple processing device is provided, which is applied to a database server, including:

[0014] An update module is configured to update the target data table in the relational database in response to a data operation request submitted for the target data table;

[0015] A storage module is configured to extract tuples to be cleaned from the updated target data table and store the tuples to be cleaned in a cleaning tuple area;

[0016] A reading module is configured to, upon receiving a flashback query statement associated with a target time interval, read a target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement;

[0017] The execution module is configured to execute the business processing task corresponding to the flashback query statement based on the target tuple.

[0018] According to a fourth aspect of an embodiment of this specification, a computing device is provided, including:

[0019] Memory and processor;

[0020] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the above-mentioned tuple processing method are implemented.

[0021] According to a fifth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned tuple processing method are implemented.

[0022] According to a sixth aspect of the embodiments of this specification, a computer program product is provided, including a computer program or instructions, which implement the steps of the above-mentioned tuple processing method when executed by a processor.

[0023] The tuple processing method provided in this embodiment can directly update the target data table according to the request when receiving a data operation request submitted to the target data table in the relational database in order to support flashback query in the relational database and ensure the efficiency and accuracy of flashback. After the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be extracted from the updated target data table first. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement is received that is associated with a target time interval, the target tuple corresponding to the target time interval can be read from the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the target tuple required by the statement can be quickly and accurately responded to. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting the subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple. A cleanup tuple area is established in the relational database to separately store dead tuples, thereby supporting relational data to provide a fast and responsive flashback mechanism to meet the flashback operations of the business side under different requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is a schematic diagram of a tuple processing method provided by an embodiment of this specification;

[0025] Figure 2 is a flow chart of a tuple processing method provided by one embodiment of this specification;

[0026] Figure 3 is a schematic diagram of a flashback query in a tuple processing method provided by an embodiment of this specification;

[0027] Figure 4 is a processing flow chart of a tuple processing method provided by an embodiment of this specification;

[0028] Figure 5 It is a structural diagram of a tuple processing system provided by an embodiment of this specification;

[0029] Figure 6 It is a structural schematic diagram of a tuple processing device provided by an embodiment of this specification;

[0030] Figure 7 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0031] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0032] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0033] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0034] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0035] First, the terms involved in one or more embodiments of this specification are explained.

[0036] PostgreSQL (PG for short): The database is a powerful open source object-relational database system. It allows users to freely use, modify and distribute its source code. It supports advanced database features such as complex SQL queries, foreign keys, triggers, views, transaction integrity, MVCC (multi-version concurrency control), etc.

[0037] Tuple: It is a basic concept in relational databases and a data structure in the database. In a relational database, data is stored in the form of tables, each table is called a relation, and each row in the table is called a tuple.

[0038] Dead tuple: It is an important concept in database management systems (such as PostgreSQL), mainly referring to row data that has been marked for deletion but has not yet been physically deleted.

[0039] In this specification, a tuple processing method is provided. This specification also relates to a tuple processing system, a tuple processing apparatus, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.

[0040] See also Figure 1As shown in the schematic diagram, the tuple processing method provided in this embodiment can directly update the target data table according to the request when receiving a data operation request submitted to the target data table in the relational database in order to support the completion of flashback query in the relational database and ensure the efficiency and accuracy of flashback; after the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be extracted from the updated target data table first. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement is received that is associated with a target time interval, the target tuple corresponding to the target time interval can be read from the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the target tuple required by the statement can be quickly and accurately responded to. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting the subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple. A cleanup tuple area is established in the relational database to separately store dead tuples, thereby supporting relational data to provide a fast and responsive flashback mechanism to meet the flashback operations of the business side under different requirements.

[0041] See also Figure 2 , Figure 2 A flowchart of a tuple processing method provided according to an embodiment of the present specification is shown. The method is applied to a database server and specifically includes the following steps.

[0042] Step S202: in response to a data operation request submitted to a target data table in a relational database, updating the target data table.

[0043] The tuple processing method provided in this embodiment can be applied to any relational database, and can support flashback query of dead tuples stored in the cleanup tuple area during data processing operations when there is a flashback requirement, thereby facilitating business use in different scenarios.

[0044] Among them, flashback query can be applied to data recovery scenarios (when users accidentally delete important data or perform incorrect update operations, the erroneous data can be quickly restored without interrupting business); audit scenarios (in financial, medical and other scenarios, there are strict audit and compliance requirements for the historical records and changes of data. The Yuanzu processing method provided in this embodiment can help auditors quickly access the historical version of the data to verify the integrity and compliance of the data); fault diagnosis scenarios (during the operation of the database, various faults and exceptions may occur, resulting in inconsistent or lost data; at this time, it can help database administrators quickly locate the cause of the problem and diagnose the fault by viewing the historical status of the data); development and testing scenarios (in the process of software development and testing, it is often necessary to view and verify the performance of data in different versions or states; at this time, it can help developers and testers quickly access the historical version of the data to verify the correctness and stability of the software), etc. The specific application scenario can be set according to the needs, and this embodiment does not make any restrictions here.

[0045] Specifically, a relational database refers to a relational database used to store related target businesses in the current business scenario, such as a pg database; correspondingly, a target data table refers to a table in a relational database used to store data, and the data recorded in the target data table needs to be updated in response to a data operation request, wherein the data operation request supports operations such as updating, adding, deleting, and inserting data in the target data table; in actual applications, the data operation request may carry an identifier corresponding to the target data table, so that after submitting the data operation request, the target data table can be accurately located in the relational database, so that the data in the target data table can be added, deleted, and modified in response to the data operation request.

[0046] Based on this, in order to support the completion of flashback query in the relational database and ensure the efficiency and accuracy of flashback, the target data table can be directly updated according to the request when a data operation request submitted to the target data table in the relational database is received; after the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be first extracted from the updated target data table. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement associated with a target time interval is received, the target tuple corresponding to the target time interval can be read in the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the statement can be responded to quickly and accurately to feedback the target tuple it needs. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple.

[0047] Furthermore, considering that different data operation requests may involve different data operations when updating the target data table, in order to ensure that the operation result of the target data table matches the data operation request, thereby supporting the subsequent cleaning of dead tuples to avoid errors, different operations can be performed on the data table according to different request types. In this embodiment, the specific implementation method is as follows:

[0048] Receive a data operation request submitted for a target data table in a relational database; determine a newly added tuple according to the data operation request, and add the newly added tuple to the target data table; or, determine a tuple to be deleted in the target data table according to the data operation request, and delete the tuple to be deleted in the target data table; or, determine a tuple to be modified in the target data table according to the data operation request, and modify the tuple to be modified according to the data operation request; as an update to the target data table.

[0049] Specifically, a newly added tuple refers to a tuple consisting of a new row of data that needs to be inserted into the target data table; correspondingly, a tuple to be deleted refers to a tuple consisting of an existing row of data that needs to be deleted from the target data table; correspondingly, a tuple to be modified refers to a tuple consisting of a row of data that needs to be modified in the target data table.

[0050] Based on this, after receiving the data operation request, the database server can determine the associated relational database by parsing the data operation request, and then extract the data table identifier from the data operation request to determine the associated target data table. On this basis, if the data operation request is a request to insert data, the newly added tuple can be determined according to the data operation request, and the newly added tuple can be added to the target data table; if the data operation request is a request to delete data, the tuple to be deleted can be determined in the target data table according to the data operation request, and the tuple to be deleted can be deleted in the target data table; if the data operation request is a request to modify data, the tuple to be modified can be determined in the target data table according to the data operation request, and the tuple to be modified can be modified according to the data operation request; it can be used as an update to the target data table.

[0051] In actual applications, the data operation request submitted for the target data table in the relational database can be selected according to actual needs, and this embodiment does not make any limitation here.

[0052] Step S204, extracting tuples to be cleaned up from the updated target data table, and storing the tuples to be cleaned up in a cleaning tuple area.

[0053] Specifically, after the update of the target data table is completed in response to the data operation request, considering that the update of the target data table may generate dead tuples, that is, tuples that are not needed for the current business, these tuples can be cleaned up at this time. In order to support the relational database with a flashback query function, the tuples that need to be cleaned up can be stored in a set cleanup tuple area. In other words, the tuples to be cleaned up can be extracted from the updated target data table, and then stored in the cleanup tuple area, so that when receiving a flashback query statement, the target tuple can be hit from the cleanup tuple area for subsequent business, thereby ensuring data recoverability.

[0054] Among them, the tuples to be cleaned are the dead tuples that need to be cleaned in the updated target data table; correspondingly, the tuple cleaning area specifically refers to a partition that separately stores the tuples to be cleaned. It can be used to allocate storage space separately for the tuples that need to be cleaned in the relational database, or it can be stored in other databases that have a distributed relationship with the relational database. In actual applications, it can be selected according to actual needs, and this embodiment does not make any limitations here.

[0055] Furthermore, after the target data table is updated, considering that there may be tuples in the updated target data table that are not needed by the current business, i.e., dead tuples, the dead tuples need to be released. In order to support the flashback query mechanism of the relational database, the dead tuples that need to be released can be stored in the cleanup tuple area. In order to avoid occupying more storage resources, they can be compressed. In this embodiment, the specific implementation method is as follows:

[0056] Extract the tuple in the invalid state from the updated target data table as the initial tuple; compress the initial tuple according to the preset compression strategy, determine the tuple to be cleaned according to the compression result, and execute the step of storing the tuple to be cleaned in the cleaning tuple area.

[0057] Specifically, the invalid initial tuple refers to the tuple in the updated target data table that is no longer needed at the current time node. Correspondingly, the compression strategy refers to a strategy for compressing the initial tuple by row, which is used to compress the initial tuple into a tuple to be cleaned that occupies a smaller storage space.

[0058] Based on this, after the update of the target data table is completed in response to the data operation request, in order to support the relational database to have a flashback query function and reduce the space occupied by cached dead tuples, the tuples in the updated target data table can be first extracted as the initial tuples; at this time, the initial tuples can be compressed according to the preset compression strategy, so that the tuples to be cleaned can be determined according to the compression results, and then the tuples to be cleaned can be stored in the cleaning tuple area to support access to the area at any stage to obtain the corresponding tuples for use.

[0059] In actual applications, when storing dead tuples in the updated target data table in the cleanup tuple area, it is necessary to first write the tuples to be cleaned into the cleanup tuple area, and then delete the tuples to be cleaned in the updated target data table, so as to avoid errors. In order to avoid downtime or cleanup failure in the middle of the operation, two-phase transactions (Two-Phase Commit, 2PC) can be used to ensure integrity, thereby supporting the flashback query function of the relational database. In addition, in order to ensure that subsequent flashback queries can be completed quickly and accurately, it is also necessary to maintain the correspondence between the catalog XID version and the tuple XID version, so as to ensure that after receiving the flashback query statement, the target tuple that hits the target time interval can be fed back.

[0060] For example, in the data recovery scenario, see Figure 3As shown in the schematic diagram, the data table at time T0 contains three tuples. From time T0 to T3, the relational database performs PG logic, performs one data update (update), and one data deletion (delete). At time T3, the data table contains 4 tuples. At time T4, the system performs a dead tuple cleanup operation. The table currently has 2 dead tuples. In order to support the database to provide flashback query function, the 2 dead tuples can be compressed by row and saved to the additional branch table adt_fork (separated dead tuple area) in the relational database. After that, the dead tuples in the storage relation can be cleaned up. In this way, when there is a flashback query requirement later, tuples can be read from the adt_fork table for use.

[0061] In specific implementation, since moving dead tuples to the adt_fork table only adds additional sequential I / O copies and CPU cycles, and can usually be run in batches at a set time interval, such as once every 15 minutes, the impact on system performance is relatively low. At this time, the data of the original data table is saved in two forks, the surviving relation and the archived dead tuple relation. They are all located in the same directory as the main fork, usually $PGDATA / base / ${dboid} / ${relfilenode}. This can support use during flashback queries.

[0062] In summary, by separating a cleanup tuple area for tuples to be cleaned up in a relational database and separately storing the tuples to be cleaned up in a compressed state, it is possible to ensure that less storage space is occupied to support flashback query.

[0063] Step S206 , when a flashback query statement associated with a target time interval is received, the target tuples corresponding to the target time interval are read from the cleanup tuple area and the updated target data table by executing the flashback query statement.

[0064] Specifically, during the operation phase of the relational database, dead tuples corresponding to different time nodes will be continuously stored in the cleanup tuple partition, so that when a flashback query statement is received at any time, the required tuples can be fed back by executing the statement. In this process, considering that the tuples to be cleaned in the updated target data table may be stored in the cleanup tuple area according to the set time interval, in a more complicated situation, there will be dead tuples in the target data table that have not been stored in the cleanup tuple area, and there will be other dead tuples in the cleanup tuple area. When the same tuple is added, deleted, or modified multiple times, there will be tuples corresponding to multiple states of the tuple in the cleanup tuple area and the updated target data table. In order to ensure the selection of the target tuple corresponding to the flashback query statement, the target time interval can be determined for the flashback query statement, and then the target tuple can be accurately hit. Therefore, when a flashback query statement associated with the target time interval is received, the target tuple corresponding to the target time interval can be read in the cleanup tuple area and the updated target data table by executing the flashback query statement, so that the target tuple can be used for downstream business processing later.

[0065] Among them, the flashback query statement specifically refers to the statement submitted when querying the tuples that have changed and is used to trigger the flashback query function of the relational database. Correspondingly, the target time interval specifically refers to the time range corresponding to the tuples that need to be queried by the flashback query statement. Correspondingly, the target tuple specifically refers to the tuple matching the target time interval in the updated target data table or the cleaned tuple area, which is used for subsequent business processing tasks that can be associated with the flashback query statement based on the target tuple, such as for auditing, data recovery, development testing, etc.

[0066] Furthermore, when the received statement is a flashback query statement associated with the target time interval, it indicates that the execution of the statement is associated with the flashback query at this time. In order to ensure that the execution result of the flashback query statement can feedback the tuples it needs, the query of the required tuples can be completed in the relational database and the cleanup tuple area in sequence to support orderly business use. In this embodiment, the specific implementation method is as follows:

[0067] When a flashback query statement associated with a target time interval is received, intermediate tuples that have not been cleaned up are determined in an updated target data table; a flashback check is performed on the intermediate tuples by executing the flashback query statement; when it is determined based on the check result that no tuples associated with the target time interval exist in the intermediate tuples, the cleanup tuple area is scanned according to the target time interval; and a target tuple is read in the cleanup tuple area based on the scan result.

[0068] Specifically, the intermediate tuple specifically refers to the dead tuple that has not been cleaned up in the updated target data table. Based on this, when a flashback query statement associated with the target time interval is received, considering that there may be dead tuples that have not been cleaned up in the updated target data table, and the cleaned up dead tuples have been stored in the cleaned up tuple area, after receiving the flashback query statement, the intermediate tuples that have not been cleaned up can be first determined in the updated target data table; at this time, the intermediate tuples are flashback tested by executing the flashback query statement; when it is determined according to the test results that there are tuples associated with the target time interval in the intermediate tuples, the tuple can be directly used as the target tuple for subsequent business processing task execution.

[0069] If it is determined based on the detection results that there is no tuple associated with the target time interval in the intermediate tuple, it means that there is no tuple matching the target time interval in the updated target data table, so the tuple area can be scanned and cleaned according to the target time interval; thus, the target tuple can be read in the cleaned tuple area based on the scanning results for subsequent business processing task execution.

[0070] In summary, by continuously querying the target tuples in the updated target data table and the cleaned tuple area, it is possible to ensure that the target statement is quickly and accurately fed back in response to the flashback query statement, thereby quickly responding to downstream services.

[0071] In practical applications, considering that after a statement is submitted, it may only represent the required query intent and does not have a more specific time interval, the target time interval of the associated flashback query statement can be determined in combination with the timestamp function, so that the target tuple can be located more accurately. In this embodiment, the specific implementation method is as follows:

[0072] When the timestamp recording function is enabled on the database server, the transaction time information associated with the flashback query statement is loaded through the function function corresponding to the timestamp recording function; the target time interval associated with the flashback query statement is determined based on the transaction time information; on this basis, the first effective time and the first expiration time respectively corresponding to the tuples contained in the cleanup tuple area, and the second effective time and the second expiration time respectively corresponding to the tuples contained in the updated target data table can be determined by executing the flashback query statement; the first effective time and the first expiration time are compared with the target time interval, and the second effective time and the second expiration time are compared with the target time interval; and the target tuple is read in the cleanup tuple area and the updated target data table according to the comparison results.

[0073] Specifically, the timestamp recording function specifically refers to the track_commit_timestamp started by the database server for the relational database; correspondingly, the function specifically refers to the system function pg_xact_commit_timestamp(xid) preset by the database server, which is used to load the transaction time information associated with the flashback query statement; correspondingly, the transaction time information specifically refers to the time node information used to determine the target time interval. Correspondingly, the first effective time and the first invalid time specifically refer to the effective time and invalid time corresponding to each tuple in the cleanup tuple area, and the second effective time and the second invalid time specifically refer to the effective time and invalid time corresponding to the tuple in the updated target data table.

[0074] Based on this, in order to be able to accurately and quickly query the target tuple for the flashback query statement after receiving the statement, it can be determined that when the timestamp recording function is turned on on the database server, the transaction time information associated with the flashback query statement is loaded through the function function corresponding to the timestamp recording function; on this basis, the target time interval associated with the flashback query statement can be determined based on the transaction time information.

[0075] Furthermore, when it is necessary to query the target tuple, the first effective time and the first expiration time corresponding to the tuples contained in the cleanup tuple area, as well as the second effective time and the second expiration time corresponding to the tuples contained in the updated target data table can be determined by executing a flashback query statement; then, by comparing the first effective time and the first expiration time with the target time interval, and comparing the second effective time and the second expiration time with the target time interval; the tuple whose effective time and expiration time are within the target time interval can be found, and it can be used as the target tuple for subsequent execution of business processing tasks.

[0076] Using the above example, Figure 3As shown in the diagram, between T4 and T5, if the user modifies record 2 and adds record 4, record 2 in the survival relation of the data table has both the latest version and the dead tuple version that has not been cleaned up, and record 2 has an older dead tuple version in the adt_fork table. On this basis, the flashback query needs to judge the survival relation (the data table corresponding to time T5) and the adt_fork table at the same time to return the version tuple that meets the requirements. On this basis, PG determines whether the tuple is visible during the transaction, mainly based on the effectiveness and expiration time of the tuple. It can be understood that only the records that have been submitted to the transaction at the beginning of this transaction are visible to this transaction. Although the flashback query queries the version iteration of data based on historical time, because some dead tuples have not been vacuumed (occupied by existing transactions or vacuum has not been triggered or because the parameter settings are retained, etc.), these dead tuples may be visible or invisible to the flashback query. Therefore, the flashback query also needs to avoid dirty reads when accessing these records.

[0077] At this point, the visibility of MVCC can be determined by the following rules. The rules include: 1. The status of t_xmin is ABORTED; Rule 1: If the t_xmin transaction is abandoned, it is invisible. 2. The status of t_xmin is IN_PROGRESS; Rule 2: If the t_xmin transaction is running and it is not the current transaction, the tuple in the transaction is invisible (otherwise it is reading dirty data); Rule 3: If the t_xmin transaction is running and the tuple status is destroyed (t_xmax!=0), it is invisible; Rule 4: If the t_xmin transaction is running and the tuple status is active (t_xmax=0), it is visible. 3. The status of t_xmin is COMMITTED; Rule 5: If the t_xmin transaction has been committed and t_xmin is active in the current snapshot, it is not visible; Rule 6: If the t_xmin transaction has been committed, the t_xmax transaction is running and the t_max transaction is the current transaction, it is not visible; Rule 7: If the t_xmin transaction has been committed, the t_xmax transaction is running and the t_max transaction is not the current transaction, it is visible; Rule 8: If the t_xmin transaction has been committed, the t_xmax transaction status is committed, and t_xmax is active in the current snapshot, it is visible; Rule 9: If the t_xmin transaction has been committed, the t_xmax transaction status is committed, and the current snapshot t_xmax is not active, it is not visible.

[0078] Under this rule, a flashback query statement like the following is received:

[0079] SELECT * FROM test_fb AS OF TIMESTAMP systimestamp – 3 / 1440

[0080] WHERE id = 2;

[0081] SELECT * FROM test_fbVERSIONS BETWEEN TIMESTAMP systimestamp – 5 / 1440AND systimestamp – 3 / 1440

[0082] WHERE id =2;

[0083] SELECT * FROM test_fb AS OF XID 1234567;

[0084] SELECT * FROM test_fb VERSIONS BETWEEN XID 725202 AND 725219;

[0085] It can be determined that when track_commit_timestamp is turned on, the time of xid can be obtained through the system function pg_xact_commit_timestamp(xid), and the target time range can be calculated through xid. On this basis, the data table corresponding to time T5 can be accessed based on the flashback query statement. If it is determined based on the access result that there is no tuple that hits the flashback query statement in the dead tuple that has not been cleaned up in the data table corresponding to time T5, the adt_fork table can be scanned, and combined with the target time range, it can be determined whether the effective time and expiration time of each tuple in the table are within the target time range, so that the tuple within the target time range can be selected as the target tuple hit by the flashback query statement, so as to complete the recovery operation of the specified data in combination with the target tuple.

[0086] In summary, by comparing the effective time and expiration time of the tuple with the target time interval, it can be ensured that the target tuple corresponding to the flashback query statement is accurately hit.

[0087] In addition, considering that different statements submitted to the database have different requirements, a judgment can be made for the received flashback query statement, so as to determine the subsequent execution logic according to the judgment result. In this embodiment, the specific implementation method is as follows:

[0088] The flashback query statement is parsed, and it is detected whether the parsed flashback query statement contains a preset flashback query clause; if not, the business tuple is read in the updated target data table by executing the flashback query statement, and the business processing task is performed based on the business tuple; if so, the step of reading the target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement.

[0089] Specifically, the flashback query clause refers to an SQL clause pre-set for a relational database to trigger the flashback query function, such as AS OF XID, AS OF TIMESTAMP, VERSION BETWEEN XID, VERSION BETWEEN TIMESTAMP, etc. In actual applications, the pre-examined flashback query clause can be set according to actual needs, and this embodiment does not make any limitation here.

[0090] Based on this, after receiving the flashback query statement, the flashback query statement can be parsed first, and it can be detected whether the parsed flashback query statement contains a preset flashback query clause; if not, it means that the flashback query statement does not involve a flashback query operation, so the business tuple can be directly read in the updated target data table by executing the flashback query statement, and the business processing task can be performed based on the business tuple; if so, it means that a flashback query is required for the target time interval at this time, so the step of reading the target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement can be performed to facilitate the subsequent execution of the business processing task.

[0091] On this basis, when the parsed flashback query statement contains a preset flashback query clause, in order to ensure the accuracy of the target tuple hit, the target tuple can be determined by comparing the tuple with the transaction identification condition. In this embodiment, the specific implementation method is as follows:

[0092] The preset transaction identification condition is determined by executing the flashback query statement; the tuples contained in the cleanup tuple area and the tuples contained in the updated target data table are respectively compared with the transaction identification condition; and the tuples that meet the transaction identification condition are selected as target tuples corresponding to the target time interval according to the comparison results.

[0093] Specifically, the transaction identification condition specifically refers to the condition for filtering the database transaction identification, which is used to filter the tuples matching the transaction identification condition in the cleanup tuple area as the target tuple. Based on this, when the parsed flashback query statement contains a preset flashback query clause, in order to ensure the accuracy of the target tuple hit, the preset transaction identification condition can be determined by executing the flashback query statement; then, the tuples contained in the cleanup tuple area and the tuples contained in the updated target data table are respectively compared with the transaction identification condition; according to the comparison result, the tuples that meet the transaction identification condition can be filtered, that is, the tuples that meet the specific transaction identification can be used as the target tuples of the corresponding target time interval for subsequent use.

[0094] For example, after the client submits an SQL statement to the database server, the compiler will be used to parse the SQL statement and convert it into an abstract syntax tree. According to the parsing results, if the SQL statement contains any of the four clauses AS OF XID, AS OF TIMESTAMP, VERSION BETWEEN XID, and VERSION BETWEEN TIMESTAMP, it means that the statement needs to be flashed back in the relational database. Therefore, based on this statement, it can be determined whether each tuple in the adt_fork table meets the specific starting xid and ending xid; assuming that the SQL statement is SELECT * FROMtest_fbVERSIONS BETWEEN XID 1001 AND 1008, according to the query results, the tuples that meet this condition are as shown in Table 1 below:

[0095] Table 1

[0096]

[0097] That is to say, the filtered tuples satisfy {effective xid is less than or equal to the starting xid, and the invalid xid is greater than the starting XID; effective xid is less than or equal to the ending xid, and the invalid xid is greater than the ending xid}. The tuples can be used for downstream businesses later, such as data recovery, auditing, development and testing, etc.

[0098] In summary, by judging the visibility of tuples, we can ensure that the target tuples that need to be used are quickly and accurately hit, so that business processing tasks can be quickly executed based on the target tuples, thereby improving business response speed.

[0099] Step S208: executing the business processing task corresponding to the flashback query statement based on the target tuple.

[0100] Specifically, after obtaining the target tuple corresponding to the target time interval, further, since the target tuple is a tuple corresponding to a specified time node obtained by executing the flashback query statement, the business processing task corresponding to the flashback query statement can be subsequently executed based on the target tuple.

[0101] Among them, the business processing task can be a data recovery task, which can quickly restore the erroneous data based on the target tuple without interrupting the business; it can also be an audit task, which can help auditors quickly access the historical version of the data based on the target tuple to verify the integrity and compliance of the data; it can also be a fault diagnosis task, which can help database administrators quickly locate the cause of the problem based on the target tuple and diagnose the fault by viewing the historical status of the data. It can also be a development and testing task, which can help developers and testers quickly access the historical version of the data based on the target tuple to verify the correctness and stability of the software; this embodiment does not make any limitation here.

[0102] In addition, after obtaining the target tuple, considering that the target tuple is compressed in the storage stage, it can be aligned and decompressed first when executing the business processing task, and the business processing task can be continued according to the decompression result. In this embodiment, the specific implementation method is as follows:

[0103] When the cleanup time of the initial tuple meets a preset time threshold, a step of compressing the initial tuple according to a preset compression strategy is performed; wherein, executing the business processing task corresponding to the flashback query statement based on the target tuple includes: when the target tuple corresponds to the cleanup tuple area, decompressing the target tuple, and executing the business processing task corresponding to the flashback query statement based on the decompressed target tuple.

[0104] In practical applications, in order to avoid occupying too many computing resources, the operation of compressing the initial tuple and storing it in the cleanup tuple area can be completed at a preset time interval. That is, when the cleanup time of the initial tuple meets the preset time threshold, the step of compressing the initial tuple according to the preset compression strategy can be performed. On this basis, when the target tuple read subsequently comes from the cleanup tuple area, the target tuple can be decompressed first, and the business processing task corresponding to the flashback query statement can be executed based on the decompressed target tuple.

[0105] The tuple processing method provided in this embodiment can directly update the target data table according to the request when receiving a data operation request submitted to the target data table in the relational database in order to support flashback query in the relational database and ensure the efficiency and accuracy of flashback. After the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be extracted from the updated target data table first. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement is received that is associated with a target time interval, the target tuple corresponding to the target time interval can be read from the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the target tuple required by the statement can be quickly and accurately responded to. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting the subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple. A cleanup tuple area is established in the relational database to separately store dead tuples, thereby supporting relational data to provide a fast and responsive flashback mechanism to meet the flashback operations of the business side under different requirements.

[0106] The following combination Figure 4 , taking the application of the tuple processing method provided in this specification in a data recovery scenario as an example, the tuple processing method is further described. Figure 4 A processing flow chart of a tuple processing method provided by an embodiment of the present specification is shown, which specifically includes the following steps.

[0107] Step S402: in response to a data operation request submitted to a target data table in a relational database, updating the target data table.

[0108] Step S404: extracting tuples in the failed state from the updated target data table as initial tuples.

[0109] Step S406, compressing the initial tuple according to a preset compression strategy, determining the tuple to be cleaned according to the compression result, and storing the tuple to be cleaned in the cleaning tuple area.

[0110] Step S408: upon receiving a flashback query statement associated with the target time interval, determining intermediate tuples that have not been cleaned up in the updated target data table.

[0111] Among them, determining the target time interval associated with the flashback query statement includes: when the timestamp recording function is turned on on the database server, loading the transaction time information associated with the flashback query statement through the function function corresponding to the timestamp recording function; and determining the target time interval associated with the flashback query statement based on the transaction time information.

[0112] Step S410: Perform flashback detection on the intermediate tuples by executing a flashback query statement.

[0113] Step S412: when it is determined according to the detection result that there is no tuple associated with the target time interval in the intermediate tuples, the tuple area is scanned and cleaned according to the target time interval.

[0114] Step S414, reading the target tuple in the clean-up tuple area according to the scanning result.

[0115] Step S416: executing the business processing task corresponding to the flashback query statement based on the target tuple.

[0116] The tuple processing method provided in this embodiment can directly update the target data table according to the request when receiving a data operation request submitted to the target data table in the relational database in order to support flashback query in the relational database and ensure the efficiency and accuracy of flashback. After the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be extracted from the updated target data table first. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement is received that is associated with a target time interval, the target tuple corresponding to the target time interval can be read from the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the target tuple required by the statement can be quickly and accurately responded to. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting the subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple. A cleanup tuple area is established in the relational database to separately store dead tuples, thereby supporting relational data to provide a fast and responsive flashback mechanism to meet the flashback operations of the business side under different requirements.

[0117] Corresponding to the above method embodiment, this specification also provides a tuple processing system embodiment, Figure 5 FIG. 2 shows a schematic diagram of a tuple processing system provided by an embodiment of the present specification. Figure 5As shown, the tuple processing system 500 includes a business terminal 510 and a database server 520, wherein the database server 520 is configured with a relational database, including:

[0118] The business terminal 510 is used to construct a data operation request for a target data table in the relational database, and send the data operation request to the database server;

[0119] The database server 520 is used to update the target data table in response to the data operation request, extract the tuples to be cleaned from the updated target data table, and store the tuples to be cleaned in the cleaned tuple area. When receiving the flashback query statement associated with the target time interval submitted by the business terminal, read the target tuple corresponding to the target time interval in the cleaned tuple area and the updated target data table by executing the flashback query statement, and feed back the target tuple to the business terminal;

[0120] The business terminal 510 is used to execute the business processing task corresponding to the flashback query statement based on the target tuple.

[0121] In an optional embodiment, the database server 520 is further used for:

[0122] Receive a data operation request submitted for a target data table in a relational database; determine a newly added tuple according to the data operation request, and add the newly added tuple to the target data table; or, determine a tuple to be deleted in the target data table according to the data operation request, and delete the tuple to be deleted in the target data table; or, determine a tuple to be modified in the target data table according to the data operation request, and modify the tuple to be modified according to the data operation request; as an update to the target data table.

[0123] In an optional embodiment, the database server 520 is further used for:

[0124] Extract the tuple in the invalid state from the updated target data table as the initial tuple; compress the initial tuple according to the preset compression strategy, determine the tuple to be cleaned according to the compression result, and execute the step of storing the tuple to be cleaned in the cleaning tuple area.

[0125] In an optional embodiment, the database server 520 is further used for:

[0126] When a flashback query statement associated with a target time interval is received, intermediate tuples that have not been cleaned up are determined in an updated target data table; a flashback check is performed on the intermediate tuples by executing the flashback query statement; when it is determined based on the check result that no tuples associated with the target time interval exist in the intermediate tuples, the cleanup tuple area is scanned according to the target time interval; and a target tuple is read in the cleanup tuple area based on the scan result.

[0127] In an optional embodiment, the database server 520 is further used for:

[0128] In the case where the timestamp recording function is enabled on the database server, the transaction time information associated with the flashback query statement is loaded through the function function corresponding to the timestamp recording function; the target time interval associated with the flashback query statement is determined based on the transaction time information; wherein, the target tuples corresponding to the target time interval are read in the cleanup tuple area and the updated target data table by executing the flashback query statement, including: determining the first effective time and the first expiration time respectively corresponding to the tuples contained in the cleanup tuple area, and the second effective time and the second expiration time respectively corresponding to the tuples contained in the updated target data table by executing the flashback query statement; comparing the first effective time and the first expiration time with the target time interval, and comparing the second effective time and the second expiration time with the target time interval; and reading the target tuples in the cleanup tuple area and the updated target data table according to the comparison results.

[0129] In an optional embodiment, the database server 520 is further used for:

[0130] The flashback query statement is parsed, and it is detected whether the parsed flashback query statement contains a preset flashback query clause; if not, the business tuple is read in the updated target data table by executing the flashback query statement, and the business processing task is performed based on the business tuple; if so, the step of reading the target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement.

[0131] In an optional embodiment, the database server 520 is further used for:

[0132] The preset transaction identification condition is determined by executing the flashback query statement; the tuples contained in the cleanup tuple area and the tuples contained in the updated target data table are respectively compared with the transaction identification condition; and the tuples that meet the transaction identification condition are selected as target tuples corresponding to the target time interval according to the comparison results.

[0133] In an optional embodiment, the database server 520 is further used for:

[0134] When the cleanup time of the initial tuple meets a preset time threshold, a step of compressing the initial tuple according to a preset compression strategy is performed; wherein, executing the business processing task corresponding to the flashback query statement based on the target tuple includes: when the target tuple corresponds to the cleanup tuple area, decompressing the target tuple, and executing the business processing task corresponding to the flashback query statement based on the decompressed target tuple.

[0135] The tuple processing system provided in this embodiment can directly update the target data table according to the request when receiving a data operation request submitted to the target data table in the relational database in order to support flashback query in the relational database and ensure the efficiency and accuracy of flashback. After the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be extracted from the updated target data table first. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement is received that is associated with a target time interval, the target tuple corresponding to the target time interval can be read from the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the target tuple required by the statement can be quickly and accurately responded to. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting the subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple. A cleanup tuple area is established in the relational database to separately store dead tuples, thereby supporting relational data to provide a fast and responsive flashback mechanism to meet the flashback operations of the business side under different requirements.

[0136] The above is a schematic scheme of a tuple processing system of this embodiment. It should be noted that the technical scheme of the tuple processing system and the technical scheme of the tuple processing method described above are of the same concept, and the details not described in detail in the technical scheme of the tuple processing system can be found in the description of the technical scheme of the tuple processing method described above.

[0137] Corresponding to the above method embodiment, this specification also provides a tuple processing device embodiment, Figure 6 FIG. 1 shows a schematic diagram of the structure of a tuple processing device provided by an embodiment of the present specification. Figure 6 As shown, the device is applied to a database server, and includes:

[0138] An updating module 602 is configured to update a target data table in a relational database in response to a data operation request submitted for the target data table;

[0139] The storage module 604 is configured to extract the tuples to be cleaned from the updated target data table and store the tuples to be cleaned in the cleaning tuple area;

[0140] The reading module 606 is configured to, upon receiving a flashback query statement associated with a target time interval, read a target tuple corresponding to the target time interval in the cleaned tuple area and the updated target data table by executing the flashback query statement;

[0141] The execution module 608 is configured to execute the business processing task corresponding to the flashback query statement based on the target tuple.

[0142] In an optional embodiment, the updating module 602 is further configured to:

[0143] Receive a data operation request submitted for a target data table in a relational database; determine a newly added tuple according to the data operation request, and add the newly added tuple to the target data table; or, determine a tuple to be deleted in the target data table according to the data operation request, and delete the tuple to be deleted in the target data table; or, determine a tuple to be modified in the target data table according to the data operation request, and modify the tuple to be modified according to the data operation request; as an update to the target data table.

[0144] In an optional embodiment, the storage module 604 is further configured to:

[0145] Extract the tuple in the invalid state from the updated target data table as the initial tuple; compress the initial tuple according to the preset compression strategy, determine the tuple to be cleaned according to the compression result, and execute the step of storing the tuple to be cleaned in the cleaning tuple area.

[0146] In an optional embodiment, the reading module 606 is further configured to:

[0147] When a flashback query statement associated with a target time interval is received, intermediate tuples that have not been cleaned up are determined in an updated target data table; a flashback check is performed on the intermediate tuples by executing the flashback query statement; when it is determined based on the check result that no tuples associated with the target time interval exist in the intermediate tuples, the cleanup tuple area is scanned according to the target time interval; and a target tuple is read in the cleanup tuple area based on the scan result.

[0148] In an optional embodiment, determining the target time interval associated with the flashback query statement includes:

[0149] When the timestamp recording function is enabled on the database server, the transaction time information associated with the flashback query statement is loaded through a function function corresponding to the timestamp recording function; and a target time interval associated with the flashback query statement is determined based on the transaction time information;

[0150] Wherein, the reading module 606 is further configured to:

[0151] By executing the flashback query statement, the first effective time and the first invalid time respectively corresponding to the tuples contained in the cleanup tuple area, and the second effective time and the second invalid time respectively corresponding to the tuples contained in the updated target data table are determined; the first effective time and the first invalid time are compared with the target time interval, and the second effective time and the second invalid time are compared with the target time interval; and the target tuple is read in the cleanup tuple area and the updated target data table according to the comparison results.

[0152] In an optional embodiment, the device further includes:

[0153] A parsing module is configured to parse the flashback query statement and detect whether the parsed flashback query statement contains a preset flashback query clause; if not, read the business tuple in the updated target data table by executing the flashback query statement, and perform the business processing task based on the business tuple; if so, execute the step of reading the target tuple corresponding to the target time interval in the cleanup tuple area and the updated target data table by executing the flashback query statement.

[0154] In an optional embodiment, when the parsed flashback query statement contains a preset flashback query clause, the reading module 606 is further configured to:

[0155] The preset transaction identification condition is determined by executing the flashback query statement; the tuples contained in the cleanup tuple area and the tuples contained in the updated target data table are respectively compared with the transaction identification condition; and the tuples that meet the transaction identification condition are selected as target tuples corresponding to the target time interval according to the comparison results.

[0156] In an optional embodiment, the device further includes:

[0157] A compression module, configured to, when the cleaning time of the initial tuple meets a preset time threshold, execute a step of compressing the initial tuple according to a preset compression strategy;

[0158] The execution module 608 is further configured to:

[0159] In the case where the target tuple corresponds to the clean-up tuple area, the target tuple is decompressed, and the business processing task corresponding to the flashback query statement is executed based on the decompressed target tuple.

[0160] The tuple processing device provided in this embodiment can directly update the target data table according to the request when receiving a data operation request submitted to the target data table in the relational database in order to support flashback query in the relational database and ensure the efficiency and accuracy of flashback. After the update is completed, there will be tuples in the target data table that are no longer needed due to the update operation, so the tuples to be cleaned can be extracted from the updated target data table first. At this time, in order to support the relational database to meet the flashback mechanism at any time. The tuples to be cleaned can be stored in the cleanup tuple area; the dead tuples that have been changed due to the update operation can be persisted separately through the cleanup tuple area to support the flashback stage, and the tuples that need to be used can be extracted from the cleanup tuple area to perform subsequent business processing tasks. Therefore, when a flashback query statement is received that is associated with a target time interval, the target tuple corresponding to the target time interval can be read from the cleanup tuple area and the updated target data table by executing the flashback query statement; thereby ensuring that the target tuple required by the statement can be quickly and accurately responded to. Even if the target tuple is updated due to a previous erroneous operation, it can be read in the cleanup tuple area, thereby supporting the subsequent business processing tasks corresponding to the execution of the flashback query statement based on the target tuple. A cleanup tuple area is established in the relational database to separately store dead tuples, thereby supporting relational data to provide a fast and responsive flashback mechanism to meet the flashback operations of the business side under different requirements.

[0161] The above is a schematic scheme of a tuple processing device of this embodiment. It should be noted that the technical scheme of the tuple processing device and the technical scheme of the tuple processing method described above are of the same concept, and the details of the technical scheme of the tuple processing device that are not described in detail can be found in the description of the technical scheme of the tuple processing method described above.

[0162] Figure 7 The block diagram of a computing device 700 according to an embodiment of the present specification is shown. The components of the computing device 700 include but are not limited to a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and the database 750 is used to store data.

[0163] The computing device 700 also includes an access device 740 that enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 740 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0164] In one embodiment of the present specification, the above components of the computing device 700 and Figure 7 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 7 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0165] The computing device 700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 700 may also be a mobile or stationary server.

[0166] The processor 720 is used to execute the following computer executable instructions, which implement the steps of the above-mentioned tuple processing method when executed by the processor.

[0167] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the tuple processing method described above are of the same concept, and the details not described in detail in the technical scheme of the computing device can be found in the description of the technical scheme of the tuple processing method described above.

[0168] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which can implement the steps of the above-mentioned tuple processing method when executed by a processor.

[0169] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the tuple processing method described above are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the tuple processing method described above.

[0170] An embodiment of the present specification also provides a computer program product, including a computer program or instructions, which implement the steps of the above-mentioned tuple processing method when executed by a processor.

[0171] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the tuple processing method described above are of the same concept, and the details not described in detail in the technical scheme of the computer program product can be found in the description of the technical scheme of the tuple processing method described above.

[0172] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0173] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0174] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0175] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0176] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can understand and use this specification well.

Claims

1. A tuple processing method, characterized in that: Applied to the database server, including: In response to a data operation request submitted to a target data table in a relational database, updating the target data table; Extracting tuples in the failed state from the updated target data table as initial tuples; compressing the initial tuples according to a preset compression strategy, determining tuples to be cleaned up according to the compression result, and storing the tuples to be cleaned up in a cleaning tuple area, wherein the cleaning tuple area is used to separately store the tuples to be cleaned up and is located in a database having a distributed relationship with the relational database; When a flashback query statement associated with a target time interval is received, and when it is determined by executing the flashback query statement that no tuple associated with the target time interval exists in the updated target data table, a target tuple corresponding to the target time interval is determined by scanning the cleanup tuple area; The business processing task corresponding to the flashback query statement is executed based on the target tuple.

2. The tuple processing method according to claim 1, characterized in that: The updating of the target data table in response to the data operation request submitted to the target data table in the relational database includes: Receiving a data operation request submitted for a target data table in a relational database; Determine a new tuple according to the data operation request, and add the new tuple to the target data table; or, determine a tuple to be deleted in the target data table according to the data operation request, and delete the tuple to be deleted in the target data table; or, determine a tuple to be modified in the target data table according to the data operation request, and modify the tuple to be modified according to the data operation request; as an update to the target data table.

3. The tuple processing method according to claim 1, characterized in that: The method of, when receiving a flashback query statement associated with a target time interval, determining by executing the flashback query statement that no tuple associated with the target time interval exists in the updated target data table, and determining a target tuple corresponding to the target time interval by scanning the cleanup tuple area, comprises: Upon receiving a flashback query statement associated with a target time interval, determining intermediate tuples that have not been cleaned up in the updated target data table; Performing flashback detection on the intermediate tuple by executing the flashback query statement; When it is determined according to the detection result that there is no tuple associated with the target time interval in the intermediate tuples, scanning the cleanup tuple area according to the target time interval; The target tuple is read in the clean tuple area according to the scanning result.

4. The tuple processing method according to claim 1 or 3, characterized in that: Determining the target time interval associated with the flashback query statement includes: When the timestamp recording function is enabled on the database server, the transaction time information associated with the flashback query statement is loaded through a function function corresponding to the timestamp recording function; Determine a target time interval associated with the flashback query statement based on the transaction time information; Wherein, when it is determined by executing the flashback query statement that there is no tuple associated with the target time interval in the updated target data table, determining the target tuple corresponding to the target time interval by scanning the cleanup tuple area further includes: By executing the flashback query statement, determining the first effective time and the first invalid time respectively corresponding to the tuples contained in the cleanup tuple area, and the second effective time and the second invalid time respectively corresponding to the tuples contained in the updated target data table; Compare the first effective time and the first expiration time with the target time interval, and compare the second effective time and the second expiration time with the target time interval; According to the comparison result, the target tuple is read in the cleaned tuple area and the updated target data table.

5. The tuple processing method according to claim 1, characterized in that: In the case where it is determined by executing the flashback query statement that there is no tuple associated with the target time interval in the updated target data table, before the step of determining the target tuple corresponding to the target time interval by scanning the cleanup tuple area is executed, the method further includes: Parsing the flashback query statement, and detecting whether the parsed flashback query statement contains a preset flashback query clause; If not, read the business tuple in the updated target data table by executing the flashback query statement, and execute the business processing task based on the business tuple; If so, executing the flashback query statement to determine that there is no tuple associated with the target time interval in the updated target data table, and then determining the target tuple corresponding to the target time interval by scanning the cleanup tuple area.

6. The tuple processing method according to claim 5, characterized in that: When the parsed flashback query statement contains a preset flashback query clause, it also includes: Determine a preset transaction identification condition by executing the flashback query statement; Comparing the tuples contained in the cleaned tuple area and the tuples contained in the updated target data table with the transaction identification conditions respectively; According to the comparison result, a tuple that meets the transaction identification condition is selected as a target tuple corresponding to the target time interval.

7. The tuple processing method according to claim 1, characterized in that: Before the initial tuple is compressed according to the preset compression strategy, the method further includes: When the cleaning time of the initial tuple meets a preset time threshold, executing a step of compressing the initial tuple according to a preset compression strategy; The executing of the business processing task corresponding to the flashback query statement based on the target tuple includes: In the case where the target tuple corresponds to the clean-up tuple area, the target tuple is decompressed, and the business processing task corresponding to the flashback query statement is executed based on the decompressed target tuple.

8. A tuple processing system, characterized in that: The tuple processing system includes a business terminal and a database server, wherein the database server is configured with a relational database, including: The business terminal is used to construct a data operation request for a target data table in the relational database, and send the data operation request to the database server; The database server is used to update the target data table in response to the data operation request, extract the tuple in the invalid state as the initial tuple in the updated target data table; compress the initial tuple according to a preset compression strategy, determine the tuple to be cleaned according to the compression result, and store the tuple to be cleaned in the cleaning tuple area; when receiving the flashback query statement associated with the target time interval submitted by the business terminal, when it is determined by executing the flashback query statement that there is no tuple associated with the target time interval in the updated target data table, determine the target tuple corresponding to the target time interval by scanning the cleaning tuple area, and feed back the target tuple to the business terminal, wherein the cleaning tuple area is used to separately store the tuple to be cleaned, and is located in a database having a distributed relationship with the relational database; The business terminal is used to execute the business processing task corresponding to the flashback query statement based on the target tuple.

9. A tuple processing device, characterized in that: Applied to the database server, including: An update module is configured to update the target data table in the relational database in response to a data operation request submitted for the target data table; A storage module is configured to extract tuples in an invalid state from the updated target data table as initial tuples; compress the initial tuples according to a preset compression strategy, determine tuples to be cleaned according to the compression result, and store the tuples to be cleaned in a cleaning tuple area, wherein the cleaning tuple area is used to separately store the tuples to be cleaned and is located in a database having a distributed relationship with the relational database; a reading module configured to, upon receiving a flashback query statement associated with a target time interval, determine by executing the flashback query statement that there is no tuple associated with the target time interval in the updated target data table, and then determine by scanning the cleanup tuple area a target tuple corresponding to the target time interval; The execution module is configured to execute the business processing task corresponding to the flashback query statement based on the target tuple.

10. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the method described in any one of claims 1 to 7 are implemented.

11. A computer-readable storage medium, characterized in that: It stores computer executable instructions, which, when executed by a processor, implement the steps of the method described in any one of claims 1 to 7.

12. A computer program product, characterized in that The method comprises a computer program or an instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data flashback inquiry and recovery method of PostgreSQL database, device

    CN109299099A