CN116955394A - Data query method, device, equipment and medium - Google Patents

Data query method, device, equipment and medium Download PDF

Info

Publication number
CN116955394A
CN116955394A CN202310053928.5A CN202310053928A CN116955394A CN 116955394 A CN116955394 A CN 116955394A CN 202310053928 A CN202310053928 A CN 202310053928A CN 116955394 A CN116955394 A CN 116955394A
Authority
CN
China
Prior art keywords
query
determining
target
cut
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310053928.5A
Other languages
Chinese (zh)
Inventor
刘恒
郭琰
韩朱忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Dameng Database Co Ltd
Original Assignee
Shanghai Dameng Database Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Dameng Database Co Ltd filed Critical Shanghai Dameng Database Co Ltd
Priority to CN202310053928.5A priority Critical patent/CN116955394A/en
Publication of CN116955394A publication Critical patent/CN116955394A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/248Presentation of query results
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data query method, a device, equipment and a medium, wherein the method comprises the following steps: acquiring a query statement for data query, and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database; determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page; and determining a query result corresponding to the query statement according to the global cut-off times, the ID information of each target transaction and the local cut-off times. For concurrent query sentences, the visibility is judged through the global cut-off times, the local cut-off times and the target transaction ID information of each target table object, and then the query result is determined. The flexibility of independently processing each target table object when the cut-off statement and the query statement are concurrent and the accuracy of the query result are ensured.

Description

Data query method, device, equipment and medium
Technical Field
The invention relates to the technical field of databases, in particular to a data query method, a data query device, data query equipment and data query media.
Background
When data query is performed, the result set of the query statement is more, and the result needs to be returned to the client in batches, and the query statement may be executed concurrently with the trunk statement.
The current concurrency execution scheme is to store corresponding data version numbers for table objects, when executing a trunk statement, all sub-tables of a partition table maintain respective data version numbers, and a query statement can distinguish whether concurrency trunk operation occurs by comparing the data version number before query execution with the current latest data version number.
When more sub-tables exist in the partition table, maintaining all sub-table data version numbers reduces the performance of the trunk statement. And when the query involves multiple partition sub-tables, concurrent execution of the query statement and the trunk statement for the partition sub-tables may result in unexpected execution results. If the query statement can query the first partition sub-table, all partition sub-tables are truncated when the trunk statement is executed concurrently after the query, so that the query result of the subsequent partition sub-table is empty, and the result does not accord with the expectations.
Disclosure of Invention
The invention provides a data query method, a device, equipment and a medium, which are used for realizing concurrent execution of query sentences and cut-off sentences.
According to a first aspect of the present invention, there is provided a data query method, comprising:
acquiring a query statement for data query, and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database;
determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page;
and determining a query result corresponding to the query statement according to the global cut-off times, the target transaction ID information and the local cut-off times.
According to a second aspect of the present invention, there is provided a data query apparatus comprising:
the first determining module is used for obtaining a query statement for carrying out data query and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database;
the second determining module is used for determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page;
and the third determining module is used for determining a query result corresponding to the query statement according to the global cut-off times, the target transaction ID information and the local cut-off times.
According to a third aspect of the present invention, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the data query method according to any one of the embodiments of the present invention.
According to a fourth aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to execute a data query method according to any embodiment of the present invention.
According to the technical scheme, query sentences used for data query are obtained, and a target table object set corresponding to the query sentences and the global cut-off times of the target database are determined in the corresponding target database; determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page; and determining a query result corresponding to the query statement according to the global cut-off times, the ID information of each target transaction and the local cut-off times. For concurrent query sentences, the visibility is judged through the global cut-off times, the local cut-off times and the target transaction ID information of each target table object, and then the query result is determined. The flexibility of independently processing each target table object when the cut-off statement and the query statement are concurrent and the accuracy of the query result are ensured.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a data query method according to a first embodiment of the present invention;
FIG. 2 is a flow chart of a data query method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a data query device according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device implementing an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a data query method according to an embodiment of the present invention, where the method may be performed by a data query device, the data query device may be implemented in hardware and/or software, and the data query device may be configured in an electronic device. As shown in fig. 1, the method includes:
s110, acquiring a query statement for data query, and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database.
It should be noted that when the result set of the query statement is more, the result needs to be returned to the client in batches, and the query statement and the cut-off statement can be executed concurrently. Because the query statement may temporarily release IS blocking on the table in the target object set when a batch of result sets IS returned, IS blocking on the table IS again performed when the next batch of result sets IS acquired, and the truncated statement IS performed in this gap, the truncated statement may block the table by X, so that the query statement and the truncated statement may be performed concurrently without causing a conflict.
In this embodiment, a query statement may be understood as a statement that is returned to the client by all records in the lookup table that are eligible. The target database may be understood as a database in which the query statement corresponds to a table that needs to be queried. The target table object set can be understood as a table set formed by the tables to be queried corresponding to the query statement, and if the query statement needs to query the partition table, the partition sub-table meeting the query condition is added into the table set. The global cut-off times can be understood as the memory value of a global variable, is initialized to 0 when the target database is started, and records the cut-off times of cut-off sentences in the subsequent target database. Partition sub-tables may be understood as sub-tables of partition tables.
Specifically, the processor may acquire a query statement sent by the client for performing data query, the processor may determine a target database according to the query statement, determine a target table object set corresponding to the query statement in the corresponding target database, and may further acquire global cut-off times in a memory value form of the target database.
S120, determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page.
In this embodiment, the index control page may be understood as a data page that maintains management index information (such as the number of clusters used by the index, rowid of the index, etc.), and each index has a corresponding control page. The target transaction ID information may be understood as transaction ID information recorded in the index control page, and may be in the form of bytes. The local cut-off times can be understood as cut-off times corresponding to each target table object aiming at the current query statement.
Specifically, the processor may determine, according to the target table object set and each index control page corresponding to the target table object set, target transaction ID information and local truncation times corresponding to each target table object included in the target table object set.
S130, determining a query result corresponding to the query statement according to the global cut-off times, the ID information of each target transaction and the local cut-off times.
In this embodiment, the query result may be understood as a result of a data query corresponding to a query statement.
Specifically, the processor may compare the global cut-off times with the local cut-off times when acquiring the data of each target table object, and determine the visibility of the transaction according to the ID information of each target transaction registered in each index control page, so as to determine whether the data can be continuously acquired, thereby obtaining a query result corresponding to the query statement.
According to the technical scheme, query sentences used for data query are obtained, and a target table object set corresponding to the query sentences and the global cut-off times of the target database are determined in the corresponding target database; determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page; and determining a query result corresponding to the query statement according to the global cut-off times, the ID information of each target transaction and the local cut-off times. For concurrent query sentences, the visibility is judged through the global cut-off times, the local cut-off times and the target transaction ID information of each target table object, and then the query result is determined. The flexibility of independently processing each target table object when the cut-off statement and the query statement are concurrent and the accuracy of the query result are ensured.
As a first alternative embodiment of the first embodiment, on the basis of the above embodiment, further includes:
when the data truncation condition is met, determining a processing result according to the obtained truncation statement for data truncation.
In this embodiment, the data truncation condition may be understood as that the query statement releases the blocking of the table object. A truncated statement may be understood as deleting all records on a table object and retaining the table structure and index information thereon, which may be preferably a trunk statement. The processing result may be understood as a processing result corresponding to the cut-off sentence, and may include the database after cut-off and each index control page.
Specifically, when the data truncation condition is satisfied, the processor may perform truncation processing on the target database corresponding to the truncation statement according to the obtained truncation statement for performing data truncation, and determine a processing result.
Further, on the basis of the above embodiment, the step of determining the processing result may further be optimized according to the obtained cutoff statement for performing data cutoff, and the step of determining the processing result may include:
a1, determining an object set to be truncated, a current index control page corresponding to each object to be truncated and historical global truncation times of the target database according to the truncation statement, wherein the object set to be truncated comprises at least one object to be truncated.
In this embodiment, the target database may be understood as a database corresponding to the truncated sentence. A set of objects to be truncated may be understood as a set of table objects that need to be truncated. The current index control page may be understood as an index control page when the truncating operation is not performed. The historical global cut-off number can be understood as the global cut-off number when no cut-off operation is performed. An object to be truncated may be understood as a table object that needs to be truncated.
Specifically, the processor may determine, according to the truncation statement, a target database to be subjected to truncation operation, and determine, in the corresponding target database, a set of objects to be truncated, a current index control page corresponding to each object to be truncated, and a historical global truncation number of times of the target database, where the set of objects to be truncated includes at least one object to be truncated.
b1, cutting the object set to be cut according to the cut-off statement to obtain a final database.
In this embodiment, the final database may be understood as a database after the truncation process is performed.
Specifically, the processor may perform truncation processing on the object set to be truncated according to the truncation statement, to obtain a final database.
And c1, determining the current transaction ID according to the cut-off statement, registering the current transaction ID in each current index control page, and determining an index control page set.
In this embodiment, the index control page set may be understood as the set of current index control pages that make the change.
Specifically, the processor may determine, according to the cut-off statement, a current transaction ID corresponding to the cut-off operation, register the current transaction ID to each current index control page, and use a set of each current index control page as an index control page set.
d1, updating the historical global cut-off times to obtain the current global cut-off times.
In this embodiment, the current global cut-off number may be understood as the global cut-off number after the cut-off operation is performed.
Specifically, after the truncation operation is performed, the processor may update the historical global truncation times, for example, the historical global truncation times may be increased (one is added on the basis of the original) to obtain the current global truncation times.
And e1, taking the final database, the index control page set and the current global cut-off times as processing results.
In the first alternative embodiment of the present embodiment, since the truncating operation would otherwise maintain the index information on the table, the operation of recording the current transaction ID on the index control page does not cause performance problems, and even if there are more sub-tables of partitions, the performance is not degraded.
Example two
Fig. 2 is a flowchart of a data query method according to a second embodiment of the present invention, where the present embodiment is further refined based on the foregoing embodiment. As shown in fig. 2, the method includes:
s210, acquiring a query statement for data query, and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database.
S220, determining an index control page corresponding to each target table object in the target table object set.
Specifically, for each target table object included in the target table object set, the processor may determine, in turn, an index control page corresponding to each target table object.
S230, determining target transaction ID information corresponding to the target table object in the index control page.
Specifically, the processor may determine the transaction ID information corresponding to the target table object in the data line in which the transaction ID information is recorded in the index control page.
S240, judging whether the query statement is the first access target table object.
Specifically, the processor may determine whether the query statement is a first access target table object according to the cache information when executing the current query statement.
S250, if yes, initializing and assigning the local cut-off times.
Specifically, if the query statement accesses the target table object for the first time, a local cut-off number may be initialized, and the local cut-off number may be assigned to zero.
And S260, if not, directly acquiring the local cut-off times.
Specifically, if the query statement is not the first access to the target table object, the existing local cut-off times can be directly obtained.
S270, determining sub-query results corresponding to the target table objects according to the global cut-off times, the target transaction ID information and the local cut-off times, and forming a sub-query result set.
In this embodiment, the sub-query result may be understood as a query result for each target table object. A sub-query result set may be understood as a set of multiple sub-query results, i.e., a set of sub-query results corresponding to all target table objects in a target table object set.
Specifically, the processor may compare the global cut-off times with the local cut-off times of each target table object in sequence, and determine the transaction visibility in combination with the target transaction ID information, so as to determine whether the query statement may acquire the data in each target table object, further determine the sub-query result, and form the sub-query result set from the sub-query results of each target table object in the target table object set corresponding to the query statement.
Further, on the basis of the foregoing embodiment, the step of determining the sub-query result corresponding to each target table object according to the global cut-off number, each target transaction ID information, and each local cut-off number, and forming the sub-query result set may include:
a2, judging whether the local cut-off times are the same as the global cut-off times or not according to each local cut-off times.
Specifically, for each local cut-off number, the processor may determine whether the local cut-off number is the same as the global cut-off number.
And b2, if so, determining the corresponding sub-query result as permission to acquire the data.
Specifically, if the local truncation times are the same as the global truncation times, it may be determined that the sub-query result corresponding to the target table object is permission to acquire data.
And c2, if not, judging the visibility of the corresponding target table object based on the target transaction ID information, and determining a corresponding sub-query result.
In this embodiment, transaction visibility may be understood as whether a statement C in transaction B is allowed to see the modifications made by transaction A.
Specifically, if the local cutoff times are different from the global cutoff times, the processor may determine the transaction visibility of the corresponding target table object based on the target transaction ID information, thereby determining a corresponding sub-query result.
Wherein, based on the target transaction ID information, performing transaction visibility determination on the corresponding target table object, the step of determining the corresponding sub-query result may include:
c21, determining the transaction information corresponding to the transaction ID information.
In this embodiment, the transaction information may be understood as a program execution logic unit formed by the operations of accessing and updating the system data.
Specifically, the processor may determine the corresponding transaction information according to the transaction ID information.
And c22, judging whether the transaction information is visible to the query statement.
Specifically, the user may set the isolation level of the transaction in the transaction information in advance, and the processor may determine whether the transaction information is visible to the query statement.
Illustratively, the transaction visibility determination is related to the transaction isolation level, which is currently supported by DM databases: read uncommitted, read committed, and serialized. Taking read commit as an example, only if transaction A has completed all execution and committed before statement C begins execution, then statement C is allowed to see the modifications made by transaction A, i.e., transaction A is visible to statement C; otherwise, transaction A is not visible to sentence C. For the scenario discussed in this patent, the transaction a is a transaction corresponding to a truncated sentence, the sentence C is a query sentence, and when the transaction corresponding to the truncated sentence is visible to the query sentence, it is explained that the transaction corresponding to the truncated sentence is completed before the query sentence starts to execute, so that the query sentence is allowed to acquire data. The visibility judging methods of different transaction isolation levels are different, and a special module is arranged in the database for judging the transaction visibility according to the transaction isolation level set by the user.
And c23, if so, determining that the sub-query result is data which is allowed to be acquired, and updating the local cut-off times according to the global cut-off times.
Specifically, if the transaction information is visible to the query statement, determining that the sub-query result is permission to acquire data, and updating the local cut-off times according to the global cut-off times, if the local cut-off times corresponding to the sub-query result can be set as the global cut-off times.
And c24, if not, determining that the sub-query result is that the data acquisition is not allowed.
Specifically, if the transaction information is not visible to the query statement, determining that the sub-query result is not allowed to acquire data.
d2, forming a sub-query result set according to each sub-query result.
Specifically, the processor may use each sub-query result as a set of sub-query results.
S280, when all sub-query results in the sub-query result set are permission to acquire data, acquiring target sub-data corresponding to all the sub-query results, and determining the query result according to all the target sub-data.
In this embodiment, the target sub-data may be understood as data in a target table object corresponding to the sub-query result.
Specifically, the processor may poll each sub-query result in the sub-query result set sequentially, and when each sub-query result in the sub-query result set is permission to acquire data, the processor may acquire target sub-data corresponding to each sub-query result, and calculate each target sub-data to obtain a query result.
S290, when any sub-query result included in the sub-query result set is that the data acquisition is not allowed, statement error reporting is carried out on the query statement.
Specifically, the processor may poll each sub-query result in the sub-query result set sequentially, and when any sub-query result included in the sub-query result set is that data is not allowed to be acquired, the processor is not allowed to continue acquiring data, and performs statement error reporting on the query statement.
According to the data query method provided by the second embodiment, whether truncated sentences are executed concurrently or not can be checked by using the target transaction ID information corresponding to the target table object, so that the checking flexibility is improved. Through the global cut-off times and the local cut-off times, sub-query results are determined firstly, when the two are inconsistent, the transaction visibility is judged according to the target transaction ID, the transaction visibility judging result is consistent in the whole execution process of a single query statement, and for the cut-off operation of a partition table, even if a plurality of partition sub-tables are involved, the transaction IDs in index control pages of the sub-tables are consistent, the two points ensure that the specific query sequence of the partition sub-tables is regulated no matter how the specific query sequence of the query statement is executed, the query statement can ensure unification for the check of the cut-off operation, the condition that the query result does not accord with expectations is avoided, and further, the query result corresponding to the query statement is determined according to each sub-query result. The flexibility of independently processing each target table object when the cut-off statement and the query statement are concurrent and the accuracy of the query result are ensured.
Example III
Fig. 3 is a schematic structural diagram of a data query device according to a third embodiment of the present invention. As shown in fig. 3, the apparatus includes: the first determination module 41, the second determination module 42 and the third determination module 43. Wherein,,
a first determining module 41, configured to obtain a query statement for performing a data query, and determine a target table object set corresponding to the query statement and a global cutoff number of the target database in a corresponding target database;
a second determining module 42, configured to determine, according to the target table object set and each index control page corresponding to the target table object set, target transaction ID information and local truncation times corresponding to each target table object;
and a third determining module 43, configured to determine a query result corresponding to the query statement according to the global cut-off times, the target transaction ID information and the local cut-off times.
According to the technical scheme, query sentences used for data query are obtained, and a target table object set corresponding to the query sentences and the global cut-off times of the target database are determined in the corresponding target database; determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page; and determining a query result corresponding to the query statement according to the global cut-off times, the ID information of each target transaction and the local cut-off times. For concurrent query sentences, the visibility is judged through the global cut-off times, the local cut-off times and the target transaction ID information of each target table object, and then the query result is determined. The flexibility of independently processing each target table object when the cut-off statement and the query statement are concurrent and the accuracy of the query result are ensured.
Further, the second determining module 42 is specifically configured to:
determining an index control page corresponding to each target table object in the target table object set;
determining the target transaction ID information corresponding to the target table object in the index control page;
if the query statement corresponds to the first access to the target table object, initializing and assigning the local cut-off times;
otherwise, directly obtaining the local cut-off times.
Optionally, the third determining module 43 includes:
the first determining unit is used for determining sub-query results corresponding to the target table objects according to the global cut-off times, the target transaction ID information and the local cut-off times to form a sub-query result set;
the second determining unit is used for acquiring target sub-data corresponding to each sub-query result when each sub-query result in the sub-query result set is permission to acquire data, and determining the query result according to each target sub-data;
and the third determining unit is used for carrying out statement error reporting on the query statement when any sub-query result included in the sub-query result set is not allowed to acquire data.
Further, the first determining unit includes:
the judging subunit is used for judging whether the local cut-off times are the same as the global cut-off times or not according to each local cut-off times;
the first determining subunit is configured to determine that the corresponding sub-query result is permission to acquire data if the corresponding sub-query result is yes;
the second determining subunit is configured to determine a corresponding sub-query result by performing transaction visibility judgment on the corresponding target table object based on the target transaction ID information if not;
and forming a subunit, configured to form the sub-query result set according to each sub-query result.
Wherein the second determining subunit is specifically configured to:
determining transaction information corresponding to the transaction ID information;
judging whether the transaction information is visible to the query statement;
if yes, determining that the sub-query result is data which is allowed to be acquired, and updating the local cut-off times according to the global cut-off times;
if not, determining that the sub-query result is that the data acquisition is not allowed.
Optionally, the device further includes:
and the truncation module is used for determining a processing result according to the acquired truncation statement for data truncation when the data truncation condition is met.
Further, the truncation module is specifically configured to:
determining an object set to be truncated, a current index control page corresponding to each object to be truncated and historical global truncation times of the target database according to the truncation statement, wherein the object set to be truncated comprises at least one object to be truncated;
performing truncation processing on the object set to be truncated according to the truncation statement to obtain a final database;
determining a current transaction ID according to the cut-off statement, registering the current transaction ID in each current index control page, and determining an index control page set;
updating the historical global cut-off times to obtain current global cut-off times;
and taking the final database, the index control page set and the current global cut-off times as processing results.
The data query device provided by the embodiment of the invention can execute the data query method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 shows a schematic diagram of an electronic device 50 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 50 includes at least one processor 51, and a memory, such as a Read Only Memory (ROM) 52 Random Access Memory (RAM) 53 or the like, communicatively connected to the at least one processor 51, in which the memory stores a computer program executable by the at least one processor, and the processor 51 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 52 or the computer program loaded from the storage unit 58 into the Random Access Memory (RAM) 53. In the RAM53, various programs and data required for the operation of the electronic device 50 can also be stored. The processor 51, the ROM 52 and the RAM53 are connected to each other via a bus 54. An input/output (I/O) interface 55 is also connected to bus 54.
Various components in the electronic device 50 are connected to the I/O interface 55, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 57 such as various types of displays, speakers, and the like; a storage unit 58 such as a magnetic disk, an optical disk, or the like; and a communication unit 59 such as a network card, modem, wireless communication transceiver, etc. The communication unit 59 allows the electronic device 50 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunications networks.
The processor 51 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 51 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 51 performs the various methods and processes described above, such as the data query method.
In some embodiments, the data query method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as the storage unit 58. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 50 via the ROM 52 and/or the communication unit 59. When the computer program is loaded into RAM53 and executed by processor 51, one or more steps of the data query method described above may be performed. Alternatively, in other embodiments, the processor 51 may be configured to perform the data query method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method of querying data, comprising:
acquiring a query statement for data query, and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database;
determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page;
and determining a query result corresponding to the query statement according to the global cut-off times, the target transaction ID information and the local cut-off times.
2. The method of claim 1, wherein determining the target transaction ID information and the local truncation number corresponding to each target table object according to the target table object set and each corresponding index control page comprises:
determining an index control page corresponding to each target table object in the target table object set;
determining the target transaction ID information corresponding to the target table object in the index control page;
if the query statement corresponds to the first access to the target table object, initializing and assigning the local cut-off times;
otherwise, directly obtaining the local cut-off times.
3. The method of claim 1, wherein determining the query result corresponding to the query statement according to the global cutoff times, the target transaction ID information, and the local cutoff times comprises:
determining sub-query results corresponding to the target table objects according to the global cut-off times, the target transaction ID information and the local cut-off times to form a sub-query result set;
when all the sub-query results in the sub-query result set are permission to acquire data, acquiring target sub-data corresponding to all the sub-query results, and determining the query results according to all the target sub-data;
and when any sub-query result included in the sub-query result set is that the data acquisition is not allowed, carrying out statement error reporting on the query statement.
4. The method of claim 3, wherein determining the sub-query result corresponding to each target table object according to the global cutoff times, each target transaction ID information, and each local cutoff times, and forming the sub-query result set includes:
judging whether the local cut-off times are the same as the global cut-off times or not according to each local cut-off times;
if yes, determining the corresponding sub-query result as permission to acquire data;
if not, judging the transaction visibility of the corresponding target table object based on the target transaction ID information, and determining a corresponding sub-query result;
and forming the sub-query result set according to each sub-query result.
5. The method of claim 4, wherein the determining the corresponding sub-query result based on the transaction visibility determination for the corresponding target table object based on the target transaction ID information comprises:
determining transaction information corresponding to the transaction ID information;
judging whether the transaction information is visible to the query statement;
if yes, determining that the sub-query result is data which is allowed to be acquired, and updating the local cut-off times according to the global cut-off times;
if not, determining that the sub-query result is that the data acquisition is not allowed.
6. The method as recited in claim 1, further comprising:
when the data truncation condition is met, determining a processing result according to the obtained truncation statement for data truncation.
7. The method of claim 6, wherein the determining the processing result according to the obtained cutoff statement for performing data cutoff comprises:
determining an object set to be truncated, a current index control page corresponding to each object to be truncated and historical global truncation times of the target database according to the truncation statement, wherein the object set to be truncated comprises at least one object to be truncated;
performing truncation processing on the object set to be truncated according to the truncation statement to obtain a final database;
determining a current transaction ID according to the cut-off statement, registering the current transaction ID in each current index control page, and determining an index control page set;
updating the historical global cut-off times to obtain current global cut-off times;
and taking the final database, the index control page set and the current global cut-off times as processing results.
8. A data query device, comprising:
the first determining module is used for obtaining a query statement for carrying out data query and determining a target table object set corresponding to the query statement and the global cut-off times of the target database in the corresponding target database;
the second determining module is used for determining target transaction ID information and local cut-off times corresponding to each target table object according to the target table object set and each corresponding index control page;
and the third determining module is used for determining a query result corresponding to the query statement according to the global cut-off times, the target transaction ID information and the local cut-off times.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the data query method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to perform the data query method of any one of claims 1-7.
CN202310053928.5A 2023-02-03 2023-02-03 Data query method, device, equipment and medium Pending CN116955394A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310053928.5A CN116955394A (en) 2023-02-03 2023-02-03 Data query method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310053928.5A CN116955394A (en) 2023-02-03 2023-02-03 Data query method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN116955394A true CN116955394A (en) 2023-10-27

Family

ID=88445020

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310053928.5A Pending CN116955394A (en) 2023-02-03 2023-02-03 Data query method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN116955394A (en)

Similar Documents

Publication Publication Date Title
CN115495473A (en) Database query method and device, electronic equipment and storage medium
CN115145924A (en) Data processing method, device, equipment and storage medium
CN114564149B (en) Data storage method, device, equipment and storage medium
CN116340318A (en) Method, device, equipment and storage medium for processing secondary index record
CN110727666A (en) Cache assembly, method, equipment and storage medium for industrial internet platform
CN115328917A (en) Query method, device, equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN116955394A (en) Data query method, device, equipment and medium
CN115905322A (en) Service processing method and device, electronic equipment and storage medium
CN116302371A (en) Transaction visibility judging method, device, equipment and storage medium
CN117171206A (en) Query method, query device, electronic equipment and storage medium
CN116301634A (en) Method, device, equipment and medium for detecting resource interaction state
CN116401269A (en) Data query method and device, electronic equipment and storage medium
CN116303578A (en) Query expression processing method, device, equipment and storage medium
CN115964387A (en) Data query method and device, distributed database system and medium
CN117194435A (en) Index data updating method, device, equipment and storage medium
CN117421322A (en) Data reading method, device, equipment and medium
CN117171214A (en) Database information comparison method and device, electronic equipment and storage medium
CN117891792A (en) Database data sharing method and device, electronic equipment and storage medium
CN117033402A (en) Data access method, device, equipment and storage medium
CN116541438A (en) Data query method, device, equipment and storage medium
CN115203246A (en) Linked list query method and device, electronic equipment and storage medium
CN115878627A (en) Database partitioning method, device, equipment and storage medium
CN117971846A (en) Data processing method, device, equipment and storage medium
CN116737752A (en) SQL statement interception method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination