Data synchronization query method, device, computer device and storage medium
By creating data item index and operation instruction set table for the database, and judging and sending data synchronization query methods, the problem of bandwidth wasted during data synchronization is solved, and more efficient data transmission is achieved.
Patent Information
- Application Number
- CN201910780749.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-22
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2039-08-22
AI Technical Summary
During the data synchronization process, the existing technology wastes bandwidth too much because the database server needs to transmit the complete data query results to the client, resulting in waste of resources.
By creating a data item index and operation instruction set table for the data in the database, we can determine whether the query is the first query. If it is not the first query, we will find and send the corresponding operation instructions based on the last synchronization time, rather than the complete data. Reduce the amount of data transmitted.
It effectively saves bandwidth resources, improves data synchronization efficiency, and reduces data transmission amount.
Smart Images

Figure CN112416924B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data query technology, and in particular to a data synchronization query method, a data synchronization query device, a computer device and a computer-readable storage medium. Background Art
[0002] In daily work, data synchronization is often required between different data storage points, such as between a database and a client. Usually, the server of the storage database executes the client's synchronization query command to query the data and returns the query results to the client. This method of querying and transmitting the data completely wastes too much bandwidth. Summary of the invention
[0003] In view of the above, it is necessary to propose a data synchronization query method and device, a computer device and a computer-readable storage medium, through which the client and the server can synchronize data in a more bandwidth-saving manner.
[0004] A 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, wherein the operation instruction set table includes: a data item index, an operation time, an operation type, an operation instruction, and a session table. The method includes:
[0005] Receive data query statements sent by the client;
[0006] Determine whether the data to be queried by the query statement is the first query;
[0007] If the queried data is the first query, output the data query result; and
[0008] 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.
[0009] Preferably, when the data in the database is updated, an update record is generated with the data item index, operation type, operation instruction, and operation time of the data and added to the data operation instruction set table.
[0010] Preferably, the session table is used to store the client's synchronous query records;
[0011] The content of the session table includes: one or more of: data item index, synchronization time, and synchronization result.
[0012] Preferably, the method for determining whether the data to be queried in the query statement is the first query includes any one of the following methods:
[0013] Searching the operation instruction set table to see whether a session table containing the client synchronization query record is included;
[0014] If the session table does not contain the client synchronous query record, it is determined that the query statement is the first query;
[0015] If the session table contains the client synchronous query record, the session table is searched to see whether the data item index of the data to be queried is contained. If not, it is determined that the query statement is the first query.
[0016] Preferably, if the queried data is queried for the first time, the step further includes:
[0017] The data item index of the queried data and the operation type corresponding to the query statement are added to the session table.
[0018] Preferably, 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:
[0019] 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;
[0020] If there is one operation instruction corresponding to the data item index, sending the operation instruction to the client; and
[0021] 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.
[0022] Preferably, if there are multiple operation instructions corresponding to the data item index, the step of arranging and merging the operation instructions includes:
[0023] Extracting a plurality of operation instructions corresponding to the data item index, and sorting the plurality of operation instructions in chronological order;
[0024] 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.
[0025] A second aspect of the present application provides a data synchronization query device, the device comprising:
[0026] A receiving module, used for receiving a data query statement sent by a client;
[0027] A judgment module, used to judge whether the data to be queried by the query statement is the first query;
[0028] A first execution module, configured to output a data query result when the queried data is queried for the first time; and
[0029] 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.
[0030] A third aspect of the present application provides a computer device, the computer device comprising a processor, the processor being configured to implement the above-mentioned data synchronization query method when executing a computer program stored in a memory.
[0031] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the data synchronization query method as described above.
[0032] The data synchronization query method of the present invention creates a data item index for all data in a database and a data operation instruction set table, and creates a session table for the query statement of the client, the session table records the data item index corresponding to the query statement of the client, and sends the operation instruction corresponding to the data item index corresponding to the data to be queried after the last update time in the operation instruction set table to the client. The method reduces the amount of query data and saves bandwidth. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is an application environment diagram of a data synchronization query method provided by one embodiment of the present invention.
[0034] Figure 2 It is a flow chart of a data synchronization query method provided by one embodiment of the present invention.
[0035] Figure 3 It is a functional module diagram of a data synchronization query device provided by one embodiment of the present invention.
[0036] Figure 4 It is a schematic diagram of a computer device provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0037] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0038] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. The embodiments described are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0040] See also Figure 1 , which is a schematic diagram of the application environment architecture of the data synchronization query method provided in the first embodiment of the present invention.
[0041] The data synchronization query method of the present invention is applied in a computer device 1, and the computer device 1 and at least one client 2 establish a communication connection through a network. The network can be a wired network or a wireless network, such as radio, wireless fidelity (Wireless Fidelity, WIFI), cellular, satellite, broadcast, etc.
[0042] The computer device 1 may be an electronic device equipped with a data synchronization query method and having storage and computing functions. Database information is stored in the computer device 1. The computer device 1 may be a personal computer, a server, etc., wherein the server may be a single server, a server cluster, a cloud server, etc.
[0043] The client 2 may be any intelligent electronic device with a file synchronization query function, which is used to send query statements to the computer device 1 and receive data query information sent by the computer device 1, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.
[0044] See also Figure 2 FIG. 1 is a flow chart of a data synchronization query method provided by a second embodiment of the present invention. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.
[0045] Step S1: receiving a query statement sent by a client.
[0046] In one embodiment, the query statement may be a structured query language. The structured query language is a database query and programming language used to access data and query, update and manage relational database systems. The computer device 1 equipped with the data synchronization query method receives the query statement sent by the client 2, and can receive the query statement one by one, and query the data to be queried according to the query statement.
[0047] In one embodiment, the client 2 may also write the multiple pieces of data information to be queried into a query script using a structured query language, and the query script may be used to query multiple pieces of data information at one time. The computer device 1 may receive the query script written in the structured query language sent by the client 2.
[0048] Step S2: Determine whether the data to be queried by the query statement is the first query.
[0049] In one embodiment, the computer device 1 can check the legality of the received query statement. If the process of the computer device 1 believes that the query statement does not comply with the grammatical requirements, the error message will be fed back to the client 2. If the query statement is legal, the identity information of the client 2 will be judged to determine whether the client 2 has the authority to access the database corresponding to the query statement. The scope of the authority of the client 2 will be confirmed to determine the scope of data that the client 2 can operate. If the client 2 does not have the database authority corresponding to the query statement, the error message will be fed back to the client 2.
[0050] The method in which the computer device 1 determines whether the data to be queried in the query statement is the first query according to the query statement received from the client includes any of the following methods:
[0051] Searching in the operation instruction set table whether a session table containing the synchronous query record of the client 2 is included;
[0052] If the session table does not contain the synchronous query record of the client 2, it is determined that the query statement is the first query;
[0053] If the session table of the synchronous query record of the client 2 is included, the session table is searched to see whether it contains the data item index of the data to be queried. If not, it is determined that the query statement is the first query.
[0054] The data item index is created by the computer device 1 for all data in the database, and the computer device 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, and session table. The data operation instruction set table is shown in Table 1:
[0055] Table 1
[0056]
[0057] When the data in the database is updated, an update record is generated with the data item index, operation type, operation instruction, and operation time of the data and added to the data operation instruction set table.
[0058] For example, the computer device 1 searches the operation instruction set table to see whether it contains the session table of the client 2, and the session table is used to record the query record of the client 2. The content of the session table includes one or more of the data item index of the query data, the synchronization time, and the synchronization result. 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 operation instruction set table contains the session table of the client 2, in the session table, the data item index corresponding to the data to be queried is determined according to the data to be queried, and the session table is searched to see whether the data item index is included. If not, the data item index is the first query. For example, in the operation instruction set table in Table 1, each serial number in the session table column corresponds to a client. For the received query statement, the computer device 1 first searches the operation instruction set table to see whether there is a session table corresponding to the client. As shown in Table 2, Table 2 is the content recorded in the session table 6, and the session table 6 is used to record the query record of the client, wherein the data information updated by the client is recorded as: data item index 4, synchronization time 201906290925, and synchronization 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 the first query; if not, the data to be queried is the first query.
[0059] Table 2
[0060] Data Item Index Synchronization Time Synchronization Result 4 201906290925 Success
[0061] Step S3: If the queried data is the first time to be queried, the data query result is output.
[0062] If the queried data is queried for the first time, the step may further include: adding a data item index of the queried data and an operation type corresponding to the query statement to the session table.
[0063] For example, after determining that the data to be queried is the first time to be queried, the computer device 1 outputs the data query result, adds the data item index of the data to be queried to the session table corresponding to the client 2, and records the time and synchronization result of this data synchronization in the session table.
[0064] In another embodiment of the present invention, after determining that the data to be queried is the first query, the computer device 1 outputs the data query result and sends the data item index corresponding to the queried data to the client 2. The client 2 receives the query data and the data item index of the data, and creates a synchronization information status table according to the data item index; the synchronization information status table includes: one or more of the data item index, synchronization time, and synchronization result.
[0065] 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 .
[0066] Step S4: If the queried data is not the first query, then search the session table for the 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.
[0067] In one embodiment of the present invention, 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:
[0068] 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;
[0069] If there is one operation instruction corresponding to the data item index, the operation instruction is sent to the client;
[0070] 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.
[0071] If there are multiple operation instructions corresponding to the data item index, the step of arranging and merging the operation instructions may include:
[0072] Extracting a plurality of operation instructions corresponding to the data item index, and sorting the plurality of operation instructions in chronological order;
[0073] 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.
[0074] In one embodiment, after parsing the structured query statement, the computer device 1 determines that the data queried in the structured query statement is the second query, searches the session table for the synchronization time of the last synchronization of the data item index by the client 2 according to the data item index corresponding to the query data, and searches the data item index in the operation instruction set table for all operation instructions of the data item index from the last synchronization time to the current query time according to the synchronization time. For example, if the computer device 1 searches the session table for the last synchronization time of the data item index 3 to be queried by the client 2 according to the data item index 3 is not the first query, then searches the operation instruction set table for all operation instructions corresponding to the data item index 3 from 10:08 on May 9, 2019 to the current query time, and the operation instructions corresponding to the data item index 3 are shown in Table 3, and the operation time is arranged in chronological order, and the operation instructions of the same operation type are merged. For example, in Table 3, there are two "operation instructions" with the operation type of "add", and these two operation instructions are merged into one. After the operation instructions corresponding to the data item indexes are sorted and merged, the operation instructions and operation types are sent to the client in chronological order.
[0075] Table 3
[0076] Data Item Index Operation Type Operation Instruction Operation Time 3 Add Add user information "Li Lei", "Male" 201905121155 3 Add Add user information "Han Meimei", "Female" 201905181355 3 Modify Modify "Phone Number" to "8566" 201905210855
[0077] The client 2 receives the merged and sorted one or more operation instructions sent by the computer device 1, and executes the one or more operation instructions on the client 2 in the order of operation time, so as to complete the synchronous update of data information in the client 2.
[0078] Above Figure 2 The data synchronization query method of the present invention is introduced in detail. In conjunction with Figures 3-4, the functional modules of the software device that implements the data synchronization query method and the hardware device architecture that implements the data synchronization query method are introduced below.
[0079] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited by this structure.
[0080] Figure 3 It is a structural diagram of a preferred embodiment of the data synchronization query device of the present invention.
[0081] In some embodiments, the data synchronization query device 10 runs in a computer device 1. The computer device 1 is connected to multiple clients 2 via a network. The data synchronization query device 10 may include multiple functional modules composed of program code segments. The program code of each program segment in the data synchronization query device 10 may be stored in the memory of the computer device 1 and executed by the at least one processor to implement the data synchronization query function.
[0082] In this embodiment, the data synchronization query device 10 can be divided into multiple functional modules according to the functions it performs. Figure 3 As shown, the functional module may include: a receiving module 101, a judging module 102, a first executing module 103, and a second executing module 104. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0083] The receiving module 101 is used to receive a data query statement sent by a client.
[0084] In one embodiment, the query statement may be a structured query language. The structured query language is a database query and programming language used to access data and query, update and manage 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.
[0085] In one embodiment, the client 2 may also write the multiple pieces of data information to be queried into a query script using a structured query language, and the query script may be used to query multiple pieces of data information at one time. The receiving module 101 may receive the query script sent by the client 2 and written in a structured query language.
[0086] The determination module 102 is used to determine whether the data to be queried by the query statement is the first query.
[0087] In one embodiment, the judgment module 102 can check the legality of the received query statement. If the judgment module 102 believes that the query statement does not comply with the grammatical requirements, the error message will be fed back to the client 2. If the query statement is legal, the identity information of the client 2 will be judged to determine whether the client 2 has the authority to access the database corresponding to the query statement. The authority scope of the client 2 is also confirmed to determine the data scope that the client 2 can operate. If the client 2 does not have the database authority corresponding to the query statement, the error message will be fed back to the client 2.
[0088] The method in which the judgment module 102 judges whether the data to be queried in the query statement is the first query according to the query statement received from the client includes any of the following methods:
[0089] Searching in the operation instruction set table whether a session table containing the synchronous query record of the client 2 is included;
[0090] If the session table does not contain the synchronous query record of the client 2, it is determined that the query statement is the first query;
[0091] If the session table of the synchronous query record of the client 2 is included, the session table is searched to see whether it contains the data item index of the data to be queried. If not, it is determined that the query statement is the first query.
[0092] The data item index is created by the computer device 1 for all data in the database, and the computer device 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, and session table. The data operation instruction set table is shown in Table 1:
[0093] Table 1
[0094]
[0095] When the data in the database is updated, an update record is generated with the data item index, operation type, operation instruction, and operation time of the data and added to the data operation instruction set table.
[0096] For example, the judgment module 102 searches the operation instruction set table for whether the session table of the client 2 is included. The session table is used to record the query record of the client 2. The content of the session table includes one or more of the data item index of the query data, the synchronization time, and the synchronization result. If the operation instruction set table does not include the session table of the client 2, the data to be queried by the query statement is the first query. If the operation instruction set table includes the session table of the client 2, in the session table, the data item index corresponding to the data to be queried is determined according to the data to be queried, and the session table is searched for whether the data item index is included. If not, the data item index is the first query. For example, in the operation instruction set table of Table 1, each serial number in the session table column corresponds to a client. For the received query statement, the judgment module 102 first searches the operation instruction set table for whether there is a session table corresponding to the client. As shown in Table 2, Table 2 is the content recorded in the session table 6, and the session table 6 is used to record the query record of the client, wherein the data information updated by the client is recorded as follows: data item index 4, synchronization time 201906290925, and synchronization 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 the first query, and if not, the data to be queried is the first query.
[0097] Table 2
[0098] Data Item Index Synchronization Time Synchronization Result 4 201906290925 Success
[0099] The first execution module 103 is used to output the data query result when the queried data is queried for the first time.
[0100] If the queried data is queried for the first time, the step may further include: adding a data item index of the queried data and an operation type corresponding to the query statement to the session table.
[0101] For example, after judging that the data to be queried is queried for the first time, the first execution module 103 outputs the data query result, adds the data item index of the data to be queried to the session table corresponding to the client 2, and records the time and synchronization result of this data synchronization in the session table.
[0102] In another embodiment of the present invention, after determining that the data to be queried is the first query, the computer device 1 outputs the data query result and sends the data item index corresponding to the queried data to the client 2. The client 2 receives the query data and the data item index of the data, and creates a synchronization information status table according to the data item index; the synchronization information status table includes: one or more of the data item index, synchronization time, and synchronization result.
[0103] 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 .
[0104] The second execution module 104 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.
[0105] In one embodiment of the present invention, 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:
[0106] 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;
[0107] If there is one operation instruction corresponding to the data item index, the operation instruction is sent to the client;
[0108] 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.
[0109] If there are multiple operation instructions corresponding to the data item index, the step of arranging and merging the operation instructions may include:
[0110] Extracting a plurality of operation instructions corresponding to the data item index, and sorting the plurality of operation instructions in chronological order;
[0111] 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.
[0112] In one embodiment, after parsing the structured query statement, the computer device 1 determines that the data queried in the structured query statement is the second query, searches the session table for the synchronization time of the last synchronization of the data item index by the client 2 according to the data item index corresponding to the query data, and searches the data item index in the operation instruction set table for all operation instructions of the data item index from the last synchronization time to the current query time according to the synchronization time. For example, if the computer device 1 searches the session table for the last synchronization time of the data item index 3 to be queried by the client 2 according to the data item index 3 is not the first query, then searches the operation instruction set table for all operation instructions corresponding to the data item index 3 from 10:08 on May 9, 2019 to the current query time, and the operation instructions corresponding to the data item index 3 are shown in Table 3, and the operation time is arranged in chronological order, and the operation instructions of the same operation type are merged. For example, in Table 3, there are two "operation instructions" with the operation type of "add", and these two operation instructions are merged into one. After the operation instructions corresponding to the data item indexes are sorted and merged, the operation instructions and operation types are sent to the client in chronological order.
[0113] Table 3
[0114] Data Item Index Operation Type Operation Instruction Operation Time 3 Add Add user information "Li Lei", "Male" 201905121155 3 Add Add user information "Han Meimei", "Female" 201905181355 3 Modify Modify "Phone Number" to "8566" 201905210855
[0115] The client 2 receives the merged and sorted one or more operation instructions sent by the computer device 1, and executes the one or more operation instructions on the client 2 in the order of operation time, so as to complete the synchronous update of data information in the client 2.
[0116] Figure 4 FIG. 4 is a schematic diagram of a preferred embodiment of a computer device of the present invention.
[0117] The computer device 1 includes a memory 20, a processor 30, and a computer program 40 stored in the memory 20 and executable on the processor 30, such as a data synchronization query program. When the processor 30 executes the computer program 40, the steps in the above-mentioned data synchronization query method embodiment are implemented, such as Figure 2 Alternatively, when the processor 30 executes the computer program 40, the functions of each module / unit in the above-mentioned data synchronization query device embodiment are realized, for example Figure 3 Units 101-104 in.
[0118] Exemplarily, the computer program 40 may be divided into one or more modules / units, which are stored in the memory 20 and executed by the processor 30 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program 40 in the computer device 1. For example, the computer program 40 may be divided into Figure 3 The receiving module 101, the judging module 102, the first executing module 103, and the second executing module 104 in the embodiment. For the specific functions of each module, please refer to the third embodiment.
[0119] The computer device 1 may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. Those skilled in the art will appreciate that the schematic diagram is merely an example of the computer device 1 and does not limit the computer device 1. The computer device 1 may include more or fewer components than shown in the diagram, or may combine certain components, or may include different components. For example, the computer device 1 may also include input and output devices, network access devices, buses, etc.
[0120] The processor 30 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor 30 may be any conventional processor, etc. The processor 30 is the control center of the computer device 1, and uses various interfaces and lines to connect various parts of the entire computer device 1.
[0121] The memory 20 can be used to store the computer program 40 and / or modules / units. The processor 30 implements various functions of the computer device 1 by running or executing the computer program and / or modules / units stored in the memory 20 and calling the data stored in the memory 20. The memory 20 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the computer device 1 (such as audio data, a phone book, etc.), etc. In addition, the memory 20 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0122] If the module / unit integrated in the computer device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0123] In the several embodiments provided by the present invention, it should be understood that the disclosed computer device and method can be implemented in other ways. For example, the computer device embodiment described above is only illustrative, for example, the division of the unit is only a logical function division, and there may be other division methods in actual implementation.
[0124] In addition, each functional unit in each embodiment of the present invention may be integrated into the same processing unit, each unit may exist physically separately, or two or more units may be integrated into the same unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0125] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or computer devices stated in the computer device claim can also be implemented by the same unit or computer device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
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 the data in the database, wherein 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. The data synchronization query method according to claim 1, characterized in that: The method further comprises: when the data in the database is updated, generating an update record with the data item index, operation type, operation instruction, and operation time of the data and adding the update record to the data operation instruction set table.
3. The data synchronization query method according to claim 1, characterized in that: If the queried data is the first query, 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. The data synchronization query method according to claim 1, characterized in that: If the queried data is not queried for the first time, 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 comprises: 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. 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 includes: 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. 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 the data in the database, wherein the operation instruction set table includes: data item index, operation time, operation type, operation instruction, and session table. 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. A computer device, characterized in that: The computer device includes 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. A computer-readable storage medium having a computer program stored thereon, characterized in that: 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.
