Data query method and device and computer readable storage medium
By copying data from the data storage unit to the target database and converting the primary key to an object identifier, the problem of low efficiency in multi-database queries is solved, and efficient data querying is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-25
- Publication Date
- 2026-03-24
AI Technical Summary
In existing technologies, data query efficiency is low because it is necessary to query the interaction data between different objects and the same target object from multiple databases.
Data from different data storage units is pre-copied to a target database, and the primary key is converted into the object identifier of the target object, so that queries only need to access the target database, reducing the number of database accesses and the time required.
By accessing data from multiple data storage units simultaneously within a single database, the number of database accesses and the duration of access are reduced, thereby improving data query efficiency.
Smart Images

Figure CN116483871B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of financial technology and other related technologies, and more specifically, to a data query method, apparatus and computer-readable storage medium. Background Technology
[0002] In existing technologies, there are numerous scenarios where multiple objects interact with the same target object. For example, the target object may be a company, and the multiple objects may be multiple users who transact with that company.
[0003] In existing technologies, data is typically stored according to the user dimension. Therefore, the interaction data between multiple users and enterprises may be scattered in different data storage units. If an enterprise wants to obtain all the data between multiple users, it needs to access multiple data storage units separately to obtain all the data. Since each access to a data storage unit requires a certain amount of access time, it will undoubtedly consume a lot of access time when the amount of data is large, thus causing the problem of low data query efficiency.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This application provides a data query method, apparatus, and computer-readable storage medium to at least solve the technical problem of low data query efficiency in the prior art caused by the need to query the interaction data between different objects and the same target object from multiple databases.
[0006] According to one aspect of this application, a data query method is provided, comprising: receiving a data query instruction, wherein the data query instruction includes at least an object identifier of a target object; the object identifier of the target object is set as a target primary key to be queried, and target data corresponding to the target primary key is queried from a target database based on the target primary key, wherein the target data is data pre-copied from N data storage units to the target database, each data storage unit corresponds to M terminal objects, and each data storage unit is used to store interaction data between the M terminal objects and the target object, where N and M are positive integers.
[0007] Furthermore, the primary key corresponding to the data in each data storage unit is the object identifier of the terminal object corresponding to that data storage unit.
[0008] Furthermore, the data query method also includes: generating an information query instruction corresponding to each data storage unit based on the object identifier of the terminal object corresponding to each data storage unit, wherein the information query instruction is a database operation instruction that uses the object identifier of the terminal object corresponding to the data storage unit as the primary key to be queried; performing a data query operation in each data storage unit according to the information query instruction corresponding to each data storage unit to obtain the target data; and copying the obtained target data to the target database.
[0009] Furthermore, the data query method also includes: using the object identifier of the target object as the primary key and the data in the target data other than the object identifier of the target object as key values, and storing the target data in the target data in the form of key-value pairs.
[0010] Furthermore, the object identifiers of the M terminal objects corresponding to each data storage unit have the same information in the preset field.
[0011] Furthermore, the data query method also includes: monitoring the copying progress of the target data; and if the copying progress, which indicates that the copying time of the target data exceeds a preset time, generating a prompt message and pausing the copying of the target data.
[0012] Furthermore, the data query method also includes: before copying the target data to the target database, detecting the data storage space of each database in the multiple databases that is currently idle; calculating the total amount of the target data; and setting the database with the data storage space greater than the total amount of data as the target database.
[0013] Furthermore, the terminal object is a consumer object that purchases the product of the target object, and the target data is the consumption data between the terminal object and the target object.
[0014] Furthermore, the data query method also includes: after obtaining the target data corresponding to the target primary key from the target database based on the target primary key, determining the sales information of the target object's product based on the target data, wherein the sales information includes at least the product's sales target, the product's total sales amount, and the product's total sales profit.
[0015] Furthermore, the N data storage units are independent of each other, and each data storage unit consists of at least one relational database.
[0016] According to another aspect of the embodiments of this application, a data query device is also provided, comprising: a receiving module, configured to receive a data query instruction, wherein the data query instruction includes at least an object identifier of the target object; and a query module, configured to set the object identifier of the target object as a target primary key to be queried, and query the target data corresponding to the target primary key from a target database based on the target primary key, wherein the target data is data pre-copied from N data storage units to the target database, each data storage unit corresponds to M terminal objects, and each data storage unit is used to store interaction data between the M terminal objects and the target object, where N and M are positive integers.
[0017] According to another aspect of this application, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program controls the device where the computer-readable storage medium is located to execute the above-described data query method when it is running.
[0018] According to another aspect of this application, an electronic device is also provided, which includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the data query method described above.
[0019] In this application, a method is adopted whereby the first data in the first data storage unit and the second data in the second data storage unit are pre-copied into the target database. First, a data query instruction is received, wherein the data query instruction includes at least the object identifier of the target object. Then, the object identifier of the target object is set as the target primary key to be queried, and the target data corresponding to the target primary key is retrieved from the target database based on the target primary key. The target data is data pre-copied from N data storage units to the target database, each data storage unit corresponding to M terminal objects, and each data storage unit is used to store the interaction data between the M terminal objects and the target object. N and M are positive integers.
[0020] As can be seen from the above, this application pre-copies data from different data storage units (e.g., first data in the first data storage unit and second data in the second data storage unit) into the same target database, and converts all primary keys corresponding to the first and second data into object identifiers of the target object in the target database. Thus, when a data query instruction is received from the target object (e.g., an enterprise) that wants to query all related data corresponding to it, the first and second data can be obtained by directly accessing the target database, without having to access the first and second data storage units separately. This reduces the number of database accesses and the access time, thereby improving data query efficiency.
[0021] Therefore, the technical solution of this application achieves the goal of accessing data from multiple data storage units in one database at the same time, thereby shortening the number of database accesses and the time required, and thus solving the technical problem of low data query efficiency caused by the need to query the interaction data between different objects and the same target object from multiple databases in the prior art. Attached Figure Description
[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0023] Figure 1 This is a flowchart of an optional data query method according to an embodiment of this application;
[0024] Figure 2 This is a flowchart of an optional first data copying process according to an embodiment of this application;
[0025] Figure 3 This is a flowchart of an optional second data copying process according to an embodiment of this application;
[0026] Figure 4 This is a schematic diagram of a data query process according to an embodiment of this application;
[0027] Figure 5 This is a schematic diagram of an optional data query device according to an embodiment of this application. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] It should also be noted that all relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties. For example, if there is an interface between this system and the relevant user or organization, before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving consent information from the aforementioned user or organization.
[0031] Example 1
[0032] According to an embodiment of this application, an embodiment of a data query method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0033] Figure 1 This is a flowchart of an optional data query method according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0034] Step S101: Receive data query instruction.
[0035] In step S101, the data query instruction includes at least the object identifier of the target object.
[0036] Optionally, a data query system deployed in financial institutions such as banks can serve as the execution entity for the data query method in this application embodiment. The data query system can establish data connections with the target terminal corresponding to the target object and terminals corresponding to R other objects, where R is a positive integer, and the R other objects interact with the target object.
[0037] For example, the target is a paying company A. The first and second targets are users who purchase the target's services and pay the target. The transactions between the target and the first and second targets are mediated by a bank. Therefore, the bank stores the transaction data between the target and the first and second targets through a data storage unit.
[0038] Optionally, when a target object wants to query all the charging data within a preset time period, the target object can send a data query instruction to the data query system through the target terminal. The data query instruction includes at least the target object's object identifier, such as the mobile phone number that the target object has reserved in the data query system.
[0039] Step S102: Set the object identifier of the target object as the target primary key to be queried, and query the target data corresponding to the target primary key from the target database based on the target primary key.
[0040] In step S102, the target data is data that has been copied from N data storage units to the target database in advance. Each data storage unit corresponds to M terminal objects. Each data storage unit is used to store the interaction data between the M terminal objects and the target object. N and M are positive integers.
[0041] Optionally, after receiving the data query instruction sent by the target terminal, the data query system will determine the object identifier of the target object as the target primary key to be queried, and then query the target database to obtain multiple key-value pairs corresponding to the target primary key based on the target primary key to be queried.
[0042] It should be noted that the data in the target database is stored in the form of key-value pairs. The primary key for data related to the target object is the object identifier of the target object. Therefore, by using the object identifier of the target object as the target primary key to be queried, all data related to the target object can be retrieved from the target database.
[0043] In one optional embodiment, it is assumed that N data storage units are a first data storage unit and a second data storage unit, M terminal objects corresponding to the first data unit are first objects (assuming M is 1), and M terminal objects corresponding to the second data unit are second objects (assuming M is 1). The target data includes at least first data copied from the first data storage unit to the target database in advance, and second data copied from the second data storage unit to the target database in advance. The first data is the interaction data between the first object and the target object, and the second data is the interaction data between the second object and the target object. The second object and the first object are different terminal objects.
[0044] Furthermore, assuming there are 10 pieces of interactive data between the first object and the target object (corresponding to 10 pieces of first data), and 20 pieces of interactive data between the second object and the target object (corresponding to 20 pieces of second data), when the 10 pieces of first data are first generated, according to existing technology, data is stored at the user level. That is, the data corresponding to the first object is stored in one data storage unit (e.g., the first data storage unit), and the data corresponding to the second object is stored in another data storage unit (e.g., the second data storage unit). Based on this, if the 10 pieces of first data and the 20 pieces of second data are retrieved at this point, the data query system needs to access both the first and second data storage units separately. Since each access to a data storage unit consumes a certain amount of time, this undoubtedly leads to low data query efficiency when the data volume is large.
[0045] To address the aforementioned issues, this application copies the first and second data into the target database after obtaining the first and second data. When the data query system needs to query the first and second data, it no longer needs to access the first and second data storage units separately, thereby reducing the number of accesses to the data storage units and improving data query efficiency.
[0046] Optionally, the primary key corresponding to the data in each data storage unit is the object identifier of the terminal object corresponding to that data storage unit.
[0047] For example, the primary key corresponding to the first data in the first data storage unit is the object identifier of the first object, and the primary key corresponding to the second data in the second data storage unit is the object identifier of the second object. Here, a data storage unit can be understood as a self-contained set that can satisfy the relevant operations of a certain type of business processing steps divided according to a certain dimension. This set contains most of the key services required by this type of business processing steps, as well as the data that this set needs to process.
[0048] For example, suppose the target is power company A, and both the first and second targets are users who purchase electricity from power company A. The electricity bill payment transactions between the target and the first and second targets are mediated by a bank. In current fintech fields, data storage is typically based on the user dimension. To ensure data independence, data from different users may be stored separately. For instance, a user's mobile phone number might be used as a unique identifier. The first target's mobile phone number would be used as its object identifier, and the corresponding first data would be stored in the first data storage unit based on this identifier. The first data would be stored as a key-value pair, specifically, the object identifier of the first target would be the primary key. Similarly, the second target's mobile phone number would be used as its object identifier, and the corresponding second data would be stored in the second data storage unit based on this identifier. The second data would also be stored as a key-value pair, specifically, the object identifier of the second target would be the primary key.
[0049] In one optional embodiment, the data query system can generate an information query instruction corresponding to each data storage unit based on the object identifier of the terminal object corresponding to each data storage unit. The information query instruction is a database operation instruction that uses the object identifier of the terminal object corresponding to the data storage unit as the primary key to be queried. The system performs a data query operation in each data storage unit according to the information query instruction corresponding to each data storage unit to obtain the target data. The obtained target data is then copied to the target database.
[0050] In one alternative embodiment, Figure 2 A flowchart illustrating an optional first data copying process according to an embodiment of this application is shown, such as... Figure 2 As shown, it includes the following steps:
[0051] Step S201: Generate a first information query instruction based on the object identifier of the first object.
[0052] In step S201, the first information query instruction is a database operation instruction that uses the object identifier of the first object as the primary key to be queried.
[0053] Step S202: Perform a data query operation in the first data storage unit according to the first information query instruction to obtain a key-value pair with the object identifier of the first object as the primary key, and use the key-value pair with the object identifier of the first object as the primary key as the first data.
[0054] Step S202: Copy the first data to the target database.
[0055] Optionally, assuming the object identifier of the first object is its mobile phone number, the data query system generates a database operation instruction A-1 with the mobile phone number of the first object as the primary key to be queried. Then, based on the database operation instruction A-1, it performs a data query operation in the first data storage unit to obtain all key-value pairs in the first data storage unit with the mobile phone number of the first object as the primary key. Subsequently, the data query system uses these key-value pairs with the mobile phone number of the first object as the primary key as the first data and copies the first data to the target database.
[0056] In one alternative embodiment, Figure 3 A flowchart illustrating an optional second data copying process according to an embodiment of this application is shown, such as... Figure 3 As shown, it includes the following steps:
[0057] Step S301: Generate a second information query instruction based on the object identifier of the second object.
[0058] In step S301, the second information query instruction is a database operation instruction that uses the object identifier of the second object as the primary key to be queried.
[0059] Step S302: Perform a data query operation in the second data storage unit according to the second information query instruction to obtain a key-value pair with the object identifier of the second object as the primary key, and use the key-value pair with the object identifier of the second object as the second data.
[0060] Step S303: Copy the second data to the target database.
[0061] Optionally, assuming the object identifier of the second object is its mobile phone number, the data query system generates a database operation instruction B-2 with the mobile phone number as the primary key to be queried. Then, based on instruction B-2, it performs a data query operation in the second data storage unit to obtain all key-value pairs in the second data storage unit that use the mobile phone number as the primary key. Subsequently, the data query system uses these key-value pairs as the second data and copies them to the target database.
[0062] It should be noted that during the process of copying the target data obtained from the query to the target database, the data query system will use the object identifier of the target object as the primary key and the data in the target data other than the object identifier of the target object as the key value, and store the target data in the target data in the form of key-value pairs.
[0063] In addition, the object identifiers of the M first objects corresponding to each data storage unit have the same information in the preset field.
[0064] Specifically, in one optional embodiment, before generating the first information query instruction based on the object identifier of the first object, the data query system first obtains K pieces of third data, wherein each piece of third data is interaction data between a first type of object and a target object, the first object is one of the K first type of objects, and the information corresponding to the object identifier of each first type of object in a preset field is preset first target information, where K is a positive integer. Then, the data query system stores the K pieces of third data in a first data storage unit, wherein each piece of third data is stored in the first data storage unit in the form of a key-value pair, the object identifier corresponding to each piece of third data is the primary key of the key-value pair corresponding to the third data, and all information in each piece of third data except for the object identifier corresponding to the third data is the value of the key-value pair corresponding to the third data.
[0065] Optionally, the preset field can be a custom field set for the object identifier. For example, when the object identifier is a mobile phone number, the preset field can be the last four digits of the mobile phone number. The data query system can obtain all data that has interacted with the target object, then identify the object identifiers corresponding to these data, and store data with the same information corresponding to the preset field in the same data storage unit. For example, if the last four digits of the mobile phone number corresponding to the first object are 1102, the data query system will identify all data with the last four digits of the mobile phone number being 1102 as third data, and store these third data in a data storage unit (e.g., the first data storage unit) in the form of key-value pairs.
[0066] It should be noted that the third data can be the first data corresponding to the first object, or it can be the data corresponding to other objects. Among them, other objects are also objects of the first type. The information of the object identifier corresponding to the first type of object in the preset field is the same as the information of the object identifier corresponding to the first object in the preset field.
[0067] In an optional embodiment, before generating the second information query instruction based on the object identifier of the second object, the data query system further acquires J pieces of fourth data. Each piece of fourth data represents interaction data between a second-type object and a target object. The second object is one of the J second-type objects. The information corresponding to the object identifier of each second-type object in a preset field is preset second target information, where J is a positive integer. Then, the data query system stores the J pieces of fourth data in a second data storage unit. Each piece of fourth data is stored in the second data storage unit as a key-value pair. The object identifier corresponding to each piece of fourth data is the primary key of the key-value pair corresponding to that fourth data. All information in each piece of fourth data, except for the object identifier, is the value of the key-value pair corresponding to that fourth data.
[0068] Taking the example of the object identifier being the mobile phone number corresponding to the object and the preset field being the last four digits of the mobile phone number, assuming that the last four digits of the mobile phone number corresponding to the second object are 2202, the data query system will determine all data with the last four digits of the mobile phone number being 2202 as the fourth data, and store these fourth data in a data storage unit (such as the second data storage unit) in the form of key-value pairs.
[0069] In one optional embodiment, during the process of copying the target data obtained from the query to the target database, the data query system will also monitor the copying progress of the target data, and if the copying progress, which indicates that the copying time of the target data is longer than a preset time, generate a prompt message and pause the copying of the target data.
[0070] Optionally, since replication anomalies may occur during the data replication process, such as excessively long replication time due to high network latency, if the data replication process is still executed at this time, it may cause problems such as the inability to read business data normally, or even cause the system of the data storage unit to crash.
[0071] To avoid the aforementioned problems, the data query system sets a preset duration and monitors the target data replication progress in real time. If the replication time of the target data (representing the replication of the first data) exceeds the preset duration, the data query system will generate a prompt message and pause the replication of the target data. This prompt message is used to notify database administrators that the target data replication has failed.
[0072] In one optional embodiment, before copying the target data to the target database, the data query system also detects the data storage space of each database in multiple databases that is currently idle, calculates the total amount of the target data, and then the data query system identifies the database with the data storage space greater than the total amount of data as the target database.
[0073] In addition, the N data storage units are independent of each other, and each data storage unit consists of at least one relational database.
[0074] Optionally, since the target database needs to store data from multiple data storage units, it needs to have sufficient free storage resources. In this application, the data query system detects the data storage space that is currently idle in each of the multiple databases, and then identifies the database with more data storage space than the total amount of data as the target database, thereby ensuring that the selected target database has sufficient data storage space to store the target data.
[0075] Optionally, in this application, a distributed MySQL database may be selected as the first data storage unit, the second data storage unit, or other data storage units, and an HBase database may be selected as the target database.
[0076] Distributed MySQL databases are suitable for the following scenarios:
[0077] 1. Online transactions and small-batch intraday transactions with a single table size not exceeding 10 billion (inclusive).
[0078] 2. In scenarios with extremely high read / write ratios (such as parameter services), a backup database is needed to assist in providing read load balancing for online scenarios.
[0079] 3. Cross-database data query scenarios for application support personnel, etc.
[0080] HBase database is suitable for the following scenarios:
[0081] 1. Suitable for simple key-value queries and updates of massive amounts of data (hundreds of billions or more).
[0082] It is worth noting that HBase databases can store tens of billions of data points, while distributed MySQL databases can store no more than tens of billions of data points. Therefore, choosing distributed MySQL databases as the first data storage unit, the second data storage unit, and other data storage units, and choosing HBase databases as the target database, can adapt to the data query methods in this application.
[0083] It should be noted that in practical applications, HBase database can also be used as the first data storage unit, the second data storage unit, or other data storage units, or MySQL database can be used as the target database. The only requirement is that the idle data storage space in the target database is sufficient to meet the amount of data to be copied and stored.
[0084] In one alternative embodiment, Figure 4 A schematic diagram of a data query process according to an embodiment of this application is shown, such as... Figure 4 As shown, considering the characteristics of implementing a unitized architecture application with extremely high transaction volume and direct customer interaction, this application can provide online read and write of structured data through the Big Data Platform Table Storage Service (KVA) based on HBase database technology, and use data replication tools to store data units (e.g., Figure 4 The data in cells 1 to n are copied to the target database (e.g., a pre-defined HBase database) and then used in other applications (e.g., ...). Figure 4 In application B), when data needs to be queried, it is only necessary to query the data from the target database.
[0085] It should be noted that in this application, the storage performance requirements of data resources are met by using the HBase database, the key-value query function in KVA technology meets the timeliness requirements of data query, and the data replication method also has the advantages of low intrusion into online transactions and simple development.
[0086] In one optional embodiment, the terminal object is a consumer object that purchases the product of the target object, and the target data is the consumption data between the terminal object and the target object.
[0087] After retrieving the target data corresponding to the target primary key from the target database based on the target primary key, the data query system can determine the sales information of the target object's products based on the target data. The sales information includes at least the product's sales target, the product's total sales amount, and the product's total sales profit.
[0088] For example, suppose the target is power company A, and the first and second targets are both users who purchase electricity from power company A. The electricity bill payment transactions between the target and the first and second targets are mediated by a bank. If power company A wants to know all its billing data for a certain period, it can send a data query instruction to the bank's data query system. The data query system then retrieves the payment data (corresponding to the target data) of all users (including the first and second targets) who purchased electricity services from power company A from the target database. Based on this payment data, the data query system can calculate the total sales revenue and total profit of power company A's electricity services.
[0089] As can be seen from the above, this application pre-copies data from different data storage units (e.g., first data in the first data storage unit and second data in the second data storage unit) into the same target database, and converts all primary keys corresponding to the first and second data into object identifiers of the target object in the target database. Thus, when a data query instruction is received from the target object (e.g., an enterprise) that wants to query all related data corresponding to it, the first and second data can be obtained by directly accessing the target database, without having to access the first and second data storage units separately. This reduces the number of database accesses and the access time, thereby improving data query efficiency.
[0090] Therefore, the technical solution of this application achieves the goal of accessing data from multiple data storage units in one database at the same time, thereby shortening the number of database accesses and the time required, and thus solving the technical problem of low data query efficiency caused by the need to query the interaction data between different objects and the same target object from multiple databases in the prior art.
[0091] Example 2
[0092] This application also provides a data query device. It should be noted that the data query device of this application can be used to execute the data query method provided in embodiment 1 of this application. The data query device provided in this application is described below.
[0093] Figure 5 This is a schematic diagram of an optional data query device according to an embodiment of this application. Figure 5 As shown, the device includes: a receiving module 501, used to receive a data query instruction, wherein the data query instruction includes at least the object identifier of the target object; and a query module 502, used to set the object identifier of the target object as the target primary key to be queried, and to query the target data corresponding to the target primary key from the target database based on the target primary key, wherein the target data is data pre-copied from N data storage units to the target database, each data storage unit corresponds to M terminal objects, and each data storage unit is used to store the interaction data between the M terminal objects and the target object, where N and M are positive integers.
[0094] Optionally, the primary key corresponding to the data in each data storage unit is the object identifier of the terminal object corresponding to that data storage unit.
[0095] Optionally, the data query device further includes: a generation module, a target data query module, and a data copying module. The generation module is used to generate an information query instruction corresponding to each data storage unit based on the object identifier of the terminal object corresponding to each data storage unit, wherein the information query instruction is a database operation instruction using the object identifier of the terminal object corresponding to the data storage unit as the primary key to be queried; the target data query module is used to perform a data query operation in each data storage unit according to the information query instruction corresponding to each data storage unit to obtain the target data; the data copying module is used to copy the obtained target data to the target database.
[0096] Optionally, the data query device further includes: a data storage module, used to store the target data in the target data in the form of key-value pairs, with the object identifier of the target object as the primary key and the data in the target data other than the object identifier of the target object as the key value.
[0097] Optionally, the object identifiers of the M terminal objects corresponding to each data storage unit have the same information in the preset field.
[0098] Optionally, the data query device further includes a monitoring module and an information generation module, wherein the monitoring module is used to monitor the copying progress of the target data; and the information generation module is used to generate a prompt message and pause the copying of the target data when the copying progress, which indicates that the copying time of the target data exceeds a preset time.
[0099] Optionally, the data query device further includes a detection module, a calculation module, and a database setting module. The detection module is used to detect the data storage space that is currently idle in each of the multiple databases; the calculation module is used to calculate the total amount of the target data; and the database setting module is used to set databases whose data storage space is greater than the total amount of data as the target database.
[0100] Optionally, the terminal object is a consumer object that purchases the product of the target object, and the target data is the consumption data between the terminal object and the target object.
[0101] Optionally, the data query device further includes: a determination module, configured to determine the sales information of the target object's product based on the target data, wherein the sales information includes at least the product's sales target, the product's total sales amount, and the product's total sales profit.
[0102] Optionally, the N data storage units are independent of each other, and each data storage unit consists of at least one relational database.
[0103] Example 3
[0104] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the data query method in Embodiment 1 above when it is run.
[0105] Example 4
[0106] According to another aspect of the embodiments of this application, an electronic device is also provided, which includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the data query method in Embodiment 1 above.
[0107] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0108] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0109] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.
[0110] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0111] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0112] If the integrated unit is implemented as 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 technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0113] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A data query method, characterized in that, include: Receive a data query instruction, wherein the data query instruction includes at least the object identifier of the target object; The object identifier of the target object is set as the target primary key to be queried, and the target data corresponding to the target primary key is retrieved from the target database based on the target primary key. The target data is data that has been copied to the target database from N data storage units in advance. Each data storage unit corresponds to M terminal objects. Each data storage unit is used to store the interaction data between the M terminal objects and the target object. N and M are positive integers. The method further includes, during the process of copying target data from N data storage units to the target database in advance: Using the object identifier of the target object as the primary key, and the data in the target data other than the object identifier of the target object as the key value, the target data is stored in the target data in the form of key-value pairs; In this context, the object identifiers of the M terminal objects corresponding to each data storage unit have the same information in the preset field; the preset field is a field that is custom-set for the object identifier.
2. The method according to claim 1, characterized in that, The primary key of the data in each data storage unit is the object identifier of the terminal object corresponding to that data storage unit.
3. The method according to claim 2, characterized in that, The target data in the target database is obtained through the following process: An information query instruction corresponding to each data storage unit is generated based on the object identifier of the terminal object corresponding to each data storage unit. The information query instruction is a database operation instruction that uses the object identifier of the terminal object corresponding to the data storage unit as the primary key to be queried. Based on the information query instruction corresponding to each data storage unit, a data query operation is performed in each data storage unit to obtain the target data; Copy the target data obtained from the query to the target database.
4. The method according to claim 3, characterized in that, The method further includes the following steps during the process of copying the retrieved target data to the target database: Monitor the copying progress of the target data; If the copying progress, which indicates the copying time of the target data, exceeds a preset time, a prompt message is generated and the copying of the target data is paused.
5. The method according to claim 3, characterized in that, Before copying the retrieved target data to the target database, the method further includes: Detect the data storage space that is currently idle in each of multiple databases; Calculate the total amount of data in the target data; The database whose data storage space is greater than the total amount of data is set as the target database.
6. The method according to claim 1, characterized in that, The terminal object is a consumer object that purchases the product of the target object, and the target data is the consumption data between the terminal object and the target object.
7. The method according to claim 6, characterized in that, After retrieving the target data corresponding to the target primary key from the target database based on the target primary key, the method further includes: Based on the target data, the sales information of the target object's products is determined, wherein the sales information includes at least the target customers of the products, the total sales amount of the products, and the total sales profit of the products.
8. The method according to claim 1, characterized in that, The N data storage units are independent of each other, and each data storage unit consists of at least one relational database.
9. A data query device, characterized in that, include: A receiving module is used to receive a data query instruction, wherein the data query instruction includes at least the object identifier of the target object; The query module is used to set the object identifier of the target object as the target primary key to be queried, and to query the target data corresponding to the target primary key from the target database based on the target primary key. The target data is data that has been copied to the target database from N data storage units in advance. Each data storage unit corresponds to M terminal objects. Each data storage unit is used to store the interaction data between the M terminal objects and the target object. N and M are positive integers. The data query device further includes a data storage module, used to store the target data in the form of key-value pairs, with the object identifier of the target object as the primary key and the data in the target data other than the object identifier of the target object as the key value. In this context, the object identifiers of the M terminal objects corresponding to each data storage unit have the same information in the preset field; the preset field is a field that is custom-set for the object identifier.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed, it controls the device containing the computer-readable storage medium to perform the data query method according to any one of claims 1 to 8.
11. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the data query method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Association object obtaining method and device
CN108628941A
Data query method and device, computer equipment and storage medium
CN112765197A