CN105574010B - Data query method and device - Google Patents

Data query method and device Download PDF

Info

Publication number
CN105574010B
CN105574010B CN201410536424.XA CN201410536424A CN105574010B CN 105574010 B CN105574010 B CN 105574010B CN 201410536424 A CN201410536424 A CN 201410536424A CN 105574010 B CN105574010 B CN 105574010B
Authority
CN
China
Prior art keywords
data
query
application server
condition information
distributed database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410536424.XA
Other languages
Chinese (zh)
Other versions
CN105574010A (en
Inventor
吴月刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201410536424.XA priority Critical patent/CN105574010B/en
Publication of CN105574010A publication Critical patent/CN105574010A/en
Application granted granted Critical
Publication of CN105574010B publication Critical patent/CN105574010B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention relates to a data query method and a data query device, wherein the method comprises the following steps: a data bus receives a data query request sent by an application server, wherein the query request carries data query condition information; the data bus inquires corresponding first data in a memory cache according to the inquiry condition information; if the first data is inquired by the data bus, the first data is sent to the application server; and if the first data is not inquired by the data bus, sending the data inquiry request to an actuator, and using the actuator to inquire the first data in a database according to the data inquiry condition information. According to the data query method and device provided by the invention, the data bus is additionally arranged in the distributed database system, so that the distributed cache is increased, the consumption of the number of the data source links is reduced, and the query performance of the application server is improved.

Description

Data query method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data query method and apparatus.
Background
With the rapid development of computer and network technologies, the scale of network access data is increasing. How to process mass data generated in the information explosion era becomes a problem to be solved urgently. In a traditional centralized database system, an application program is concentrated on one computer to run, and once the computer fails, the whole system is affected. In addition, centralized processing causes the scale and configuration of the system to be inflexible, and the expandability of the system is poor. Therefore, the traditional centralized database system cannot meet the application requirements of large-scale data.
Distributed database systems have been developed based on centralized database systems and are the product of a combination of computer technology and network technology. The distributed database is a unified whole logically, and is stored on different physical nodes respectively physically. An application may access a database distributed in different locations through a network connection. The distributivity of the distributed database system is represented by that the data in the database is stored on the storage devices of different computers, and a user can execute a global application on any one computer through a network connection. The distributed database system has high reliability, when one computer in the system breaks down, the system can operate the same copy on the other computer, and the whole system cannot be broken down due to one failure. Moreover, the distributed database system can select the data copy closest to the user for operation according to the distance, so that the communication cost is reduced, and the performance of the whole system is improved.
However, in the use process of the distributed database system, data in the database is stored in storage devices of different computers, so that an application server needs to be connected with a plurality of databases, and the problem of insufficient links between the application server and the databases exists, which leads to low efficiency or abnormal conditions of users during query operation. In the prior art, the problem of insufficient link number of a data source still cannot be solved by splitting a database or introducing a memory cache.
Disclosure of Invention
The invention aims to provide a data query method and a data query device, which are used for solving the problem of insufficient data source link number in a large-scale distributed database system.
In a first aspect, a data query method is provided, where the method includes:
a data bus receives a data query request sent by an application server, wherein the query request carries data query condition information;
the data bus inquires corresponding first data in a memory cache according to the inquiry condition information;
if the first data is inquired by the data bus, the first data is sent to the application server;
and if the first data is not inquired by the data bus, sending the data inquiry request to an actuator, and using the actuator to inquire the first data in a database according to the data inquiry condition information.
In a second aspect, there is provided a data query apparatus, including:
the receiving unit is used for receiving a data query request sent by an application server through a data bus, wherein the query request carries data query condition information;
the first query unit is used for the data bus to query the corresponding first data in the memory cache according to the query condition information;
and the judging unit is used for judging whether the first data is inquired in the memory cache by the data bus.
The first sending unit is used for sending the first data to the application server when the first data is inquired by the data bus;
the second sending unit is used for sending the data query request to an actuator when the first data is not queried by the data bus;
and the second query unit is used for querying the first data in a database by the executor according to the data query condition information.
According to the data query method and device, the data bus is additionally arranged in the distributed database system, so that distributed cache is added, the data bus is forwarded, the consumption of the number of the data source links is reduced, and the query performance of the application server is improved.
Drawings
Fig. 1 is a flowchart of a data query method according to an embodiment of the present application;
FIG. 2 is a diagram of a prior art single database schema distributed database system;
FIG. 3 is a diagram of a prior art multi-database schema distributed database system;
FIG. 4 is a diagram illustrating a distributed database system after memory caching is introduced in the prior art;
fig. 5 is a schematic diagram of a distributed database system according to an embodiment of the present application;
fig. 6 is a schematic diagram of a data query apparatus according to a second embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. 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 application.
According to the data query method and device provided by the embodiment of the application, the application server firstly sends a data query request to the data bus, the data bus queries in the memory cache according to the query condition information, if the data bus does not query the query result meeting the query condition, the data query request is sent to the actuator, and the actuator queries in the database according to the data query condition information. The invention adds the data bus in the distributed database system, reduces the number of links between the application server and the database through the forwarding of the data bus, and improves the query efficiency.
Example one
Fig. 1 is a flowchart of a data query method according to an embodiment of the present application. The method specifically comprises the following steps:
step 101, a data bus receives a data query request sent by an application server, wherein the query request carries data query condition information.
The network environment in which the method of the present invention operates may be, but is not limited to, a distributed database system in a cloud computing environment.
In the prior art distributed database system, the application server is directly connected with the database, and a schematic diagram of the distributed database system in a single database mode is shown in fig. 2. The number of links linking a single database and N application servers is M × N.
In order to reduce the number of links, the database is split, and the database is split to form a multi-database schema database system, as shown in fig. 3. After a single database is split into i databases, the total number of links of the N application servers and the i databases is mxnxi, and the problem of insufficient number of links of the data source is not solved.
Even if the memory cache is introduced, since the memory cache cannot send feedback information to the application server, the application server still needs to be linked with the database, and the total number of links between N application servers and i databases is still mxnxi, which cannot solve the problem of insufficient number of links of the data source, as shown in fig. 4.
In order to solve the problem of insufficient link number of a data source, a data bus is introduced into a distributed database system, wherein the data bus comprises a memory cache and an SQL (Structured Query Language) executor. Due to the introduction of Q data buses, the total number of the links of the N application servers and the i databases is Q multiplied by i (Q < M multiplied by N), and the consumption of the number of the database links is reduced. As shown in fig. 5.
The application server is an upper-layer service system and is used for processing services related to the requirements of the users. For example, the user accesses a shopping site, searches for commodity information satisfying a certain condition, and the like.
The data query condition information is a condition of any combination of upper-layer services, for example, a user wants to purchase a lady black woolen overcoat with a price of 1000-2000 yuan, a search keyword can be ' lady ' + ' black ' + ' woolen overcoat ' + ' 1000-2000 yuan, if the search range is to be enlarged, the keywords can be selected to be combined randomly, and then commodity information meeting the combination condition is searched and fed back to the user.
In this embodiment, the application server sends the data query request carrying the query condition information to the data bus through SQL. The data bus collects SQL query requests of an upper-layer business system, and the use of database links can be effectively reduced through the forwarding of the data bus.
And 102, the data bus queries corresponding first data in a memory cache according to the query condition information.
Specifically, the data bus accesses an inquiry interface of the memory cache according to the main key, and inquires data meeting an inquiry condition in the memory cache, where the first data is the data meeting the inquiry condition.
Step 103, determining whether the first data exists in the memory cache.
Specifically, if the data bus queries the data meeting the condition in the memory cache, the step 106 is continuously executed to feed the data meeting the query condition back to the application server for the upper layer service system to use. Otherwise, step 104 is performed.
And 104, sending the data query request to an executor when the first data is not queried by the data bus.
And if the data bus does not inquire the information meeting the inquiry condition in the memory cache, sending the data inquiry request to an actuator, triggering the actuator, and continuing to execute the step 105.
The executor is an SQL executor and queries the database by using SOL.
And 105, the executor queries the first data in a database according to the data query condition information.
Specifically, the executor queries in a database by using SQL according to the data query condition information.
The database is a mysql database, and is accessed by using SQL. The SQL executor obtains a query table name from the query request SQL, selects a database according to the query table name, and queries data meeting conditions.
And 106, sending the first data to the application server.
And if the data bus inquires the data meeting the conditions in the memory cache, the data bus sends the first data to an application server to meet the use requirement of an upper-layer service system.
And if the executor queries the data meeting the conditions in the database, the executor sends the first data to the application server, and simultaneously stores the data meeting the query conditions in a memory cache to update the cache, so that the next user can conveniently search the requirement.
According to the data query method provided by the embodiment of the application, the application server firstly sends a data query request to the data bus, the data bus queries in the memory cache according to the query condition information, if the data bus does not query the query result meeting the query condition, the data query request is sent to the actuator, and the actuator queries in the database according to the data query condition information. The invention adds the data bus in the distributed database system, thereby increasing the distributed cache, reducing the consumption of the data source link number through the forwarding of the data bus, and improving the query performance of the application server.
Example two
Corresponding to the data query method, a data query apparatus provided in the embodiment of the present application is further provided, and fig. 3 is a schematic diagram of an apparatus provided in the second embodiment of the present application, where the apparatus includes: a receiving unit 201, a first query unit 202, a judging unit 203, a first sending unit 204, a second sending unit 205, a second query unit 206 and a storage unit 207.
The receiving unit 201 is configured to receive, by using a data bus, a data query request sent by an application server, where the query request carries information of a data query condition.
The first query unit 202 is configured to query, by the data bus, the corresponding first data in the memory cache according to the query condition information.
The determining unit 203 is configured to determine whether the first data is queried in the memory cache by the data bus.
The first sending unit 204 is configured to send the first data to the application server when the first data is queried by the data bus.
The second sending unit 205 is configured to send the data query request to an executor when the data bus does not query the first data.
The second query unit 206 is configured to query the first data in a database according to the data query condition information.
The apparatus further includes a storage unit 207, configured to send the queried first data to the application server, and store the first data in the memory cache.
The device provided by the second embodiment of the present application is implanted with the method provided by the first embodiment of the present application, and therefore, detailed descriptions of the specific working process of the device provided by the present application are omitted here.
According to the data query device provided by the embodiment of the application, the application server firstly sends a data query request to the data bus, the data bus queries in the memory cache according to the query condition information, if the data bus does not query the query result meeting the query condition, the data query request is sent to the actuator, and the actuator queries in the database according to the data query condition information. The invention adds the data bus in the distributed database system, thereby increasing the distributed cache, reducing the consumption of the data source link number through the forwarding of the data bus, and improving the query performance of the application server.
Those of skill would further appreciate that the various illustrative objects and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied in hardware, a software module executed by a processor, or a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The above-mentioned embodiments, objects, technical solutions and advantages of the present application are described in further detail, it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present application, and are not intended to limit the scope of the present application, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present application should be included in the scope of the present application.

Claims (12)

1. A method for data query, the method comprising:
q data buses summarize data query requests sent by N application servers, wherein the query requests carry data query condition information, each application server needs M links, each data bus respectively comprises a memory cache and an actuator, and Q is a preset integer larger than 1;
q data buses inquire corresponding first data in the memory cache according to the inquiry condition information;
if the Q data buses inquire the first data, the first data are sent to the application server;
and if the Q data buses do not inquire the first data, sending the data inquiry request to the executor, wherein the executor inquires the first data in a distributed database according to the data inquiry condition information, and the number of links of each database in the distributed database is Q, and Q is less than M multiplied by N.
2. The method according to claim 1, wherein the executor queries the first data in the distributed database according to the data query condition information, and specifically, the executor queries the first data in the distributed database by using a structured query language according to the data query condition information.
3. The method of claim 1, after the executor queries the first data in a distributed database according to the data query condition information, further comprising: and sending the inquired first data to the application server, and storing the first data in the memory cache.
4. The method of claim 1, wherein the Q data buses belong to a data bus cluster for adding distributed cache.
5. The method of claim 1, wherein the distributed database is hosted by a database cluster for storing upper-level business data information.
6. The method of claim 1, wherein the application server belongs to an application server cluster for processing upper layer services.
7. A data query apparatus, characterized in that the apparatus comprises:
the device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is used for collecting data query requests sent by N application servers through Q data buses, the query requests carry data query condition information, each application server needs M links, each data bus respectively comprises a memory cache and an actuator, and Q is a preset integer which is larger than 1;
the first query unit is used for querying the corresponding first data in the memory cache by the Q data buses according to the query condition information;
the judging unit is used for judging whether the first data are inquired in the memory cache by the Q data buses;
the first sending unit is used for sending the first data to the application server when the Q data buses inquire the first data;
the second sending unit is used for sending the data query request to the executor when the first data is not queried by the data bus;
and the second query unit is used for querying the first data in a distributed database by the executor according to the data query condition information, wherein the number of links of each database in the distributed database is Q, and Q is less than M multiplied by N.
8. The apparatus according to claim 7, wherein the executor queries the first data in the distributed database according to the data query condition information, in particular, the executor queries the first data in the distributed database by using a structured query language according to the data query condition information.
9. The apparatus of claim 7, further comprising: and the storage unit is used for sending the inquired first data to the application server and storing the first data in the memory cache.
10. The apparatus of claim 7, wherein the data bus belongs to a data bus cluster for adding distributed cache.
11. The apparatus of claim 7, wherein the distributed database is attributed to a database cluster for storing upper layer business data information.
12. The apparatus of claim 7, wherein the application server belongs to an application server cluster for processing upper layer services.
CN201410536424.XA 2014-10-13 2014-10-13 Data query method and device Active CN105574010B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410536424.XA CN105574010B (en) 2014-10-13 2014-10-13 Data query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410536424.XA CN105574010B (en) 2014-10-13 2014-10-13 Data query method and device

Publications (2)

Publication Number Publication Date
CN105574010A CN105574010A (en) 2016-05-11
CN105574010B true CN105574010B (en) 2020-06-02

Family

ID=55884157

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410536424.XA Active CN105574010B (en) 2014-10-13 2014-10-13 Data query method and device

Country Status (1)

Country Link
CN (1) CN105574010B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107239570A (en) * 2017-06-27 2017-10-10 联想(北京)有限公司 Data processing method and server cluster
CN107832401B (en) * 2017-11-01 2021-07-16 郑州云海信息技术有限公司 Database data access method, system, device and computer readable storage medium
CN108777718B (en) * 2018-06-22 2021-03-23 创新先进技术有限公司 Method and device for accessing read-write-more-less system through client side by service system
CN109933585B (en) * 2019-02-22 2021-11-02 京东数字科技控股有限公司 Data query method and data query system

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081624A (en) * 2009-11-30 2011-06-01 中国移动通信集团北京有限公司 Data inquiring method and data inquiring server

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120239681A1 (en) * 2011-03-14 2012-09-20 Splunk Inc. Scalable interactive display of distributed data
CN103365929B (en) * 2012-04-10 2016-09-28 阿里巴巴集团控股有限公司 The management method of a kind of data base connection and system
CN103064960B (en) * 2012-12-31 2016-09-07 华为技术有限公司 Data base query method and equipment
CN103441861B (en) * 2013-07-16 2017-03-08 杭州华为数字技术有限公司 A kind of data record generation method and device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081624A (en) * 2009-11-30 2011-06-01 中国移动通信集团北京有限公司 Data inquiring method and data inquiring server

Also Published As

Publication number Publication date
CN105574010A (en) 2016-05-11

Similar Documents

Publication Publication Date Title
US11120022B2 (en) Processing a database query using a shared metadata store
US11301446B1 (en) System and method for interacting with a plurality of data sources
US8032551B2 (en) Searching documents for successive hashed keywords
US11762775B2 (en) Systems and methods for implementing overlapping data caching for object application program interfaces
EP3977307B1 (en) Caching techniques for a database change stream
CN105574010B (en) Data query method and device
US10496645B1 (en) System and method for analysis of a database proxy
EP3188051B1 (en) Systems and methods for search template generation
US8032550B2 (en) Federated document search by keywords
CN103823846A (en) Method for storing and querying big data on basis of graph theories
US20140095644A1 (en) Processing of write requests in application server clusters
CN110737747A (en) data operation method, device and system
WO2016101759A1 (en) Data routing method, data management device and distributed storage system
US9229969B2 (en) Management of searches in a database system
CN110110184B (en) Information inquiry method, system, computer system and storage medium
US20170270149A1 (en) Database systems with re-ordered replicas and methods of accessing and backing up databases
JP5464017B2 (en) Distributed memory database system, database server, data processing method and program thereof
CN113094391B (en) Calculation method, device and equipment for data summarization supporting cache
CN113515504B (en) Data management method, device, electronic equipment and storage medium
US20220191104A1 (en) Access management for a multi-endpoint data store
CN114020744A (en) Data transmission method, device, electronic equipment and computer readable medium
CN112784148A (en) Information popularization method and device
JP2017027471A (en) Distribution database system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20201010

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201010

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right