[go: up one dir, main page]

CN112416924B - Data synchronization query method, device, computer device and storage medium - Google Patents

Data synchronization query method, device, computer device and storage medium Download PDF

Info

Publication number
CN112416924B
CN112416924B CN201910780749.5A CN201910780749A CN112416924B CN 112416924 B CN112416924 B CN 112416924B CN 201910780749 A CN201910780749 A CN 201910780749A CN 112416924 B CN112416924 B CN 112416924B
Authority
CN
China
Prior art keywords
data
query
synchronization
item index
operation instruction
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.)
Active
Application number
CN201910780749.5A
Other languages
Chinese (zh)
Other versions
CN112416924A (en
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.)
Futaihua Industry Shenzhen Co Ltd
Hon Hai Precision Industry Co Ltd
Original Assignee
Futaihua Industry Shenzhen Co Ltd
Hon Hai Precision Industry 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 Futaihua Industry Shenzhen Co Ltd, Hon Hai Precision Industry Co Ltd filed Critical Futaihua Industry Shenzhen Co Ltd
Priority to CN201910780749.5A priority Critical patent/CN112416924B/en
Priority to TW108131975A priority patent/TWI816875B/en
Publication of CN112416924A publication Critical patent/CN112416924A/en
Application granted granted Critical
Publication of CN112416924B publication Critical patent/CN112416924B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Landscapes

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

Abstract

本发明提供一种数据同步查询方法、数据同步查询装置、计算机装置及存储介质,所述数据同步查询装置为数据库中的数据创建数据项索引以及操作指令集表,所述操作指令集表包括:数据项索引、操作时间、操作类型、操作指令、会话表,所述方法包括:接收客户端发送的数据查询语句;判断所述查询语句所要查询的数据是否为第一次查询;若所述查询的数据为第一次查询,则输出数据查询结果;若所述查询的数据非第一次查询,则在会话表中查找所述数据项索引上一次的同步时间,及根据所述同步时间确定与所述数据项索引对应的至少一条操作指令,并输出所述操作指令。通过所述方法使得在数据库查询数据时,以更加节约带宽的方式进行。

The present invention provides a data synchronization query method, a data synchronization query device, a computer device and a storage medium. The data synchronization query device creates a data item index and an operation instruction set table for data in a database. The operation instruction set table includes: data item index, operation time, operation type, operation instruction, and session table. The method includes: receiving a data query statement sent by a client; judging whether the data to be queried by the query statement is the first query; if the queried data is the first query, outputting the data query result; if the queried data is not the first query, searching the session table for the last synchronization time of the data item index, and determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction. The method enables the query of data in the database to be performed in a more bandwidth-saving manner.

Description

Data synchronous query method, device, computer device and storage medium
Technical Field
The present invention relates to the field of data query technologies, and in particular, to a data synchronization query method, a data synchronization query device, a computer device, and a computer readable storage medium.
Background
In everyday operations, it is often necessary to synchronize data between different data storage points, such as between a database and a client. Typically, the server side storing the database executes the client side's synchronous query instructions to query the data and return the results to be queried to the client side. This way of querying and transmitting data in its entirety is too wasteful of bandwidth.
Disclosure of Invention
In view of the foregoing, there is a need for a data synchronization query method and apparatus, a computer apparatus, and a computer readable storage medium, by which a client and a server perform in a more bandwidth-efficient manner when synchronizing data.
The first aspect of the present application provides a data synchronization query method, which is applied to a data synchronization query device, wherein the data synchronization query device creates a data item index and an operation instruction set table for data in a database, and the operation instruction set table includes: a data item index, an operation time, an operation type, an operation instruction, a session table, the method comprising:
Receiving a data query statement sent by a client;
judging whether the data to be queried of the query statement is a first query or not;
if the queried data is the first query, outputting a data query result; and
If the queried data is not queried for the first time, searching the last synchronization time of the data item index in a session table, determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction.
Preferably, when the data in the database is updated, an update record is generated by the data item index, the operation type, the operation instruction and the operation time of the data and is added to the data operation instruction set table.
Preferably, the session table is used for storing the synchronous query record of the client;
The contents of the session table include: one or more of data item index, synchronization time, synchronization result.
Preferably, the method for judging whether the data to be queried in the query statement is the first query or not includes any one of the following modes:
searching whether a session table of the client synchronous query record is contained in the operation instruction set table;
If the session table of the client synchronous query record is not contained, judging that the query statement is the first query;
If the session table of the client synchronous query record is included, searching whether a data item index of which the query is data is included in the session table, and if not, judging that the query statement is the first query.
Preferably, if the queried data is a first query, the steps further include:
And adding the data item index of the queried data and the operation type corresponding to the query statement into the session table.
Preferably, if the queried data is not queried for the first time, searching for a last synchronization time of the data item index in a session table, determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction, wherein the step of determining the operation instruction comprises the following steps:
Searching at least one operation instruction corresponding to the data item index in a preset range in the operation instruction set table according to the synchronous time, wherein the preset range refers to the operation instruction corresponding to the data item index from the synchronous time to the current query time;
if the operation instruction corresponding to the data item index is one, the operation instruction is sent to the client; and
And if the operation instructions corresponding to the data item indexes are multiple, the operation instructions are sorted and combined and then sent to the client.
Preferably, if the operation instructions corresponding to the data item indexes are multiple, the step of sorting and merging the operation instructions includes:
extracting a plurality of operation instructions corresponding to the data item index, and sequencing the operation instructions according to a time sequence;
And merging operation instructions with the same operation type of two adjacent operation types according to the time sequence, wherein the operation types comprise one or more of deletion, addition and modification.
A second aspect of the present application provides a data synchronization inquiry apparatus, the apparatus comprising:
The receiving module is used for receiving the data query statement sent by the client;
The judging module is used for judging whether the data to be queried of the query statement is the first query or not;
The first execution module is used for outputting a data query result when the queried data is the first query; and
And the second execution module is used for searching the last synchronous time of the data item index in the session table when the queried data is not queried for the first time, determining at least one operation instruction corresponding to the data item index according to the synchronous time and outputting the operation instruction.
A third aspect of the application provides a computer apparatus comprising a processor for implementing a data synchronous query method as described above when executing a computer program stored in a memory.
A fourth aspect of the application provides a computer readable storage medium having stored thereon a computer program which when executed by a processor implements a data synchronous query method as described above.
The data synchronous query method creates data item indexes for all data in a database, creates a data operation instruction set table, creates a session table for query sentences of a client, records the data item indexes corresponding to the query sentences of the client in the session table, and sends an operation instruction corresponding to the data item indexes corresponding to the data to be queried to the client after the last update time is queried in the operation instruction set table. The method reduces the data volume of the query data and saves the bandwidth.
Drawings
Fig. 1 is an application environment diagram of a data synchronization query method according to an embodiment of the present invention.
Fig. 2 is a flowchart of a data synchronization query method according to an embodiment of the present invention.
Fig. 3 is a functional block diagram of a data synchronization query device according to an embodiment of the present invention.
Fig. 4 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will be more clearly understood, a more particular description of the application will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. It should be noted that, without conflict, the embodiments of the present application and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, and the described embodiments are merely some, rather than all, embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
Fig. 1 is a schematic diagram of an application environment architecture of a data synchronous query method according to a first embodiment of the present invention.
The data synchronous query method is applied to the computer device 1, and the computer device 1 and at least one client 2 establish communication connection through a network. The network may be a wired network or a wireless network, such as radio, wireless fidelity (WIRELESS FIDELITY, WIFI), cellular, satellite, broadcast, etc.
The computer device 1 may be an electronic device having a function of storing computation and the like, in which a data synchronization query method is installed, the database information is stored in the computer device 1, and the computer device 1 may be a personal computer, a server, or the like, where the server may be a single server, a server cluster, a cloud server, or the like.
The client 2 may be various intelligent electronic devices with a file synchronization query function, and is configured to send a query statement to the computer device 1, and receive data query information sent by the computer device 1. Including but not limited to smartphones, tablet computers, laptop portable computers, desktop computers, and the like.
Fig. 2 is a flowchart of a data synchronization query method according to a second embodiment of the present invention. The order of the steps in the flow diagrams may be changed, and some steps may be omitted, according to different needs.
Step S1, receiving a query statement sent by a client.
In one embodiment, the query statement may be a structured query language. The structured query language is a database query and programming language for accessing data and querying, updating and managing relational database systems. The computer device 1 provided with the data synchronous query method receives the query sentences sent by the client side 2, and can receive the query sentences one by one and query the data to be queried according to the query sentences.
In an embodiment, the client 2 may also write a plurality of pieces of data information to be queried into a query script using a structured query language, and may query the plurality of pieces of data information at a time using the query script. The computer device 1 may receive a query script written in a structured query language sent by the client 2.
And S2, judging whether the data to be queried by the query statement is the first query.
In an embodiment, the computer device 1 may check the validity of the received query statement, and may feed this error information back to the client 2 if the process of the computer device 1 considers that the query statement does not conform to the grammatical rules. If the query statement is legal, the identity information of the client 2 is judged, and whether the client 2 has the authority to access the database corresponding to the query statement is judged. And confirms the authority range of the client 2, and determines the data range which can be operated by the client 2. And if the client 2 does not have the database permission corresponding to the query statement, feeding back the client 2.
The method for determining whether the data to be queried in the query statement is the first query by the computer device 1 according to the received query statement sent by the client side includes any one of the following modes:
searching whether a session table of the client 2 synchronous query record is contained in the operation instruction set table;
if the session table of the synchronous query record of the client 2 is not included, judging that the query statement is the first query;
If the session table of the synchronous query record of the client 2 is included, searching whether the data item index of the data to be queried is included in the session table, and if the data item index is not included, judging that the query statement is the first query.
Wherein the data item index is created for all data in the database by the computer apparatus 1, and the computer apparatus 1 also creates a data operation instruction set table for the data in the database. The operation instruction set table includes: data item index, operation time, operation type, operation instruction, session table. The data operation instruction set table is shown in table 1:
TABLE 1
When the data in the database is updated, generating an update record according to the data item index, the operation type, the operation instruction and the operation time of the data, and adding the update record into the data operation instruction set table.
For example, the computer device 1 searches the operation instruction set table for a session table including the client 2, where the session table is used for recording the query record of the client 2, and the content of the session table includes one or more of a data item index, a synchronization time, and a synchronization result of the query data. If the operation instruction set table does not contain the session table of the client 2, the data to be queried by the query statement is the first query. If the session table of the client 2 is included in the operation instruction set table, determining a data item index corresponding to the data according to the data to be queried in the session table, and searching whether the data item index is included in the session table, if not, determining that the data item index is queried for the first time. For example, in the operation instruction set table of table 1, each sequence number in the column of the session table corresponds to one client, and the computer apparatus 1 first searches the operation instruction set table for whether or not there is a session table corresponding to the client for the received query statement. As shown in table 2, table 2 is the content recorded in the session table 6, where the session table 6 is used for recording the query record of the client, and the data information updated by the client is recorded as follows: data item index 4, sync time 201906290925, sync result is successful. If the data item index corresponding to the query data exists in the session table, the data to be queried is not queried for the first time, and if the data to be queried does not exist, the data to be queried is queried for the first time.
TABLE 2
Data item index Synchronization time Synchronization results
4 201906290925 Success of
And step S3, outputting a data query result if the queried data is the first query.
If the queried data is the first query, the steps may further include: and adding the data item index of the queried data and the operation type corresponding to the query statement into the session table.
For example, after determining that the data to be queried is the first query, the computer device 1 outputs a data query result, adds a data item index of the data to be queried to a session table corresponding to the client 2, and records the time and the synchronization result of the synchronization data in the session table.
In yet another embodiment of the present invention, the computer apparatus 1 outputs the data query result after determining that the data to be queried is the first query, and sends the data item index corresponding to the queried data to the client 2 together. The client 2 receives the query data and the data item index of the data, and creates a synchronous information state table according to the data item index; the synchronization information state table includes: one or more of data item index, synchronization time, synchronization result.
The client 2 receives the data query result sent by the computer device 1 and updates the data query result in the data system of the client 2.
And S4, if the queried data is not queried for the first time, searching the last synchronization time of the data item index in a session table, determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction.
In an embodiment of the present invention, if the queried data is not queried for the first time, searching for a last synchronization time of the data item index in a session table, determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction includes:
Searching at least one operation instruction corresponding to the data item index in a preset range in the operation instruction set table according to the synchronous time, wherein the preset range refers to the operation instruction corresponding to the data item index from the synchronous time to the current query time;
if the operation instruction corresponding to the data item index is one, the operation instruction is sent to the client;
And if the operation instructions corresponding to the data item indexes are multiple, the operation instructions are sorted and combined and then sent to the client.
If the operation instructions corresponding to the data item indexes are multiple, the step of sorting and merging the operation instructions may include:
extracting a plurality of operation instructions corresponding to the data item index, and sequencing the operation instructions according to a time sequence;
And merging operation instructions with the same operation type of two adjacent operation types according to the time sequence, wherein the operation types comprise one or more of deletion, addition and modification.
In one embodiment, after the computer device 1 analyzes the structured query statement, it determines that the data queried in the structured query statement is a second query, searches the session table for the synchronization time of the last synchronization of the data item index of the client 2 according to the data item index corresponding to the query data, and queries all the operation instructions from the last synchronization time to the current query time of the data item index in the operation instruction set table according to the synchronization time. For example, according to the data item index 3 to be queried by the client 2, if the data item index 3 is not queried for the first time, the computer device 1 queries that the last synchronization time of the data item index 3 is 201905091008 in the session table, searches all operation instructions corresponding to the data item index 3 from the point 08 of 2019, 5, 9, 10 and 10 to the current query time in the operation instruction set table, the operation instructions corresponding to the data item index 3 are shown in table 3, the operation times are arranged according to the time sequence, and the operation instructions of the same operation type are combined, for example, in table 3, there are two operation instructions with the operation type of "adding", and the two operation instructions are combined into one operation instruction. And after finishing the sorting and merging of the operation instructions corresponding to the data item indexes, sending the operation instructions and the operation types to the client according to a time sequence.
TABLE 3 Table 3
Data item index Operation type Operation instruction Time of operation
3 Adding Adding user information "Li Lei", "Man" 201905121155
3 Adding Adding user information Han Meimei and women " 201905181355
3 Modification of Modifying "telephone number" to "8566" 201905210855
The client 2 receives the one or more operation instructions after the merging and sorting sent by the computer device 1, and executes the one or more operation instructions in the client 2 according to the operation time sequence, so as to complete the synchronous update of the data information in the client 2.
The above-mentioned fig. 2 describes the data synchronization query method of the present invention in detail, and the functional modules of the software device implementing the data synchronization query method and the hardware device architecture implementing the data synchronization query method are described below with reference to fig. 3-4.
It should be understood that the embodiments described are for illustrative purposes only and are not limited to this configuration in the scope of the patent application.
FIG. 3 is a block diagram of a data synchronization query device according to a preferred embodiment of the present invention.
In some embodiments, the data synchronization querying device 10 is running in the computer device 1. The computer apparatus 1 is connected to a plurality of clients 2 via a network. The data synchronization querying device 10 may comprise a plurality of functional modules consisting of program code segments. Program code of the individual program segments in the data sync query means 10 may be stored in the memory of the computer means 1 and executed by the at least one processor for realizing the data sync query function.
In this embodiment, the data synchronization inquiry apparatus 10 may be divided into a plurality of functional modules according to the functions performed by the data synchronization inquiry apparatus. Referring to fig. 3, the functional module may include: the receiving module 101, the judging module 102, the first executing module 103 and the second executing module 104 refer to a series of computer program segments capable of being executed by at least one processor and performing a fixed function, and the modules are stored in a memory. In the present embodiment, the functions of the respective modules will be described in detail in the following embodiments.
The receiving module 101 is configured to receive a data query statement sent by a client.
In one embodiment, the query statement may be a structured query language. The structured query language is a database query and programming language for accessing data and querying, updating and managing relational database systems. The receiving module 101 receives the query statement sent by the client 2, and may receive the query statement one by one, and query the data to be queried according to the query statement.
In an embodiment, the client 2 may also write a plurality of pieces of data information to be queried into a query script using a structured query language, and may query the plurality of pieces of data information at a time using the query script. The receiving module 101 may receive a query script written in a structured query language sent by the client 2.
The judging module 102 is configured to judge whether the data to be queried by the query statement is a first query.
In one embodiment, the determining module 102 may check the validity of the received query term, and may feed back this error information to the client 2 if the determining module 102 considers that the query term does not conform to the grammar rules. If the query statement is legal, the identity information of the client 2 is judged, and whether the client 2 has the authority to access the database corresponding to the query statement is judged. And confirms the authority range of the client 2, and determines the data range which can be operated by the client 2. And if the client 2 does not have the database permission corresponding to the query statement, feeding back the client 2.
The method for determining whether the data to be queried in the query statement is the first query by the determining module 102 according to the received query statement sent by the client includes any one of the following modes:
searching whether a session table of the client 2 synchronous query record is contained in the operation instruction set table;
if the session table of the synchronous query record of the client 2 is not included, judging that the query statement is the first query;
If the session table of the synchronous query record of the client 2 is included, searching whether the data item index of the data to be queried is included in the session table, and if the data item index is not included, judging that the query statement is the first query.
Wherein the data item index is created for all data in the database by the computer apparatus 1, and the computer apparatus 1 also creates a data operation instruction set table for the data in the database. The operation instruction set table includes: data item index, operation time, operation type, operation instruction, session table. The data operation instruction set table is shown in table 1:
TABLE 1
When the data in the database is updated, generating an update record according to the data item index, the operation type, the operation instruction and the operation time of the data, and adding the update record into the data operation instruction set table.
For example, the determining module 102 searches the operation instruction set table for a session table including the client 2, where the session table is used for recording the query record of the client 2, and the content of the session table includes one or more of a data item index, a synchronization time, and a synchronization result of the query data. If the operation instruction set table does not contain the session table of the client 2, the data to be queried by the query statement is the first query. If the session table of the client 2 is included in the operation instruction set table, determining a data item index corresponding to the data according to the data to be queried in the session table, and searching whether the data item index is included in the session table, if not, determining that the data item index is queried for the first time. For example, in the operation instruction set table of table 1, each sequence number in a column of the session table corresponds to a client, and the determining module 102 first searches for whether a session table corresponding to the client exists in the operation instruction set table for the received query statement. As shown in table 2, table 2 is the content recorded in the session table 6, where the session table 6 is used for recording the query record of the client, and the data information updated by the client is recorded as follows: data item index 4, sync time 201906290925, sync result is successful. If the data item index corresponding to the query data exists in the session table, the data to be queried is not queried for the first time, and if the data to be queried does not exist, the data to be queried is queried for the first time.
TABLE 2
Data item index Synchronization time Synchronization results
4 201906290925 Success of
The first execution module 103 is configured to output a data query result when the queried data is the first query.
If the queried data is the first query, the steps may further include: and adding the data item index of the queried data and the operation type corresponding to the query statement into the session table.
For example, after the determining module 103 determines that the data to be queried is the first query, the first executing module 103 outputs a data query result, adds a data item index of the data to be queried to a session table corresponding to the client 2, and records the time and the synchronization result of the synchronization data in the session table.
In yet another embodiment of the present invention, the computer apparatus 1 outputs the data query result after determining that the data to be queried is the first query, and sends the data item index corresponding to the queried data to the client 2 together. The client 2 receives the query data and the data item index of the data, and creates a synchronous information state table according to the data item index; the synchronization information state table includes: one or more of data item index, synchronization time, synchronization result.
The client 2 receives the data query result sent by the computer device 1 and updates the data query result in the data system of the client 2.
The second execution module 104 is configured to, when the queried data is not the first query, search a session table for a last synchronization time of the data item index, determine at least one operation instruction corresponding to the data item index according to the synchronization time, and output the operation instruction.
In an embodiment of the present invention, if the queried data is not queried for the first time, searching for a last synchronization time of the data item index in a session table, determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction includes:
Searching at least one operation instruction corresponding to the data item index in a preset range in the operation instruction set table according to the synchronous time, wherein the preset range refers to the operation instruction corresponding to the data item index from the synchronous time to the current query time;
if the operation instruction corresponding to the data item index is one, the operation instruction is sent to the client;
And if the operation instructions corresponding to the data item indexes are multiple, the operation instructions are sorted and combined and then sent to the client.
If the operation instructions corresponding to the data item indexes are multiple, the step of sorting and merging the operation instructions may include:
extracting a plurality of operation instructions corresponding to the data item index, and sequencing the operation instructions according to a time sequence;
And merging operation instructions with the same operation type of two adjacent operation types according to the time sequence, wherein the operation types comprise one or more of deletion, addition and modification.
In one embodiment, after the computer device 1 analyzes the structured query statement, it determines that the data queried in the structured query statement is a second query, searches the session table for the synchronization time of the last synchronization of the data item index of the client 2 according to the data item index corresponding to the query data, and queries all the operation instructions from the last synchronization time to the current query time of the data item index in the operation instruction set table according to the synchronization time. For example, according to the data item index 3 to be queried by the client 2, if the data item index 3 is not queried for the first time, the computer device 1 queries that the last synchronization time of the data item index 3 is 201905091008 in the session table, searches all operation instructions corresponding to the data item index 3 from the point 08 of 2019, 5, 9, 10 and 10 to the current query time in the operation instruction set table, the operation instructions corresponding to the data item index 3 are shown in table 3, the operation times are arranged according to the time sequence, and the operation instructions of the same operation type are combined, for example, in table 3, there are two operation instructions with the operation type of "adding", and the two operation instructions are combined into one operation instruction. And after finishing the sorting and merging of the operation instructions corresponding to the data item indexes, sending the operation instructions and the operation types to the client according to a time sequence.
TABLE 3 Table 3
Data item index Operation type Operation instruction Time of operation
3 Adding Adding user information "Li Lei", "Man" 201905121155
3 Adding Adding user information Han Meimei and women " 201905181355
3 Modification of Modifying "telephone number" to "8566" 201905210855
The client 2 receives the one or more operation instructions after the merging and sorting sent by the computer device 1, and executes the one or more operation instructions in the client 2 according to the operation time sequence, so as to complete the synchronous update of the data information in the client 2.
FIG. 4 is a schematic diagram of a computer device according to a preferred embodiment of the invention.
The computer device 1 comprises a memory 20, a processor 30 and a computer program 40, such as a data synchronization query program, stored in the memory 20 and executable on the processor 30. The steps of the above-described embodiments of the data synchronization query method, such as steps S1 to S4 shown in fig. 2, are implemented when the processor 30 executes the computer program 40. Or the processor 30, when executing the computer program 40, performs the functions of the modules/units of the above-described embodiments of the data synchronization querying device, such as units 101-104 in fig. 3.
Illustratively, the computer program 40 may be partitioned into one or more modules/units that are stored in the memory 20 and executed by the processor 30 to complete the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions, which instruction segments are used for describing the execution of the computer program 40 in the computer device 1. For example, the computer program 40 may be divided into a receiving module 101, a judging module 102, a first executing module 103, and a second executing module 104 in fig. 3. For specific functions of each module, see embodiment three.
The computer device 1 may be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the computer apparatus 1 and does not constitute a limitation of the computer apparatus 1, and may comprise more or less components than shown, or may combine certain components, or different components, e.g. the computer apparatus 1 may further comprise input and output devices, network access devices, buses, etc.
The Processor 30 may be a central processing unit (Central Processing Unit, CPU), other general purpose Processor, digital signal Processor (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The general purpose processor may be a microprocessor or the processor 30 may be any conventional processor or the like, the processor 30 being the control center of the computer device 1, the various interfaces and lines being used to connect the various parts of the overall computer device 1.
The memory 20 may be used to store the computer program 40 and/or modules/units, and the processor 30 may perform various functions of the computer device 1 by executing or executing the computer program and/or modules/units stored in the memory 20, and invoking data stored in the memory 20. The memory 20 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data created according to the use of the computer apparatus 1 (such as audio data, phonebook, etc.), and the like. In addition, the memory 20 may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory card (SMART MEDIA CARD, SMC), secure Digital (SD) card, flash memory card (FLASH CARD), at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device.
The modules/units integrated in the computer device 1 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
In the several embodiments provided herein, it should be understood that the disclosed computer apparatus and method may be implemented in other ways. For example, the above-described embodiments of the computer apparatus are merely illustrative, and for example, the division of the units is merely a logical function division, and there may be other manners of division when actually implemented.
In addition, each functional unit in the embodiments of the present invention may be integrated in the same processing unit, or each unit may exist alone physically, or two or more units may be integrated in the same unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. Multiple units or computer means recited in the computer means claim may also be implemented by means of software or hardware by means of the same unit or computer means. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (8)

1.一种数据同步查询方法,应用于数据同步查询装置中,其特征在于,所述数据同步查询装置为数据库中的数据创建数据项索引以及操作指令集表,所述操作指令集表包括:数据项索引、操作时间、操作类型、操作指令、会话表,所述方法包括:1. A data synchronization query method, applied to a data synchronization query device, characterized in that the data synchronization query device creates a data item index and an operation instruction set table for data in a database, the operation instruction set table includes: data item index, operation time, operation type, operation instruction, and session table, the method includes: 接收客户端发送的数据查询语句;Receive data query statements sent by the client; 判断所述查询语句所要查询的数据是否为第一次查询,包括如下任意一种方式:在所述操作指令集表中查找是否包含所述客户端同步查询记录的会话表;若不包含所述客户端同步查询记录的会话表,则判定所述查询语句为第一次查询;若包含所述客户端同步查询记录的会话表,在所述会话表中查找是否包含所要查询是数据的数据项索引,若不包含,则判定所述查询语句为第一次查询;其中,所述会话表用于存储客户端的同步查询记录;所述会话表的内容包括:数据项索引、同步时间、同步结果中的一项或多项;Determining whether the data to be queried by the query statement is the first query includes any of the following methods: searching the operation instruction set table for a session table containing the client synchronization query record; if the session table containing the client synchronization query record is not contained, determining that the query statement is the first query; if the session table containing the client synchronization query record is contained, searching the session table for a data item index of the data to be queried; if not, determining that the query statement is the first query; wherein the session table is used to store the client synchronization query record; the content of the session table includes: one or more of the data item index, synchronization time, and synchronization result; 若所述查询的数据为第一次查询,则输出数据查询结果;及If the queried data is the first query, output the data query result; and 若所述查询的数据非第一次查询,则在会话表中查找所述数据项索引上一次的同步时间,及根据所述同步时间确定与所述数据项索引对应的至少一条操作指令,并输出所述操作指令。If the queried data is not the first query, the last synchronization time of the data item index is searched in the session table, and at least one operation instruction corresponding to the data item index is determined according to the synchronization time, and the operation instruction is output. 2.如权利要求1所述的数据同步查询方法,其特征在于,所述方法还包括:当所述数据库中的数据有更新时,以所述数据的数据项索引、操作类型、操作指令、操作时间生成一条更新记录并添加到所述数据操作指令集表中。2. The data synchronization query method as described in claim 1 is characterized in that the method also includes: when the data in the database is updated, an update record is generated based on the data item index, operation type, operation instruction, and operation time of the data and added to the data operation instruction set table. 3.如权利要求1所述的数据同步查询方法,其特征在于,若所述查询的数据为第一次查询,还包括:3. The data synchronization query method according to claim 1, characterized in that if the queried data is queried for the first time, it also includes: 将所述查询的数据的数据项索引和所述查询语句对应的操作类型添加到所述会话表中。The data item index of the queried data and the operation type corresponding to the query statement are added to the session table. 4.如权利要求1所述的数据同步查询方法,其特征在于,若所述查询的数据非第一次查询,则在会话表中查找所述数据项索引上一次的同步时间,及根据所述同步时间确定与所述数据项索引对应的至少一条操作指令,并输出所述操作指令的步骤包括:4. The data synchronization query method according to claim 1, characterized in that if the queried data is not queried for the first time, the steps of searching the session table for the last synchronization time of the data item index, determining at least one operation instruction corresponding to the data item index according to the synchronization time, and outputting the operation instruction include: 根据所述同步时间在所述操作指令集表中的预设范围中查找与所述数据项索引对应的至少一条操作指令,其中所述预设范围是指从所述同步时间到当前查询时间之间与所述数据项索引对应的操作指令;Searching for at least one operation instruction corresponding to the data item index in a preset range in the operation instruction set table according to the synchronization time, wherein the preset range refers to the operation instruction corresponding to the data item index between the synchronization time and the current query time; 若所述数据项索引对应的操作指令为一条,则将所述操作指令发送至客户端;及If there is one operation instruction corresponding to the data item index, sending the operation instruction to the client; and 若所述数据项索引对应的操作指令为多条,则将所述操作指令进行整理合并后发送至客户端。If there are multiple operation instructions corresponding to the data item index, the operation instructions are sorted and merged and then sent to the client. 5.如权利要求4所述的数据同步查询方法,其特征在于,若所述数据项索引对应的操作指令为多条,则将所述操作指令进行整理合并的步骤包括:5. The data synchronization query method according to claim 4, characterized in that if there are multiple operation instructions corresponding to the data item index, the step of arranging and merging the operation instructions comprises: 提取与所述数据项索引对应的多条操作指令,将所述多条操作指令按照时间顺序进行排序;Extracting a plurality of operation instructions corresponding to the data item index, and sorting the plurality of operation instructions in chronological order; 按照时间先后顺序,将相邻两项操作类型相同的操作指令进行合并,所述操作类型包括删除、添加、修改中的一项或多项。Two adjacent operation instructions of the same operation type are merged in chronological order, where the operation type includes one or more of deletion, addition, and modification. 6.一种数据同步查询装置,其特征在于,所述数据同步查询装置为数据库中的数据创建数据项索引以及操作指令集表,所述操作指令集表包括:数据项索引、操作时间、操作类型、操作指令、会话表,所述装置包括:6. A data synchronization query device, characterized in that the data synchronization query device creates a data item index and an operation instruction set table for data in a database, the operation instruction set table includes: data item index, operation time, operation type, operation instruction, and session table, and the device includes: 接收模块,用于接收客户端发送的数据查询语句;A receiving module, used for receiving a data query statement sent by a client; 判断模块,用于判断所述查询语句所要查询的数据是否为第一次查询,包括如下任意一种方式:在所述操作指令集表中查找是否包含所述客户端同步查询记录的会话表;若不包含所述客户端同步查询记录的会话表,则判定所述查询语句为第一次查询;若包含所述客户端同步查询记录的会话表,在所述会话表中查找是否包含所要查询是数据的数据项索引,若不包含,则判定所述查询语句为第一次查询;其中,所述会话表用于存储客户端的同步查询记录;所述会话表的内容包括:数据项索引、同步时间、同步结果中的一项或多项;The judgment module is used to judge whether the data to be queried by the query statement is the first query, including any of the following methods: searching whether the session table containing the client synchronization query record is included in the operation instruction set table; if the session table containing the client synchronization query record is not included, then the query statement is determined to be the first query; if the session table containing the client synchronization query record is included, searching whether the session table contains the data item index of the data to be queried, if not, then the query statement is determined to be the first query; wherein, the session table is used to store the client synchronization query record; the content of the session table includes: one or more of the data item index, synchronization time, and synchronization result; 第一执行模块,用于当所述查询的数据为第一次查询时,则并输出数据查询结果;及A first execution module, configured to output a data query result when the queried data is queried for the first time; and 第二执行模块,用于当所述查询的数据非第一次查询时,则在会话表中查找所述数据项索引上一次的同步时间,及根据所述同步时间确定与所述数据项索引对应的至少一条操作指令,并输出所述操作指令。The second execution module is used to search the session table for the last synchronization time of the data item index when the queried data is not queried for the first time, determine at least one operation instruction corresponding to the data item index according to the synchronization time, and output the operation instruction. 7.一种计算机装置,其特征在于:所述计算机装置包括处理器,所述处理器用于执行存储器中存储的计算机程序时实现如权利要求1-5中任一项所述的数据同步查询方法。7. A computer device, characterized in that: the computer device comprises a processor, and the processor is used to implement the data synchronization query method according to any one of claims 1 to 5 when executing a computer program stored in a memory. 8.一种计算机可读存储介质,其上存储有计算机程序,其特征在于:所述计算机程序被处理器执行时实现如权利要求1-5中任一项所述的数据同步查询方法。8. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the data synchronization query method according to any one of claims 1 to 5 is implemented.
CN201910780749.5A 2019-08-22 2019-08-22 Data synchronization query method, device, computer device and storage medium Active CN112416924B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910780749.5A CN112416924B (en) 2019-08-22 2019-08-22 Data synchronization query method, device, computer device and storage medium
TW108131975A TWI816875B (en) 2019-08-22 2019-09-04 Data synchronous query method, device, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910780749.5A CN112416924B (en) 2019-08-22 2019-08-22 Data synchronization query method, device, computer device and storage medium

Publications (2)

Publication Number Publication Date
CN112416924A CN112416924A (en) 2021-02-26
CN112416924B true CN112416924B (en) 2024-11-19

Family

ID=74779494

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910780749.5A Active CN112416924B (en) 2019-08-22 2019-08-22 Data synchronization query method, device, computer device and storage medium

Country Status (2)

Country Link
CN (1) CN112416924B (en)
TW (1) TWI816875B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117312445A (en) * 2023-09-15 2023-12-29 中国银行股份有限公司 Data synchronization method, apparatus, computer device, storage medium, and program product

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104488248A (en) * 2014-04-15 2015-04-01 华为技术有限公司 File synchronization method, server and terminal
CN106897338A (en) * 2016-07-04 2017-06-27 阿里巴巴集团控股有限公司 A kind of data modification request processing method and processing device for database

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101963993B (en) * 2010-10-21 2012-08-29 江苏科技大学 Method for fast searching database sheet table record
CN103514064B (en) * 2012-06-28 2016-03-16 国际商业机器公司 The method and apparatus of record backup information
CN104199881B (en) * 2014-08-21 2018-07-06 广州华多网络科技有限公司 Data-base cluster, data query method, method of data synchronization and device
CN105512200A (en) * 2015-11-26 2016-04-20 华为技术有限公司 Distributed database processing method and device
CN106789167A (en) * 2016-11-28 2017-05-31 努比亚技术有限公司 A kind of data processing method and server

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104488248A (en) * 2014-04-15 2015-04-01 华为技术有限公司 File synchronization method, server and terminal
CN106897338A (en) * 2016-07-04 2017-06-27 阿里巴巴集团控股有限公司 A kind of data modification request processing method and processing device for database

Also Published As

Publication number Publication date
TW202109307A (en) 2021-03-01
CN112416924A (en) 2021-02-26
TWI816875B (en) 2023-10-01

Similar Documents

Publication Publication Date Title
CN111737228B (en) Database and table dividing method and device
US11907251B2 (en) Method and system for implementing distributed lobs
US20200204688A1 (en) Picture book sharing method and apparatus and system using the same
CN111522574B (en) Differential packet generation method and related equipment
TWI686705B (en) Paging query method and device and electronic equipment
CN114461790B (en) Method, device, electronic device and storage medium for automatically generating news event topics
CN112307061B (en) Method and device for querying data
CN112527900A (en) Method, device, equipment and medium for database multi-copy reading consistency
CN107590248B (en) Search method, search device, search terminal and computer-readable storage medium
CN112559913A (en) Data processing method and device, computing equipment and readable storage medium
CN112416924B (en) Data synchronization query method, device, computer device and storage medium
CN115190136B (en) Data storage method, data transmission method and computing equipment
CN110222046A (en) Processing method, device, server and the storage medium of table data
CN119066670A (en) Systems and methods for protecting proprietary data when using third-party AI/ML services
CN111104408B (en) Data exchange method, device and storage medium based on map data
CN112733510A (en) Financial certificate generation method, device, equipment and computer readable storage medium
CN114153845B (en) Data storage and reading method, device, equipment and medium
CN112989011B (en) Data query method, data query device and electronic equipment
CN111526034B (en) Route centralized management method, device, electronic device and storage medium
US20180101622A1 (en) Perform graph traversal with graph query language
CN113268483A (en) Request processing method and device, electronic equipment and storage medium
CN111639103B (en) Service data processing method, device, computer system and medium
CN116541482B (en) Text object indexing method, object storage system and related equipment
KR102443302B1 (en) Apparatus and method for serverless service development based on blockchain
US20250103654A1 (en) Space-optimized forest for graph databases

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
GR01 Patent grant
GR01 Patent grant