CN107220376B - Data query method and device - Google Patents
Data query method and device Download PDFInfo
- Publication number
- CN107220376B CN107220376B CN201710476723.2A CN201710476723A CN107220376B CN 107220376 B CN107220376 B CN 107220376B CN 201710476723 A CN201710476723 A CN 201710476723A CN 107220376 B CN107220376 B CN 107220376B
- Authority
- CN
- China
- Prior art keywords
- query
- queried
- data source
- dimension
- item
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
- G06F16/24534—Query rewriting; Transformation
- G06F16/24549—Run-time optimisation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a data query method and a data query device, wherein the data query method comprises the following steps: the method comprises the steps of obtaining a first query request comprising a task to be queried and a dimension to be queried, determining a data source corresponding to each item to be queried under the dimension to be queried in the task to be queried according to configuration information, then determining each item to be queried belonging to the same data source, generating a corresponding second query request, and obtaining batch query results from the corresponding data source by adopting the second query request. Therefore, the behavior of inquiring different data sources for many times in the complex logic is combined into the behavior of inquiring each data source once in batch, the network overhead is greatly reduced, and the inquiring efficiency of the data inquiry is effectively improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of electric communication, in particular to a data query method and a data query device.
Background
With the rapid development of network technology and computer technology, people generate more and more data and information in life and work. In order to query these data, there may be multiple data sources in a large-scale system, and one query request may need to be directed to multiple different data sources. Moreover, as services expand and logic complexity increases, multiple queries may need to be performed on the same data source for one query request, which may greatly increase network IO consumption between the service party sending the query request and the data source, resulting in an impact on throughput and an increase in system delay. In extreme cases, it may also cause a service outage, seriously affecting the query efficiency.
Therefore, how to effectively improve the query efficiency in the data query process is a technical problem to be solved at present.
Disclosure of Invention
The embodiment of the invention provides a data query method and a data query device, which are used for solving the problem that real-time data query influences a production system in the prior art.
In order to solve the above problems, the present invention discloses a data query method, including:
acquiring a first query request, wherein the first query request comprises a task to be queried and a dimension to be queried;
determining a data source corresponding to each item to be queried under the dimension to be queried in the task to be queried according to configuration information;
determining items to be queried belonging to the same data source, and generating a corresponding second query request, wherein the second query request is used for carrying out batch query on the items to be queried corresponding to the data source;
and acquiring a batch query result from the corresponding data source by adopting the second query request.
Preferably, the step of determining, according to the configuration information, a data source corresponding to each item to be queried under the dimension to be queried in the task to be queried includes: inquiring configuration information according to the task to be inquired and the dimension to be inquired, and determining a matched inquiry dimension in the configuration information and an inquiry item corresponding to the matched inquiry dimension; taking the inquired inquiry item as an item to be inquired from a data source; and determining the data source corresponding to each item to be queried according to the corresponding relation between the query item and the data source in the configuration information.
Preferably, the step of determining a query dimension matched with the configuration information and a query item corresponding to the matched query dimension according to the task to be queried and the query configuration information of the query dimension includes: inquiring configuration information according to the task to be inquired, and determining an inquiry task matched with the configuration information; and inquiring the matched inquiry tasks in the configuration information according to the dimension to be inquired, and determining inquiry items corresponding to the matched inquiry dimension.
Preferably, the step of determining each item to be queried belonging to the same data source and generating a corresponding second query request includes: merging the items to be queried belonging to the same data source to generate a group of items to be queried corresponding to the data source; and respectively adding corresponding query codes for each group of items to be queried to generate the second query request, wherein each query code is used for initiating the second query request to a corresponding data source.
Preferably, the data query method further includes a configuration information changing step: changing the query dimension corresponding to the query task; and/or altering query terms corresponding to the query dimensions.
On the other hand, in order to solve the above problem, the present invention also discloses a data query apparatus, including:
the system comprises a first request acquisition module, a first query module and a second query module, wherein the first request acquisition module is used for acquiring a first query request, and the first query request comprises a task to be queried and a dimension to be queried;
the data source determining module is used for determining a data source corresponding to each item to be queried under the dimension to be queried in the task to be queried according to the configuration information;
the second request generation module is used for determining all items to be queried which belong to the same data source and generating corresponding second query requests, wherein the second query requests are used for carrying out batch query on all items to be queried which correspond to the data source;
and the query result acquisition module is used for acquiring the batch query results from the corresponding data source by adopting the second query request.
Preferably, the data source determining module includes: the query item determining submodule is used for determining a matched query dimension in the configuration information and a query item corresponding to the matched query dimension according to the task to be queried and the query configuration information of the dimension to be queried; taking the inquired inquiry item as an item to be inquired from a data source; and the data source determining submodule is used for determining the data source corresponding to each item to be queried according to the corresponding relation between the query item and the data source in the configuration information.
Preferably, the query term determination sub-module includes: the first matching unit is used for inquiring the configuration information according to the task to be inquired and determining the matched inquiry task in the configuration information; and the second matching unit is used for querying the matched query tasks in the configuration information according to the dimension to be queried and determining the query items corresponding to the matched query dimension.
Preferably, the second request generating module includes: the grouping submodule is used for merging the items to be queried which belong to the same data source to generate a group of items to be queried corresponding to the data source; and the assembling sub-module is used for respectively adding corresponding query codes for each group of items to be queried and generating the second query request, wherein each query code is used for initiating the second query request to a corresponding data source.
Preferably, the apparatus further comprises: the configuration changing module is used for changing the query dimension corresponding to the query task; and/or altering query terms corresponding to the query dimensions.
To sum up, in the embodiments of the present invention, a first query request including a task to be queried and a dimension to be queried is obtained, a data source corresponding to each item to be queried under the dimension to be queried in the task to be queried is determined according to configuration information, then each item to be queried belonging to the same data source is determined, a corresponding second query request is generated, and a batch query result is obtained from the corresponding data source by using the second query request. Therefore, the behavior of inquiring different data sources for many times in the complex logic is combined into the behavior of inquiring each data source once in batch, the network overhead is greatly reduced, and the inquiring efficiency of the data inquiry is effectively improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a flowchart of a data query method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another data query method provided by the embodiment of the invention;
fig. 3 is a block diagram of a data query device according to an embodiment of the present invention;
fig. 4 is a block diagram of another data query apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Referring to fig. 1, a flowchart of a data query method provided by an embodiment of the present invention is shown.
The first query request is a data query request initiated by a service party, and comprises a task to be queried and a dimension to be queried. The task to be inquired refers to a task needing to be inquired, the task to be inquired is determined according to each inquiry task defined in advance, and the inquiry tasks comprise: one or more query dimensions, each query dimension corresponding to one or more query terms, such that queries can be performed from the one or more query dimensions for a query task. The dimension to be queried refers to one or more dimensions which need to be queried in order to complete the task to be queried, wherein each dimension to be queried is used for representing a query angle related to the task to be queried, and for example, when a transaction risk is queried, the query can be performed from the angles of user behavior information, a user mobile phone number, a user identity card and the like.
And step 102, determining a data source of each item to be queried under the dimension to be queried in the task to be queried according to the configuration information.
The configuration information is used for managing various query tasks in the system, and comprises the following steps: predefined query tasks and the corresponding relation between query items in each query task and a data source. Specifically, each query task may include at least one query dimension, each query dimension includes at least one query term, and each query term corresponds to one data source. That is, each query term queries data from a unique corresponding one of the data sources.
Specifically, according to the task to be queried and the query configuration information of the query dimension, the query dimension matched with the configuration information and the query item corresponding to the matched query dimension can be determined, and then each query item corresponding to the task to be queried is determined. And determining the data source corresponding to each item to be queried according to the corresponding relation between the query item and the data source in the configuration information.
And 103, determining all items to be queried which belong to the same data source, and generating a corresponding second query request.
Because each query item queries data from one data source which is only corresponding to the query item, the query items to be queried can be grouped according to the data sources, the query items which belong to the same data source are combined, and a group of query items corresponding to the data sources are generated.
Because each item to be queried in each group of items to be queried corresponds to the same data source, and each query code is used for initiating a second query request to one corresponding data source, the second query request for querying data to the corresponding data source can be generated only by adding the query code to each group of items to be queried once, and a plurality of query items can be queried only by one query request. The second query request is an integrated data query request facing a data source, the first query request is a data query request initiated by a service party, and a primary query request initiated by the service party and directly facing the data source in the prior art is replaced by the combination of the two query requests, namely the first query request and the second query request, so that each query item can be configured between the two query requests, and the efficiency of data query is improved. Compared with the prior art that query codes need to be added to each query item respectively and corresponding query requests need to be generated respectively to obtain corresponding query results, the embodiment greatly reduces the number of query requests for performing data query on the data source.
And 104, acquiring a batch query result from the corresponding data source by adopting the second query request.
After the second query request is generated, the second query request may be sent to a corresponding data source to query a record that conforms to the value of each item to be queried in the second query request, and the queried record is used as a batch query result of the second query request.
In summary, in the embodiments of the present invention, a first query request including a task to be queried and a dimension to be queried is obtained, a data source corresponding to each item to be queried in the dimension to be queried in the task to be queried is determined according to configuration information, then each item to be queried belonging to the same data source is determined, a corresponding second query request is generated, and a batch query result is obtained from the corresponding data source by using the second query request. Therefore, the behavior of inquiring different data sources for many times in the complex logic is combined into the behavior of inquiring each data source once in batch, the network overhead is greatly reduced, and the inquiring efficiency of the data inquiry is effectively improved.
Example two
On the basis of the above embodiments, the present embodiment further discusses a data query method.
With the change of the system environment and the upgrade of the query means, in order to complete a certain query task, in the embodiment of the application, the corresponding relation between the query task and the query dimension and/or the corresponding relation between the query dimension and the query item can be changed, so that the query strategy for each query task can be adjusted at any time, and the configuration is more flexible. For example, when the purchasing member service needs to pay, in order to ensure the transaction security, a query task of "transaction risk query" needs to be executed to confirm whether the current transaction environment is sufficiently secure. And if the query dimension corresponding to the query task 'transaction risk query' in the original configuration information is user behavior information, a user identity card and transaction equipment. With the continuous enrichment of the functions of the mobile phone, the transaction risk can be determined through the mobile phone number of the user, so that the configuration information can be changed, and the query dimension of the mobile phone number of the user is increased in the query task of 'transaction risk query'. For another example, if the query item corresponding to the query dimension of the user's mobile phone number in the original configuration information is, whether the mobile phone is marked as a rogue mobile phone, and whether the mobile phone is marked as a malicious mobile phone. In order to enhance the query effect of the query dimension of the mobile phone number of the user, the query item of whether the mobile phone belongs to the mobile phone small number or not can be increased. After the configuration information is changed, the user can input the task to be queried and the dimension to be queried according to the changed configuration information so as to realize the corresponding query effect.
The change of the query dimension in the query task can cause the increase and decrease of the corresponding query item. When newly added query items are needed, the corresponding relationship between each newly added query item and each data source is configured according to the information of the data source to which each newly added query item belongs. And ensuring that the data source corresponding to each item to be inquired can be inquired through the task to be inquired and the dimension to be inquired.
Referring to fig. 2, a flow chart of another data query method provided by the embodiment of the present invention is shown:
Different from the prior art that each query request initiated by a service party needs to include a query code, the first query request acquired in this embodiment may not need to include a query code, and after the items to be queried are grouped and combined according to the data source, the query code corresponding to the data source is added when the second query request is generated. The task to be queried input by the user may be a name of the task to be queried. For example, when querying a query task of transaction risk in a wind control system, a user may input a predefined query task name "transaction risk query" and corresponding dimensions to be queried: user behavior information, a user mobile phone number and a user identity card.
Because the first query request does not need to contain the query code, the query code in the configuration information is added when the second query request is generated, when the query code is changed, the code does not need to be modified one by one for a large number of query requests, only the query code in the configuration information needs to be changed, the code management is convenient, and the repeated codes are reduced.
Specifically, the configuration information may be queried according to the task to be queried to determine a query task matching with the configuration information, and then the query task matching with the configuration information may be queried according to the dimension to be queried to determine a query term corresponding to the matched query dimension. For example, configuration information may be queried according to a task to be queried, which is "transaction risk query", to determine a query task matching the configuration information, where the query dimensions corresponding to the query task matching the configuration information may be 4, and the query dimensions are user behavior information, a user mobile phone number, a user identity card, and transaction equipment, respectively. And if the dimension to be inquired input by the user is user behavior information, a user mobile phone number and a user identity card, determining the inquiry item corresponding to the matched inquiry dimension according to the 3 dimensions to be inquired.
And step 203, taking the inquired inquiry item as an item to be inquired from the data source.
The query items queried according to the configuration information are the items to be queried required for completing the corresponding query task, and the query results required by the query task can be obtained by querying the items to be queried from the data source.
And 204, determining the data source corresponding to each item to be queried according to the corresponding relation between the query item and the data source in the configuration information.
Because the corresponding relation between the query item and the data source is configured in the configuration information in advance, the data source corresponding to each item to be queried, which is matched with the query item, can be determined through the configuration information.
The data source can be various databases such as a relational database, a distributed database, a cache database and the like.
The corresponding relation between each item to be queried and the data source is that each query item queries data from a unique corresponding data source, and each data source corresponds to different query items, so that the items to be queried can be grouped based on the data sources. The items to be queried belonging to the same data source are combined into one group, so that different data sources respectively correspond to different groups of items to be queried. For example, if the query terms a1, a2, a3 in the configuration information correspond to data source a, the query terms B1, B2, B3, B4 correspond to data source B, and the query terms C1, C2, C3 correspond to data source C. When the items to be queried are a1, a2, B2, B3, B4, C2 and C3, the items a1 and a2 to be queried can be merged to generate a group of items to be queried corresponding to the data source a, the items B2, B3 and B4 to be queried are merged to generate a group of items to be queried corresponding to the data source B, and then the items C2 and C3 to be queried are merged to generate a group of items to be queried corresponding to the data source C.
And step 206, adding corresponding query codes for each group of items to be queried respectively, and generating a second query request.
The query codes respectively aiming at different data sources can be packaged in advance, and after the items to be queried are grouped, the query codes corresponding to the data sources to which the items to be queried belong can be directly added, so that a second query request is generated.
In order to make the data queried from the data source more easy to use, the data type of the value-taking record corresponding to the query term can be configured, if the query term is a name, the data type of the query term is configured to be a text type, and if the query term is a birthday, the data type of the query term is configured to be a date type.
And step 207, acquiring the batch query result from the corresponding data source by adopting the second query request.
After the second query request is generated, the interface between the system and the data source is called, and the batch query results of each group of query items are obtained from the corresponding data source. Therefore, the query results of the plurality of query items can be obtained only by querying the same data source once, and the network IO consumption between the service party initiating the first query request and the data source is greatly reduced.
In summary, the embodiment of the present invention determines the configuration information in advance, so that the adjustment of the query task can be embodied in the change of the configuration information, when the first query request is obtained, the adjusted configuration information can be queried according to the task to be queried and the dimension to be queried to obtain the corresponding item to be queried, and then the items to be queried belonging to the same data source are merged according to the corresponding relationship between the query items in the configuration information and the data source to generate the second query request, and the second query request is adopted to obtain the batch query result from the corresponding data source. Because newly-added query can be realized only by changing configuration information without modifying codes one by one, the network overhead is greatly reduced, and the query efficiency is greatly improved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
EXAMPLE III
On the basis of the above embodiments, the present embodiment also provides a data query apparatus.
Referring to fig. 3, a block diagram of a data query apparatus according to an embodiment of the present invention is provided, which may specifically include the following modules:
a first request obtaining module 31, configured to obtain a first query request, where the first query request includes a task to be queried and a dimension to be queried;
the data source determining module 32 is configured to determine, according to the configuration information, a data source corresponding to each item to be queried in the dimension to be queried in the task to be queried;
the second request generating module 33 is configured to determine each to-be-queried item belonging to the same data source, and generate a corresponding second query request, where the second query request is used to perform batch query on each to-be-queried item corresponding to the data source;
and the query result obtaining module 34 is configured to obtain the batch query results from the corresponding data source by using the second query request.
In summary, in the embodiment of the present invention, the first request obtaining module 31 obtains the first query request including the task to be queried and the dimension to be queried, the data source determining module 32 determines the data source corresponding to each item to be queried in the dimension to be queried in the task to be queried according to the configuration information, the second request generating module 33 determines each item to be queried belonging to the same data source, generates the corresponding second query request, and the query result obtaining module 34 obtains the batch query results from the corresponding data source by using the second query request. Therefore, the behavior of inquiring different data sources for many times in the complex logic is combined into the behavior of inquiring each data source once in batch, the network overhead is greatly reduced, and the inquiring efficiency of the data inquiry is effectively improved.
Referring to fig. 4, in an alternative implementation manner of the present invention, on the basis of fig. 3, a block diagram of a structure of another data query apparatus provided in an embodiment of the present invention is given.
Specifically, the data source determining module 32 includes the following sub-modules:
a to-be-queried item determining submodule 321, configured to query configuration information according to the to-be-queried task and the to-be-queried dimension, determine a query dimension matched in the configuration information, and a query item corresponding to the matched query dimension; taking the inquired inquiry item as an item to be inquired from a data source;
and the data source determining submodule 322 is configured to determine a data source corresponding to each item to be queried according to the corresponding relationship between the query item in the configuration information and the data source.
The to-be-queried item determination submodule 321 includes the following units:
the first matching unit 3211 is configured to query the configuration information according to the task to be queried and determine a query task matching the configuration information;
the second matching unit 3212 is configured to query the query tasks matched in the configuration information according to the dimension to be queried, and determine query terms corresponding to the matched query dimension.
Further, the second request generation module 33 includes the following sub-modules:
the grouping submodule 331 is configured to combine the items to be queried belonging to the same data source, and generate a group of items to be queried corresponding to the data source;
the assembling sub-module 332 is configured to add corresponding query codes to each group of items to be queried, respectively, and generate a second query request, where each query code is used to initiate the second query request to a corresponding data source.
The data inquiry apparatus further includes:
a configuration change module 35, configured to change the query dimension corresponding to the query task; and/or altering query terms corresponding to the query dimensions.
In summary, in the embodiment of the present invention, the configuration change module 35 determines the configuration information in advance, so that the adjustment of the query task can be embodied in the change of the configuration information, when the first request obtaining module 31 obtains the first query request, the data source determining module 32 can query the adjusted configuration information according to the task to be queried and the dimension to be queried to obtain the corresponding item to be queried, the second request generating module 33 combines the items to be queried belonging to the same data source according to the corresponding relationship between the query item and the data source in the configuration information to generate the second query request, and the query result obtaining module 34 obtains the batch query result from the corresponding data source by using the second query request. Because newly-added query can be realized only by changing configuration information without modifying codes one by one, the network overhead is greatly reduced, and the query efficiency is greatly improved.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or terminal equipment comprising the element.
The above detailed description is provided for a data query method and apparatus, and the principle and the implementation of the present invention are explained in this document by applying specific examples, and the above description of the embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (8)
1. A method for data query, the method comprising:
acquiring a first query request, wherein the first query request comprises a task to be queried and a dimension to be queried;
according to configuration information, determining a data source corresponding to each item to be queried under the dimension to be queried in the task to be queried, wherein the data source comprises: a relational database, a distributed database, and a cache database;
determining items to be queried belonging to the same data source, and generating a corresponding second query request, wherein the second query request is used for carrying out batch query on the items to be queried corresponding to the data source;
acquiring a batch query result from a corresponding data source by adopting the second query request;
the determining of the items to be queried belonging to the same data source and generating of the corresponding second query request includes:
merging the items to be queried belonging to the same data source to generate a group of items to be queried corresponding to the data source, wherein each query item uniquely corresponds to one data source;
respectively adding corresponding query codes for each group of items to be queried to generate the second query requests, wherein each query code is used for initiating the second query request to a corresponding data source;
the obtaining of the batch query result from the corresponding data source by using the second query request includes:
and after the second query request is generated, sending the second query request to a corresponding data source so as to query a record conforming to the value of each item to be queried in the second query request, and taking the record as a batch query result of the second query request.
2. The method according to claim 1, wherein the step of determining, according to the configuration information, a data source corresponding to each item to be queried in the dimension to be queried in the task to be queried comprises:
inquiring configuration information according to the task to be inquired and the dimension to be inquired, and determining a matched inquiry dimension in the configuration information and an inquiry item corresponding to the matched inquiry dimension;
taking the inquired inquiry item as an item to be inquired from a data source;
and determining the data source corresponding to each item to be queried according to the corresponding relation between the query item and the data source in the configuration information.
3. The method according to claim 2, wherein the step of determining a matching query dimension in the configuration information and a query item corresponding to the matching query dimension according to the task to be queried and the query configuration information of the dimension to be queried comprises:
inquiring configuration information according to the task to be inquired, and determining an inquiry task matched with the configuration information;
and inquiring the matched inquiry tasks in the configuration information according to the dimension to be inquired, determining the matched inquiry dimension in the configuration information and the inquiry item corresponding to the matched inquiry dimension.
4. The method of claim 1, further comprising the step of changing the configuration information:
changing the query dimension corresponding to the query task; and/or
And changing the query item corresponding to the query dimension.
5. A data query apparatus, characterized in that the apparatus comprises:
the system comprises a first request acquisition module, a first query module and a second query module, wherein the first request acquisition module is used for acquiring a first query request, and the first query request comprises a task to be queried and a dimension to be queried;
a data source determining module, configured to determine, according to configuration information, a data source corresponding to each item to be queried in the to-be-queried task under the to-be-queried dimension, where the data source includes: a relational database, a distributed database, and a cache database;
the second request generation module is used for determining all items to be queried which belong to the same data source and generating corresponding second query requests, wherein the second query requests are used for carrying out batch query on all items to be queried which correspond to the data source;
the query result acquisition module is used for acquiring batch query results from the corresponding data source by adopting the second query request;
the second request generation module includes:
the grouping submodule is used for merging the items to be queried which belong to the same data source to generate a group of items to be queried corresponding to the data source, and each query item uniquely corresponds to one data source;
the assembling sub-module is used for respectively adding corresponding query codes for each group of items to be queried and generating the second query request, wherein each query code is used for initiating the second query request to a corresponding data source;
the query result obtaining module is further configured to: and after the second query request is generated, sending the second query request to a corresponding data source so as to query a record conforming to the value of each item to be queried in the second query request, and taking the record as a batch query result of the second query request.
6. The apparatus of claim 5, wherein the data source determination module comprises:
the query item determining submodule is used for determining a matched query dimension in the configuration information and a query item corresponding to the matched query dimension according to the task to be queried and the query configuration information of the dimension to be queried; taking the inquired inquiry item as an item to be inquired from a data source;
and the data source determining submodule is used for determining the data source corresponding to each item to be queried according to the corresponding relation between the query item and the data source in the configuration information.
7. The apparatus of claim 6, wherein the item to be queried determination submodule comprises:
the first matching unit is used for inquiring the configuration information according to the task to be inquired and determining the matched inquiry task in the configuration information;
and the second matching unit is used for querying the matched query tasks in the configuration information according to the dimension to be queried, determining the matched query dimension in the configuration information and the query item corresponding to the matched query dimension.
8. The apparatus of claim 5, further comprising:
the configuration changing module is used for changing the query dimension corresponding to the query task; and/or altering query terms corresponding to the query dimensions.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710476723.2A CN107220376B (en) | 2017-06-21 | 2017-06-21 | Data query method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710476723.2A CN107220376B (en) | 2017-06-21 | 2017-06-21 | Data query method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107220376A CN107220376A (en) | 2017-09-29 |
CN107220376B true CN107220376B (en) | 2020-10-27 |
Family
ID=59949901
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710476723.2A Active CN107220376B (en) | 2017-06-21 | 2017-06-21 | Data query method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107220376B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110309181A (en) * | 2019-06-18 | 2019-10-08 | 平安普惠企业管理有限公司 | A kind of data query method and relevant apparatus |
CN110297955B (en) * | 2019-06-20 | 2023-03-24 | 创新先进技术有限公司 | Information query method, device, equipment and medium |
CN110942046B (en) * | 2019-12-05 | 2023-04-07 | 腾讯云计算(北京)有限责任公司 | Image retrieval method, device, equipment and storage medium |
CN113064928A (en) * | 2021-04-25 | 2021-07-02 | 深圳壹账通智能科技有限公司 | Report data query method and device, electronic equipment and storage medium |
CN113177062B (en) * | 2021-05-25 | 2023-06-09 | 深圳前海微众银行股份有限公司 | Data query method and device |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102222108A (en) * | 2011-06-28 | 2011-10-19 | 用友软件股份有限公司 | Scripting method and device |
CN103500188A (en) * | 2013-09-13 | 2014-01-08 | 北京奇虎科技有限公司 | Method and system for generating data sheet |
CN103631951A (en) * | 2013-12-12 | 2014-03-12 | 用友软件股份有限公司 | Batch access function merging method and device based on metadata |
CN104933115A (en) * | 2015-06-05 | 2015-09-23 | 北京京东尚科信息技术有限公司 | Multi-dimensional analysis method and system |
CN105677683A (en) * | 2014-11-21 | 2016-06-15 | 华为技术有限公司 | Batch data query method and device |
CN105740344A (en) * | 2016-01-25 | 2016-07-06 | 中国科学院计算技术研究所 | Sql statement combination method and system independent of database |
CN106570022A (en) * | 2015-10-10 | 2017-04-19 | 阿里巴巴集团控股有限公司 | Cross-data-source query method, apparatus and system |
-
2017
- 2017-06-21 CN CN201710476723.2A patent/CN107220376B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102222108A (en) * | 2011-06-28 | 2011-10-19 | 用友软件股份有限公司 | Scripting method and device |
CN103500188A (en) * | 2013-09-13 | 2014-01-08 | 北京奇虎科技有限公司 | Method and system for generating data sheet |
CN103631951A (en) * | 2013-12-12 | 2014-03-12 | 用友软件股份有限公司 | Batch access function merging method and device based on metadata |
CN105677683A (en) * | 2014-11-21 | 2016-06-15 | 华为技术有限公司 | Batch data query method and device |
CN104933115A (en) * | 2015-06-05 | 2015-09-23 | 北京京东尚科信息技术有限公司 | Multi-dimensional analysis method and system |
CN106570022A (en) * | 2015-10-10 | 2017-04-19 | 阿里巴巴集团控股有限公司 | Cross-data-source query method, apparatus and system |
CN105740344A (en) * | 2016-01-25 | 2016-07-06 | 中国科学院计算技术研究所 | Sql statement combination method and system independent of database |
Also Published As
Publication number | Publication date |
---|---|
CN107220376A (en) | 2017-09-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107220376B (en) | Data query method and device | |
CN109614823B (en) | Data processing method, device and equipment | |
CN112671769B (en) | Electronic contract signing method, device and equipment | |
CN111382174B (en) | Multi-party data joint query method, device, server and storage medium | |
CN107515878B (en) | Data index management method and device | |
CN107391142B (en) | Application splitting method and device | |
CN109144997A (en) | Data correlation method, device and storage medium | |
CN111046237B (en) | User behavior data processing method and device, electronic equipment and readable medium | |
CN103927338A (en) | Log information storage processing method and log information storage processing device | |
CN110276060B (en) | Data processing method and device | |
CN103106585A (en) | Real-time duplication eliminating method and device of product information | |
CN104965918B (en) | A kind of searching method and device based on searching keyword | |
CN107404431B (en) | A kind of the message transmission selection method and system of account universal retrievals more by all kinds of means | |
CN105227352A (en) | A kind of update method of user ID collection and device | |
CN109213758B (en) | Data access method, device, equipment and computer readable storage medium | |
CN104809130A (en) | Method, equipment and system for data query | |
CN111612388A (en) | Method and device for merging target orders | |
CN107133233B (en) | Processing method and device for configuration data query | |
CN111767144A (en) | Transaction routing determination method, device, equipment and system for transaction data | |
CN111680108A (en) | Data storage method and device and data acquisition method and device | |
CN111752944A (en) | Data allocation method and device, computer equipment and storage medium | |
CN102508884A (en) | Method and device for acquiring hotpot events and real-time comments | |
US11475064B2 (en) | System and method in a database system for creating a field service work order | |
CN105786941B (en) | Information mining method and device | |
CN111445319A (en) | Voucher generation method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |