CN110457350A - For carrying out the method and device of aggregate query in inquiry database - Google Patents

For carrying out the method and device of aggregate query in inquiry database Download PDF

Info

Publication number
CN110457350A
CN110457350A CN201910671470.3A CN201910671470A CN110457350A CN 110457350 A CN110457350 A CN 110457350A CN 201910671470 A CN201910671470 A CN 201910671470A CN 110457350 A CN110457350 A CN 110457350A
Authority
CN
China
Prior art keywords
data
polymerization
static
inquiry
dynamic
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.)
Pending
Application number
CN201910671470.3A
Other languages
Chinese (zh)
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.)
Beijing Oceanbase Technology 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 CN201910671470.3A priority Critical patent/CN110457350A/en
Publication of CN110457350A publication Critical patent/CN110457350A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24554Unary operations; Data partitioning operations
    • G06F16/24556Aggregation; Duplicate elimination

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Present disclose provides the method and devices for carrying out aggregate query in inquiry database.This method comprises: generating dynamic queries data corresponding with aggregate query type based on dynamic data tables after receiving for the aggregate query request of inquiry database;Static polymerization calculated result is obtained, static polymerization calculated result is to carry out polymerization calculating to static list of data according to polymerization calculation method corresponding with aggregate query type and obtain;Polymerization calculating is carried out to dynamic queries data and static polymerization calculated result according to polymerization calculation method, to obtain data query result;Output data query result.It is consistent using the actual conditions of this method, the result and database that enable to aggregate query, and then improves the accuracy rate of aggregate query.

Description

For carrying out the method and device of aggregate query in inquiry database
Technical field
This disclosure relates to technical field of data storage, and in particular, to for carrying out aggregate query in inquiry database Method and device.
Background technique
In the databases such as Oracle, MySQL, it is typically stored with a large amount of data.In existing database aggregate query In, when carrying out aggregate query (Aggregation Query) to database, can advance to all initial data in database Row scanning, and polymerization calculating is carried out to obtained data are scanned, thus obtain query result.In this inquiry mode, when , can be longer for the sweep time of database when data volume is larger, so that needing to spend longer query time, thus lead Search efficiency is caused to reduce.
In order to improve aggregate query efficiency, another aggregate query scheme is polymerize using query engine Kylin Inquiry.In the aggregate query scheme, polymerization calculating is carried out in advance to the data in database using query engine Kylin, with Corresponding precomputation is obtained as a result, and storing the precomputation result.As a result, when carrying out aggregate query for the database, Replace initial data row based on database to be scanned, is inquired based on from the precomputation result stored.By institute The data volume of the precomputation result of storage is far smaller than the data volume of database, to improve aggregate query efficiency.However, sharp With the obtained precomputation of Kylin the result is that carrying out polymerization calculating in advance to the total data in database obtained from, and Precomputation is the background data base based on system to carry out, and there is certain delay since the data of background data base are synchronous, from And cause the update of background data base cannot be synchronous with the modification of the real-time incremental of database, thus lead to data in the database There are when increment modification, the database that precomputation is based on cannot be updated in time, so that the precomputation knot stored Data in fruit and database mismatch, so cause aggregate query query result and database actual storage situation it is different It causes.
Summary of the invention
In view of above-mentioned, present disclose provides a kind of for carrying out the method and device of aggregate query in inquiry database. Using this method and device, real time aggregation inquiry can be carried out to inquiry data.
According to one aspect of the disclosure, a kind of method for carrying out aggregate query in inquiry database is provided, The inquiry database includes dynamic data tables and static list of data, and the dynamic data tables are for storing for inquiry database Carry out incremental data when increment modification operation, the static list of data for storing static data, the static data into The row increment modification remains unchanged when operating, which comprises looks into receiving the polymerization for the inquiry database After asking request, dynamic queries data corresponding with aggregate query type are generated based on the dynamic data tables;It obtains static poly- It is total to calculate result, wherein the static polymerization calculated result is according to polymerization calculating side corresponding with the aggregate query type Method come to the static list of data carry out polymerization calculating and obtain;According to the polymerization calculation method come to the dynamic queries Data and the static polymerization calculated result carry out polymerization calculating, to obtain data query result;And the output data are looked into Ask result.
Optionally, in an example of above-mentioned aspect, obtaining static polymerization calculated result may include: to calculate from polymerization The static polymerization calculated result corresponding with the polymerization calculation method is obtained in result database, wherein described static poly- Calculated result is closed correspondingly to be stored in the polymerization calculation result data library with the polymerization calculation method.
Optionally, in an example of above-mentioned aspect, obtaining static polymerization calculated result may include: according to described poly- Calculation method is closed to carry out polymerization calculating to the static list of data, to obtain the static polymerization calculated result.
Optionally, in an example of above-mentioned aspect, the method can also include: to meet predetermined merging condition When, processing is merged to the dynamic data tables and the static list of data, to obtain updated static list of data;And Empty the dynamic data tables.
Optionally, in an example of above-mentioned aspect, the predetermined merging condition includes: in the dynamic data tables Data volume reaches preset data amount threshold value;Alternatively, receiving static list of data more new command.
Optionally, in an example of above-mentioned aspect, the increment modification operation includes in the modification operation of following increments At least one of: data insertion operation;Data delete operation;With data update operation.
Optionally, in an example of above-mentioned aspect, the aggregate query type includes in following aggregate query types At least one of: maximum value inquiry;Minimum value inquiry;Counting inquiry;Sum number inquiry;Average value inquiry;With non-duplicate object meter Number inquiry.
Optionally, in an example of above-mentioned aspect, the dynamic queries data and the static polymerization calculated result It is index data.
Optionally, in an example of above-mentioned aspect, the inquiry database is stored using LSM Tree structure Database.
According to another aspect of the present disclosure, a kind of device for the progress aggregate query in inquiry database is also provided, The inquiry database includes dynamic data tables and static list of data, and the dynamic data tables are for storing for inquiry database Carry out incremental data when increment modification operation, the static list of data for storing static data, the static data into The row increment modification remains unchanged when operating, and described device includes: that dynamic queries data generating unit is configured as receiving To after the aggregate query request for the inquiry database, generated based on the dynamic data tables and aggregate query type pair The dynamic queries data answered;Polymerization calculated result acquiring unit is configured as obtaining static polymerization calculated result, wherein described quiet State polymerization calculated result be according to polymerization calculation method corresponding with the aggregate query type come to the static list of data into Row polymerization calculate and obtain;Query result obtaining unit is configured as looking into the dynamic according to the polymerization calculation method It askes data and the static polymerization calculated result carries out polymerization calculating, to obtain data query result;And query result output Unit is configured as exporting the data query result.
Optionally, in an example of above-mentioned aspect, the polymerization calculated result acquiring unit is configured as: from polymerization The static polymerization calculated result corresponding with the polymerization calculation method is obtained in calculation result data library, wherein described quiet State polymerization calculated result is correspondingly stored in the polymerization calculation result data library with the polymerization calculation method.
Optionally, in an example of above-mentioned aspect, the polymerization calculated result acquiring unit is configured as: according to The aggregate query type corresponding polymerization calculation method carries out polymerization calculating to the static list of data, described quiet to obtain State polymerize calculated result.
Optionally, in an example of above-mentioned aspect, described device can also include: static list of data updating unit quilt It is configured to when meeting predetermined merging condition, processing is merged to the dynamic data tables and the static list of data, with To updated static list of data;And it empties unit and is configured as emptying the dynamic data tables.
Optionally, in an example of above-mentioned aspect, the predetermined merging condition includes: in the dynamic data tables Data volume reaches preset data amount threshold value;Alternatively, receiving static list of data more new command.
According to another aspect of the present disclosure, a kind of calculating equipment is also provided, comprising: at least one processor;And storage Device, the memory store instruction, when described instruction is executed by least one described processor, so that described at least one It manages device and executes method as described above.
According to another aspect of the present disclosure, a kind of machine readable storage medium is also provided, executable instruction is stored with, institute State instruction makes the machine execute method as described above upon being performed.
The method and device for the progress aggregate query in inquiry database provided by the disclosure, will inquire data Library is divided into static list of data and dynamic data tables, and dynamic data tables carry out increment modification operation for inquiry database for storing When incremental data, static list of data is for storing static data.Based on this storage mode, aggregate query request is being received Afterwards, dynamic queries data can be generated based on dynamic data tables, and obtains static polymerization calculated result.When carrying out aggregate query It is that polymerization calculating is carried out to dynamic queries data and static polymerization calculated result, obtains aggregate query result.Due to being gathered The inquiry that the incremental data for inquiry database is considered when inquiry is closed, so that the reality of aggregate query result and database Border situation is consistent.
Detailed description of the invention
By referring to following attached drawing, may be implemented to further understand the nature and advantages of present disclosure.In In attached drawing, similar assembly or feature can have identical appended drawing reference.Attached drawing be for provide to the embodiment of the present invention into One step understands, and constitutes part of specification, is used to explain the implementation of the disclosure together with following specific embodiment Example, but do not constitute the limitation to embodiment of the disclosure.In the accompanying drawings:
Fig. 1 shows the schematic diagram that aggregate query is carried out using query engine Kylin;
Fig. 2 shows the schematic diagrames according to the inquiry database of the embodiment of the present disclosure;
Fig. 3 shows the process of the method for carrying out aggregate query in inquiry database according to the embodiment of the present disclosure Figure;
Fig. 4 shows an exemplary schematic diagram of the counting inquiry according to the embodiment of the present disclosure;
Fig. 5 shows the exemplary schematic diagram inquired according to the sum number of the embodiment of the present disclosure;
Fig. 6 shows the exemplary schematic diagram inquired according to the maximum value of the embodiment of the present disclosure;
Fig. 7 shows the exemplary schematic diagram inquired according to the minimum value of the embodiment of the present disclosure;
Fig. 8 shows the exemplary schematic diagram inquired according to the non-duplicate object count of the embodiment of the present disclosure;
Fig. 9 shows the method for carrying out aggregate query in inquiry database according to another embodiment of the present disclosure Flow chart;
Figure 10 shows the side of the device for carrying out aggregate query in inquiry database according to the embodiment of the present disclosure Block diagram;
Figure 11 shows the dress for the progress aggregate query in inquiry database according to another embodiment of the present disclosure The block diagram set;
Figure 12 is shown according to the embodiment of the present disclosure for carrying out the calculating equipment of aggregate query in inquiry database Block diagram.
Specific embodiment
Theme described herein is discussed below with reference to example embodiment.It should be understood that discussing these embodiments only It is in order to enable those skilled in the art can better understand that being not to claim to realize theme described herein Protection scope, applicability or the exemplary limitation illustrated in book.It can be in the protection scope for not departing from present disclosure In the case of, the function and arrangement of the element discussed are changed.Each example can according to need, omit, substitute or Add various processes or component.In addition, feature described in relatively some examples can also be combined in other examples.
As used in this article, term " includes " and its modification indicate open term, are meant that " including but not limited to ". Term "based" indicates " being based at least partially on ".Term " one embodiment " and " embodiment " expression " at least one implementation Example ".Term " another embodiment " expression " at least one other embodiment ".Term " first ", " second " etc. may refer to not Same or identical object.Here may include other definition, either specific or implicit.Unless bright in context It really indicates, otherwise the definition of a term is consistent throughout the specification.
As used herein, term " aggregate query " refers to based on one or more dimension, to one or more A statistical value carries out the inquiry of the calculating such as MAX, MIN, COUNT, SUM, AVG, COUNT DISTINCT.
As used herein, term " LSM Tree " structure is a kind of data structure of multistage, wherein every grade of data Be ordered, but it is not at the same level between data be to intersect, newest primary structure is only written in when write-in, and needs when inquiring Merger is carried out to all grades of data.
As used herein, term " HashMap " refers to a hash table, for storing key-value pair mapping.
Fig. 1 shows the schematic diagram that aggregate query is carried out using query engine Kylin.As shown in Figure 1, being used for aggregate query Database 110 include 5 initial data: (000001, YiShan, Zhang, Male, 1980, BeiJing, 10000), (000002, ZhaoJun, Wang, Female, 1988, ShangHai, 6000), (000003, YuBo, Li, Male, 1988, ShangHai, 8000), (000004, FeiYan, Zhao, Female, 1982, ShenZhen, 5000), (000005, YingYing, Zhang, Female, 1980, BeiJing, 20000).Here, database 110 for example can be in this field Any inquiry data, for example, oracle database, MySQL database etc..
Before carrying out aggregate query, polymerization calculating is carried out to above-mentioned database in advance using Kylin, for example, being directed to each city Number counts in city, obtains polymerization calculated result, and the polymerization calculated result is stored in polymerization calculation result data library. The polymerization calculated result is to be directed to the precomputation of aggregate query as a result, for example, for population number meter in each city shown in Fig. 1 Several precomputation results 120, the precomputation result 120 include: (BeiJing, 2), (ShangHai, 2), (ShenZhen, 1). After carrying out above-mentioned pre-calculation process, in the aggregate query for needing to carry out database 110 to count for number in each city, The precomputation counted for number in each city can be obtained from polymerization calculation result data library as a result, and by the precomputation knot Fruit exports as query result.
However, increment modification operation is carried out in case of to database 110 in aggregate query scheme shown in FIG. 1, For example, insertion data (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000), the then number in database 110 According to increasing to 6, correspondingly, the number counting of BeiJing becomes 3.But since it is expected that calculation processing is based on system background institute The data of storage carry out, and the synchronization of the data of background data base is not usually real-time, need to wait for a period of time, thus So that pre-calculation process result is not to carry out result obtained from real time aggregation calculating to the database after insertion data.At this time such as Fruit carries out the aggregate query for each urban human counting number again, then in obtained query result, for the meter of BeiJing Number is still that the actual conditions in 2, with current database are inconsistent, so as to cause query result inaccuracy.
To solve the above-mentioned problems, present disclose provides a kind of inquiry databases, which includes dynamic data Table and static list of data.Dynamic data tables are used to store incremental data when carrying out increment modification operation for inquiry database, For storing static data, which remains unchanged static list of data when carrying out increment modification operation.When for inquiry When database carries out increment modification operation, the incremental data in dynamic data tables can correspondingly change, quiet in static list of data State data remain unchanged.
Using the inquiry database, when carrying out aggregate query, can be generated based on dynamic data tables and aggregate query Corresponding dynamic queries data of type, and obtain static polymerization calculated result, the static polymerization calculated result be according to it is poly- The corresponding polymerization calculation method of query type is closed carrying out polymerizeing calculating to static list of data and is obtained.Then, to dynamically looking into It askes data and static polymerization calculated result carries out polymerization calculating, to obtain data query result;And output data query result.
In the aggregate query scheme according to provided by the disclosure, inquiry is directed to due to considering when carrying out aggregate query The inquiry of the incremental data of database, so that aggregate query result and the actual conditions of database are consistent.
It is described in detail below in conjunction with attached drawing according to the embodiment of the present disclosure for being polymerize in inquiry database The method and device of inquiry.
Fig. 2 shows exemplary schematic diagrames according to the inquiry database 200 of the embodiment of the present disclosure.As shown in Fig. 2, Inquiring database 200 includes dynamic data tables 210 and static list of data 220.Dynamic data tables 210 are for storing for inquiry number Incremental data when increment modification operation is carried out according to library, static list of data 220 for storing static data, the static data into It is remained unchanged when the modification operation of row increment.When carrying out increment modification operation for inquiry database 200, dynamic data tables 210 In incremental data can correspondingly change, the static data in static list of data 220 remains unchanged.
For example, the static list of data 220 in Fig. 2 includes 5 static datas: (000001, YiShan, Zhang, Male, 1980, BeiJing, 10000), (000002, ZhaoJun, Wang, Female, 1988, ShangHai, 6000), (000003, YuBo, Li, Male, 1988, ShangHai, 8000), (000004, FeiYan, Zhao, Female, 1982, ShenZhen, 5000), (000005, YingYing, Zhang, Female, 1980, BeiJing, 20000).When the inquiry database to Fig. 2 When 200 progress increment modification operation, for example, data update operation, data delete operation and data insertion operation, static list of data 5 static datas in 220 remain unchanged, and increase by three incremental datas in dynamic data tables 210: Update (000003, Salary:15000), Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, Beijing, 13000).
In the disclosure, inquiry database 200 can be OceanBase database, can also be based on Oracle data The database obtained after the modification such as library, MySQL database, is not limited thereto.
In the disclosure, increment modification operation may include that data insertion operation, data delete operation and data update behaviour At least one of in work.Correspondingly, the incremental data in dynamic data tables 210, can be data, the data of deletion of insertion with And at least one of data updated etc. data.
For example, data, which are deleted, to be grasped when being data delete operation to the increment modification operation carried out in database 200 is inquired The object of work is the data that identification number is 000004, then the incremental data in dynamic data tables 210 is " Delete (000004) ". When being that data update operates to the increment modification operation carried out in database 200 is inquired, the object that data update operation is to mark Know number data for being 000003, then the incremental data in dynamic data tables 210 is Update (000003, Salary:15000). When being data insertion operation to the increment modification operation carried out in database 200 is inquired, for example, insertion identification number is 000006 Data, then the incremental data in dynamic data tables 210 be Insert (000006, YuHuan, Yang, Female, 1985, Beijing, 13000).
In the disclosure, an increment modification operation is carried out for inquiry database 200 is every, then in dynamic data tables 210 In correspondingly increase an incremental data, which is used to characterize the operation content of corresponding increment modification operation.Example Such as, a delete operation is carried out respectively to the inquiry database 200 in Fig. 2, an insertion operation and primary update operate, then Correspondingly in dynamic data tables 210 increase by 3 incremental datas: Delete (000004), Insert (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000) and Update (000003, Salary:15000).
In an example of the disclosure, inquiry database 200 be can be using LSM Tree (Log Structured Merged Tree, structuring merge tree) structure storage database.In LSM-Tree structure, the data stored are divided into Two parts: MemTable and SSTable.In this case, dynamic data tables can be MemTable, and static list of data can be with It is SSTable.Correspondingly, it is carried out in MemTable for the increment modification operation of inquiry database, and it is quiet in SSTable State data remain unchanged.
In an example of the disclosure, MemTable be can store in memory, i.e. dynamic data tables are stored in memory. SSTable can store in disk, i.e. static list of data can store in disk.Relative to disk, memory is easier to be read It the operation such as takes and is written, need continually to carry out write operation when frequent progress increment, which is modified, to be operated, MemTable is stored in It is more convenient for carrying out incremental data MemTable is written in memory.Relative to memory, the data in disk are not easy to lose, will be static Tables of data is stored in disk, and the safety that static data stores in static list of data can be improved.
Fig. 3 shows the process of the method for carrying out aggregate query in inquiry database according to the embodiment of the present disclosure Figure.
As shown in figure 3, after receiving for the aggregate query request of inquiry database, being based on dynamic data in block 310 Table generates dynamic queries data corresponding with aggregate query type.
In the disclosure, aggregate query type may include maximum value (MAX) inquiry, minimum value (MIN) inquiry, count (COUNT) inquiry, sum number (SUM) inquiry, average value (AVG) inquiry and non-duplicate object count (COUNT DISTINCT) are looked into At least one of ask etc..But it is not limited in above six kinds according to the aggregate query type of the disclosure, such as can also wrap Include the other types inquiries such as variance inquiry, standard deviation inquiry.Variance (VAR) inquiry and standard deviation inquiry can be looked into based on sum number It askes and counting inquiry obtains corresponding query result.Average value inquiry can obtain average value based on sum number inquiry and counting inquiry Query result.
In the disclosure, aggregate query type can be based on aggregate query request determination, for example, can be by poly- Inquiry request is closed to be analyzed to determine matched aggregate query type.For example, it is assumed that aggregate query request is " to count each city In number ", then aggregate query type is counting inquiry.
It in the disclosure, can based on dynamic data tables dynamic queries data generated if aggregate query type is different To be different.Dynamic queries data can be according to aggregate query type and choose aggregate query class from dynamic data tables Incremental data needed for type simultaneously carries out pattern matched processing to generate.
For example, as shown in Figure 2, dynamic data tables 210 include 3 incremental datas, and every incremental data includes multiple numbers According to element.Specifically, 3 incremental datas include: (000003, Salary:15000) Update, Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, Beijing, 13000).In the polymerization for carrying out such as counting inquiry When inquiry, incremental data relevant to counting inquiry be Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, Beijing, 13000), and the data format of counting inquiry result is (city, Data Identification), is thus obtained Dynamic queries data be Delete (Shenzhen, 000004) and Insert (Beijing, 000006).In the disclosure, Aggregate query type is different, and the data element in incremental data needed for forming dynamic queries data can be different.
In the disclosure, when in dynamic data tables 210 there are when a plurality of incremental data, can be according to preset first sequence Rule arranges a plurality of incremental data.When in dynamic queries data there are when a plurality of data, can be according to preset Two ordering rules arrange a plurality of data.First ordering rule can be identical with the second ordering rule, can not also phase Together.It is inserted for example, the first ordering rule and the second ordering rule can update operation, data delete operation and data using data Enter putting in order for operation.
Then, in block 320, static polymerization calculated result is obtained.
In the disclosure, static polymerization calculated result is according to polymerization calculation method corresponding with aggregate query type, in advance Polymerization calculating first is carried out to static list of data and is obtained.Static polymerization calculated result can reflect out for static list of data into Query result of the row based on aggregate query type.Aggregate query type is different, and corresponding polymerization calculation method can be different.Example Such as, the corresponding polymerization calculation method of counting inquiry polymerization calculation method corresponding from maximum value inquiry is different.
In an example of the disclosure, obtaining static polymerization calculated result may include: from polymerization calculation result data The static polymerization calculated result corresponding with polymerization calculation method is obtained in library.In this case, in advance according to polymerize The corresponding polymerization calculation method of query type obtains static polymerization calculated result to carry out polymerization calculating to static data, and Obtained static polymerization calculated result is correspondingly stored in polymerization calculation result data library with polymerization calculation method.By This can determine aggregate query type based on aggregate query request, then obtain pair after receiving aggregate query request The polymerization calculation method answered may then based on the polymerization calculation method to get correspondence from polymerization calculation result data library Static polymerization calculated result and then improve polymerization to save the time for carrying out polymerization calculating to static list of data and look into Ask efficiency.
In another example of the disclosure, obtain static polymerization calculated result may include: according to aggregate query type Corresponding polymerization calculation method carries out polymerization calculating to static list of data, to obtain static polymerization calculated result.In this feelings Under condition, after receiving aggregate query request every time, polymerization can be all carried out to static list of data and is calculated to obtain static polymerization meter Calculate result.
In an example of the disclosure, dynamic queries data and static polymerization calculated result can be index data, i.e., Dynamic queries data and static polymerization calculated result can be stored in the form of index, and support some phases of index Operation is closed, such as: the operation such as deletion, increase.In this way convenient for subsequent based on dynamic queries data and static polymerization calculated result Polymerization calculates.
Then, in block 330, according to polymerization calculation method corresponding with aggregate query type come to dynamic queries data and quiet State polymerization calculated result carries out polymerization calculating, to obtain data query result.
After obtaining data query result, in block 340, output data query result.
The embodiment of the method for the progress aggregate query in inquiry database provided by the disclosure, will inquire data Library is divided into static list of data and dynamic data tables, and dynamic data tables carry out increment modification operation for inquiry database for storing When incremental data, static list of data is for storing static data.Based on this storage mode, aggregate query request is being received Afterwards, dynamic queries data can be generated based on dynamic data tables, and obtains static polymerization calculated result.When carrying out aggregate query It is that polymerization calculating is carried out to dynamic queries data and static polymerization calculated result, obtains aggregate query result.Due to being gathered The inquiry that the incremental data for inquiry database is considered when inquiry is closed, so that the reality of aggregate query result and database Border situation is consistent, and then improves the accuracy rate of aggregate query.
Fig. 4 shows an exemplary schematic diagram of the counting inquiry according to the embodiment of the present disclosure.
In the example depicted in fig. 4, counting inquiry is that the number in each city being directed in inquiry database 200 is counted Number statistics.As shown in figure 4, dynamic data tables 210 include three incremental datas: Update (000003, Salary:15000), Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000).It is looked into counting In the case where inquiry, the count results for number will not be changed to the update operation of emolument, so that dynamic queries data 230 are only The incremental data of incremental data and data insertion operation including data delete operation.In addition, for the number in each city Counting inquiry, then can only consider two data elements in incremental data: city and Data Identification.Here, Data Identification It can be the identification card number of people corresponding to the data.In this way, dynamic queries data 230 generated are as follows: Insert (Beijing, 000006) and Delete (ShenZhen, 000004).
In this example, static polymerization calculated result 240 can be according to polymerization calculation method corresponding with counting inquiry Static list of data 220 is carried out obtained from polymerization calculating.Specifically, counting inquiry is for every in inquiry database 200 The number in a city carries out counting statistics, the data element that each data in static polymerization calculated result 240 include are as follows: city City and count number.In this way, the data that static polymerization calculated result 240 includes are as follows: (BeiJing, 2), (ShangHai, 2) and (ShenZhen, 1).
When calculating the polymerization corresponding with the progress counting inquiry of static polymerization calculated result 240 of dynamic queries data 230, For the data Insert (Beijing, 000006) in dynamic queries data 230, due to the data element " city " of the data It is then the data of " Beijing " by " city " in static polymerization calculated result 240 for " Beijing ", that is, (BeiJing, 2) increase processing, is carried out, that is, the count number of the data is added 1, thus obtaining the result after polymerization calculates is (BeiJing, 2+1).
For the data Delete (ShenZhen, 000004) in dynamic queries data 230, due to the data element of the data Plain " city " is " ShenZhen ", then is the data of " ShenZhen " by " city " in static polymerization calculated result 240, i.e., (ShenZhen, 1) carries out deleting processing, i.e., the count number of the data is subtracted 1, thus obtains the result after polymerization calculates For (ShenZhen, 1-1).In this way, after carrying out polymerization calculating to dynamic queries data 230 and static polymerization calculated result 240, Obtained data query result are as follows: (BeiJing, 3), (ShangHai, 2) and (ShenZhen, 0).At one of the disclosure In example, the data for being 0 for count number can not also be exported, the data query result thus exported are as follows: (BeiJing, , and (ShangHai, 2) 3).
Fig. 5 shows the exemplary schematic diagram inquired according to the sum number of the embodiment of the present disclosure.
In the example depicted in fig. 5, sum number inquiry is the emolument summation progress for each city in inquiry database 200 Inquiry.As shown in figure 5, dynamic data tables 210 include three incremental datas: Update (000003, Salary:15000) and Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000).It is looked into sum number In the case where inquiry, the update of emolument is operated, insertion operation and delete operation can all influence the calculating of emolument summation, therefore, Dynamic queries data 230 include the incremental data of data delete operation, data update the incremental data of operation and data insertion is grasped The incremental data of work.In addition, the inquiry of the emolument summation for each city, then can only consider three numbers in incremental data According to element: city, emolument and Data Identification.In this way, dynamic queries data 230 generated are as follows: Insert (BeiJing, 000006,13000), Update (ShangHai, 000003,15000:8000) and Delete (ShenZhen, 000004, 5000).Here, 15000:8000 indicates that the emolument before updating is 8000, and updated emolument is 15000.In the disclosure, should The data expression of form indicates this meaning.
In this example, static polymerization calculated result 240 can be according to polymerization calculation method corresponding with sum number inquiry Static list of data 220 is carried out obtained from polymerization calculating.Specifically, sum number inquiry is for each in inquiry database 200 The emolument summation in city is inquired, therefore, the data element that each data in static polymerization calculated result 240 include Are as follows: city, number and emolument summation.In this way, the data that static polymerization calculated result 240 includes are as follows: (BeiJing, 30000, 2), (ShangHai, 14000,2) and (ShenZhen, 5000,1).
When carrying out sum number inquiry corresponding polymerization calculating to dynamic queries data 230 and static polymerization calculated result 240, For the Insert (BeiJing, 000006,13000) in dynamic queries data 230, since " city " of the data is " BeiJing ", then need be to " city " in static polymerization calculated result 240 " BeiJing " data, i.e., (BeiJing, 30000,2), carry out increase processing, that is, by the emolument summation 30000 of the data plus the emolument 13000 in incremental data and Number also adds 1, thus obtains the result after polymerization calculates are as follows: (BeiJing, 30000+13000,2+1).
When carrying out sum number inquiry corresponding polymerization calculating to dynamic queries data 230 and static polymerization calculated result 240, For the Update (ShangHai, 000003,15000:8000) in dynamic queries data 230, due to " the city of the data City " is " ShangHai ", then need be to " city " in static polymerization calculated result 240 " ShangHai " data, i.e., (ShangHai, 14000,2), is updated processing, that is, the emolument summation 14000 of the data is added updated emolument 15000, then the emolument 8000 before updating is subtracted, and number remains unchanged, thus obtain the result after polymerization calculates are as follows: (ShangHai, 14000+15000-8000,2).
When carrying out sum number inquiry corresponding polymerization calculating to dynamic queries data 230 and static polymerization calculated result 240, For the Delete (ShenZhen, 000004,5000) in dynamic queries data 230, since " city " of the data is " ShenZhen ", then need be to " city " in static polymerization calculated result 240 " ShenZhen " data, i.e., (ShenZhen, 5000,1) carries out deleting processing, that is, by emolument summation 5000 subtract the emolument 5000 in incremental data and Number also subtracts 1, thus obtains the result after polymerization calculates are as follows: (ShenZhen, 5000-5000,1-1).
To sum up, obtained data query result includes: (BeiJing, 43000,3), (ShangHai, 21000,2) and (ShenZhen, 0,0).In an example of the disclosure, the data for being 0 for number can not be exported, in addition, in this public affairs In another example opened, the number in data can not also be exported.The data query result then exported at this time are as follows: (BeiJing, 43000), (ShangHai, 21000).
Fig. 6 shows the exemplary schematic diagram inquired according to the maximum value of the embodiment of the present disclosure.
In the example depicted in fig. 6, maximum value inquiry is for the highest salary in inquiry database 220 in each city It is inquired.As shown in fig. 6, dynamic data tables 210 include three incremental datas: Update (000003, Salary:7000), Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000).In maximum value In the case where inquiry, the update of emolument is operated, insertion operation and delete operation can all influence the inquiry of highest salary, because This, dynamic queries data 230 include the incremental data of data delete operation, data update the incremental data of operation and data are inserted into The incremental data of operation.In addition, then can only consider three in incremental data for the inquiry of the highest salary in each city A data element: city, emolument and Data Identification.In this way, dynamic queries data 230 generated are as follows: Insert (BeiJing, 000006,13000), Update (ShangHai, 000003,7000:8000) and Delete (ShenZhen, 000004, 5000)。
In this example, static polymerization calculated result 240 can be according to polymerization corresponding with maximum value inquiry calculating side Method carries out obtained from polymerization calculating static list of data 220.Specifically, maximum value inquiry is for each in inquiry database Highest salary in city is inquired, and is carrying out polymerization calculating to dynamic queries data 230 and static polymerization calculated result 240 When, the data in static list of data 220 may be also needed to refer to, therefore, static polymerization calculated result 240 includes two parts, the A part be static list of data 220 is carried out polymerization calculate it is obtained as a result, the number that each data in the result include According to element are as follows: city, highest salary and number.Second part is number needed for carrying out to each data in static list of data 220 According to the extraction of element, each data only include data element needed for maximum value inquiry: city, Data Identification in obtained result And emolument.In this way, the data for the first part that obtained static polymerization calculated result 240 includes are as follows: (BeiJing, 20000, 2), (ShangHai, 8000,2) and (ShenZhen, 5000,1).The data of second part are as follows: (BeiJing, 000001, 10000), (BeiJing, 000005,20000), (ShangHai, 000002,6000), (ShangHai, 000003,8000) and (ShenZhen, 000004,5000).
Corresponding polymerization calculating is inquired carrying out maximum value to dynamic queries data 230 and static polymerization calculated result 240 When, for the insertion data of data insertion operation in dynamic queries data 230, it can first determine " city " in the insertion data And " emolument ", judge whether the emolument is greater than the corresponding highest salary in the city in the data of first part.If the emolument is big The corresponding highest salary in the city then can be updated to be inserted by the corresponding highest salary in the city in the data of first part Emolument in data;If the emolument is directed to highest no more than the corresponding highest salary in the city in the data of first part Emolument can not be handled, and number adds 1.
In this example, for the data Insert (BeiJing, 000006,13000) in dynamic queries data 230, by In " city " of the data be " BeiJing " and " emolument " is " 13000 ", judges whether the emolument " 13000 " is greater than first Highest salary " 20000 " corresponding to " BeiJing " in the data divided.Since the emolument " 13000 " is no more than first part Highest salary " 20000 " corresponding to " BeiJing " in data can not then be handled for highest salary, and number adds 1.By This obtains the result after polymerization calculates are as follows: (BeiJing, MAX (20000,13000), 3), that is, (BeiJing, 20000,3).
Corresponding polymerization calculating is inquired carrying out maximum value to dynamic queries data 230 and static polymerization calculated result 240 When, data in dynamic queries data 230 are updated with the more new data of operation, can first determine " city " in more new data, " emolument " before updated " emolument " and update, judges whether updated emolument is greater than the city in the data of first part Corresponding highest salary.If updated emolument is greater than the corresponding highest salary in the city in the data of first part, can The corresponding highest salary in the city is updated to the updated emolument;If updated emolument is no more than first part The corresponding highest salary in the city in data, then continue whether the emolument before judging to update is the city in the data of first part Corresponding highest salary illustrates more if the emolument before updating is not the corresponding highest salary in the city in the data of first part Emolument before new is non-highest salary, then can not handle for highest salary;If the emolument before updating is the number of first part The corresponding highest salary in the city in illustrates that the emolument before updating is highest salary, is then counted in second part data After update, the corresponding emolument in the city after update is compared again, obtains highest salary.
In this example, in dynamic queries data 230 data Update (ShangHai, 000003,7000: 8000) emolument before, " city " of the data is " ShangHai ", updated emolument is " 7000 " and updates is " 8000 ". Judge whether updated emolument " 7000 " is greater than " ShangHai " corresponding highest salary " 8000 " in the data of first part. Since updated emolument " 7000 " are no more than the emolument " 8000 " before updating, then continuing the emolument " 8000 " before judgement updates is " ShangHai " corresponding highest salary " 8000 " in the no data for first part, since the emolument " 8000 " before updating is the " ShangHai " corresponding highest salary " 8000 " in the data of a part illustrates that the emolument before updating is highest salary, then exists After carrying out data update in second part data, " ShangHai " corresponding emolument includes: " 6000 " and " 7000 ", after update " ShangHai " corresponding emolument is compared again, show that highest salary is " 7000 ".The knot after polymerization calculates is obtained in this way Fruit are as follows: (ShangHai, MAX (6000,7000), 2), that is, (ShangHai, 7000,2).
Corresponding polymerization calculating is inquired carrying out maximum value to dynamic queries data 230 and static polymerization calculated result 240 When, for the deletion data of data delete operation in dynamic queries data 230, it can first determine " city " in the deletion data And " emolument ", judge whether emolument highest salary corresponding with the city in the data of first part is identical, if the emolument Highest salary corresponding with the city in the data of first part is not identical, then can not handle for highest salary;If should Emolument is identical as the corresponding highest salary in the city in the data of first part, then data deletion is carried out in second part data Later, if there is also the data in the city in second part data, to there is also the corresponding emolument in the city carry out weight It is new relatively to obtain highest salary, if the data in the city are not present in second part data, also it is not present for the city Highest salary.
It in this example, should for the data Delete (ShenZhen, 000004,5000) in dynamic queries data 230 " city " of data is " ShenZhen " and emolument is " 5000 ".Judge in the emolument " 5000 " and the data of first part Whether highest salary " 5000 " corresponding to " ShenZhen " is identical, due in the emolument " 5000 " and the data of first part Highest salary " 5000 " corresponding to " ShenZhen " is identical, then after carrying out data deletion in second part data, i.e., (ShenZhen ,-, 1-1), there is no " ShenZhen " corresponding data in second part data, then highest salary is not present, this Sample obtains the result after polymerization calculates are as follows: (ShenZhen ,-, 0).
To sum up, obtained data query result be include: (BeiJing, 20000,3), (ShangHai, 7000,2), (ShenZhen ,-, 0).In an example of the disclosure, the data for being 0 for number can not be exported.In the another of the disclosure In one example, the number in data can not also be exported.Thus the data query result exported are as follows: (BeiJing, 20000), (ShangHai, 7000).
Fig. 7 shows the exemplary schematic diagram inquired according to the minimum value of the embodiment of the present disclosure.
In the example depicted in fig. 7, minimum value inquiry is for the minimum emolument in inquiry database 220 in each city It is inquired.As shown in fig. 7, dynamic data tables 210 include three incremental datas: Update (000002, Salary:7000), Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000).In minimum value In the case where inquiry, the update of emolument is operated, insertion operation and delete operation can all influence the inquiry of minimum emolument, because This, dynamic queries data 230 include the incremental data of data delete operation, data update the incremental data of operation and data are inserted into The incremental data of operation.In addition, then can only consider three in incremental data for the inquiry of the minimum emolument in each city A data element: city, emolument and Data Identification.In this way, dynamic queries data 230 generated are as follows: Insert (BeiJing, 000006,13000), Update (ShangHai, 000002,7000:6000) and Delete (ShenZhen, 000004, 5000)。
In this example, static polymerization calculated result 240 can be according to polymerization corresponding with minimum value inquiry calculating side Method carries out obtained from polymerization calculating static list of data 220.Specifically, minimum value inquiry is for each in inquiry database Minimum emolument in city is inquired, and is carrying out polymerization calculating to dynamic queries data 230 and static polymerization calculated result 240 When, the data in static list of data 220 may be also needed to refer to, therefore, static polymerization calculated result 240 includes two parts, the A part be static list of data 220 is carried out polymerization calculate it is obtained as a result, the number that each data in the result include According to element are as follows: city, lowest salary respond with a poem number.Second part is number needed for carrying out to each data in static list of data 220 According to the extraction of element, each data only include data element needed for minimum value inquiry: city, Data Identification in obtained result And emolument.In this way, the data for the first part that obtained static polymerization calculated result 240 includes are as follows: (BeiJing, 10000, 2), (ShangHai, 6000,2) and (ShenZhen, 5000,1).The data of second part are as follows: (BeiJing, 000001, 10000), (BeiJing, 000005,20000), (ShangHai, 000002,6000), (ShangHai, 000003,8000) and (ShenZhen, 000004,5000).
Corresponding polymerization calculating is inquired carrying out minimum value to dynamic queries data 230 and static polymerization calculated result 240 When, for the insertion data of data insertion operation in dynamic queries data 230, it can first determine " city " in the insertion data And " emolument ", judge whether the emolument is less than the corresponding minimum emolument in the city in the data of first part.If the emolument is small The corresponding minimum emolument in the city then can be updated to be inserted by the corresponding minimum emolument in the city in the data of first part Emolument in data;If the emolument is not less than the corresponding minimum emolument in the city in the data of first part, for minimum Emolument can not be handled, and number adds 1.
It in this example, should for the data Insert (BeiJing, 000006,13000) in dynamic queries data 230 " city " of data is " BeiJing " and " emolument " is " 13000 ".Judge whether the emolument " 13000 " is less than first part " BeiJing " corresponding minimum emolument " 10000 " in data.Since the emolument " 13000 " is not less than in first part's data Minimum emolument " 10000 " can not then be handled for minimum emolument, and number adds 1.The result after polymerization calculates is obtained in this way Are as follows: (BeiJing, MIN (10000,13000), 3), i.e. (BeiJing, 10000,3).
Corresponding polymerization calculating is inquired carrying out minimum value to dynamic queries data 230 and static polymerization calculated result 240 When, in dynamic queries data 230 data update operation more new data, can determine " city " changed in more new data, " emolument " before updated " emolument " and update, judges whether updated emolument is less than the city in the data of first part Corresponding minimum emolument.If updated emolument is less than the corresponding minimum emolument in the city in the data of first part, can The corresponding minimum emolument in the city is updated to the updated emolument;If updated emolument is not less than first part The corresponding minimum emolument in the city in data, then continue whether the emolument before judging to update is the city in the data of first part Corresponding minimum emolument illustrates more if the emolument before updating is not the corresponding minimum emolument in the city in the data of first part Emolument before new is not least emolument, can not be handled for minimum emolument;If the emolument before updating is the data of first part In the corresponding minimum emolument in the city, illustrate update before emolument be minimum emolument, then data are carried out in second part data After update, the corresponding emolument in the city after update is compared again, obtains minimum emolument.
In this example, in dynamic queries data 230 data Update (ShangHai, 000002,7000: 6000) emolument before emolument is " 7000 " and updates after, " city " of the data is " ShangHai ", updates is " 6000 ".Sentence Whether emolument " 7000 " is less than " ShangHai " corresponding minimum emolument " 6000 " in the data of first part after disconnected update.If It is not less than, then continues whether the emolument " 6000 " before judging to update is that " ShangHai " is corresponding minimum in the data of first part Emolument " 6000 ", since the emolument " 6000 " before updating is " ShangHai " corresponding minimum emolument in the data of first part " 6000 " illustrate that the emolument " 6000 " before updating is minimum emolument, then after carrying out data update in second part data, " ShangHai " corresponding emolument includes: " 7000 " and " 8000 ", is carried out again to " ShangHai " after update corresponding emolument Compare, show that minimum emolument is " 7000 ".The result after polymerization calculates is obtained in this way are as follows: (ShangHai, MIN (7000, 8000), 2), i.e., (ShangHai, 7000,2).
Corresponding polymerization calculating is inquired carrying out minimum value to dynamic queries data 230 and static polymerization calculated result 240 When, for the deletion data of data delete operation in dynamic queries data 230, it can first determine " city " in the deletion data And " emolument ", judge whether the emolument minimum emolument corresponding with the city in the data of first part is identical, if the emolument Minimum emolument corresponding with the city in the data of first part is not identical, then can not handle for minimum emolument;If should Emolument minimum emolument corresponding with the city in the data of first part is identical, then data deletion is carried out in second part data Later, if there is also the data in the city in second part data, to there is also the corresponding emolument in the city carry out weight It is new relatively to obtain minimum emolument, if the data in the city are not present in second part data, also it is not present for the city Minimum emolument.
In this example, for for Delete (ShenZhen, 000004,5000), " city " of the data is " ShenZhen " and emolument are " 5000 ".Judge in the emolument " 5000 " and the data of first part corresponding to " ShenZhen " Whether minimum emolument " 5000 " is identical, in the emolument " 5000 " and the data of first part corresponding to " ShenZhen " most High emolument " 5000 " is identical, then after carrying out data deletion in second part data, i.e., (ShenZhen ,-, 1-1), second There is no " ShenZhen " corresponding data in partial data, then minimum emolument is not present, obtains the result after polymerization calculates in this way Are as follows: (ShenZhen ,-, 0).
To sum up, obtained data query result be include: (BeiJing, 10000,3), (ShangHai, 7000,2), (ShenZhen ,-, 0).In one example, the data for being 0 for number can not be exported.In another example of the disclosure, Number in data can not also export.Thus the data query result exported are as follows: (BeiJing, 10000), (ShangHai, 7000)。
Fig. 8 shows the exemplary schematic diagram inquired according to the non-duplicate object count of the embodiment of the present disclosure.
In the example depicted in fig. 8, non-duplicate object count inquiry is to be directed in inquiry database 200 in each city not Quantity with surname is inquired.As shown in figure 8, dynamic data tables 210 include three incremental datas: Update (000003, Last_Name:Wang), Delete (000004) and Insert (000006, YuHuan, Yang, Female, 1985, BeiJing, 13000).For the quantity inquiry of surnames different in each city, the update of surname is operated, is inserted Query result can all be influenced by entering operation and delete operation, and therefore, dynamic queries data 230 include the increment of data delete operation Data, data update the incremental data of operation and the incremental data of data insertion operation.In addition, for not of the same surname in each city The inquiry of the quantity of family name then can only consider three data elements in incremental data: city, surname and Data Identification.In this way, Dynamic queries data 230 generated are as follows: Insert (BeiJing, 000006, Yang), Update (ShangHai, 000003, ) and Delete (ShenZhen, 000004, Zhao) Wang:Li.
In this example, static polymerization calculated result 240 can be according to corresponding with the inquiry of non-duplicate object count poly- Calculation method is closed to carry out obtained from polymerization calculating static list of data 220.Specifically, non-duplicate object count inquiry is to be directed to The quantity of different surnames is inquired in each city in inquiry database 200, therefore, in static polymerization calculated result 240 The data element that each data include are as follows: city, surname and count number.In this way, static polymerization calculated result 240 includes Data are as follows: (BeiJing, (<Zhang, 2>)), (ShangHai, (<Wang, 2>,<Li, 1>)) and (ShenZhen, (and<Zhao, 1 >)).Here,<Zhang, the count number that 2>expression surname is Zhang is 2, and the form indicates this meaning in the disclosure.
In an example of the disclosure, the count number of surname and surname can use the form of key-value pair, in static state HashMap is preset in polymerization calculated result 240 for storing key-value pair, each key-value pair can be indicated with key-value, Key can be used to indicate that surname, and value is for indicating count number.In this way, each key-value pair can represent a surname Corresponding count number.
It is corresponding carrying out non-duplicate object count inquiry to dynamic queries data 230 and static polymerization calculated result 240 When polymerization calculates, for the insertion data of data insertion operation in dynamic queries data 230, it can determine in the insertion data " city " and " surname " then can will when having the surname in the surname corresponding to the city in static polymerization calculated result 240 The corresponding count number of the surname adds 1 in the city.In the surname corresponding to the city in static polymerization calculated result 240 Not when the surname, then it can increase the corresponding relationship of the surname and count number in the corresponding data in the city.
In this example, the data Insert (BeiJing, 000006, Yang) in dynamic queries data 230 is come It says, " city " of the data is " BeiJing ", and " surname " is " Yang ", due in static polymerization calculated result 240 When there is no " Yang " in " BeiJing " corresponding " surname ", then can increase in " BeiJing " corresponding data " Yang " with The corresponding relationship of count number, obtain in this way polymerization calculate after result be (BeiJing, (and<Zhang, 2>,<Yang, 1>)).
It is corresponding carrying out non-duplicate object count inquiry to dynamic queries data 230 and static polymerization calculated result 240 When polymerization calculates, data in dynamic queries data 230 are updated with the more new data of operation, can be determined in the more new data " city " and " surname ", " surname " include the surname and updated surname before updating.It will in static polymerization calculated result 240 The corresponding count number of surname before updating in the city subtracts 1, and when having in the city in static polymerization calculated result 240 When the updated surname, then the corresponding count number of the updated surname of this in the city can be added 1.Work as static polymerization When there is no the updated surname in calculated result in the city, then it can increase in the corresponding data in the city updated The corresponding relationship of surname and count number.
In this example, for the data Update (ShangHai, 000003, Wang:Li) in dynamic queries data 230 For, " city " of the data is " ShangHai ", and surname is " Li " before updating, and surname is " Wang " after update.Static state is poly- Closing in calculated result 240 " city " is that the count number of surname before " ShangHai " corresponding update subtracts 1, due to static polymerization " ShangHai " is corresponding with surname after update in calculated result 240, then can be by surname after " ShangHai " corresponding update Count number adds 1.Thus the result after polymerization calculates is obtained are as follows: (ShangHai, (<Wang, 2>)).
It is corresponding carrying out non-duplicate object count inquiry to dynamic queries data 230 and static polymerization calculated result 240 When polymerization calculates, for the deletion data of data delete operation in dynamic queries data 230, can first it determine in the deletion data " city " and " surname ", the corresponding count number of the surname in the city is subtracted 1 in static polymerization calculated result 240
In this example, for for Delete (ShenZhen, 000004, Zhao), " city " of the data is " ShenZhen ", " surname " are " Zhao ", then are that " ShenZhen " is corresponding by " city " in static polymerization calculated result 240 " surname " is that the count number of " Zhao " subtracts 1, and thus obtaining the result after polymerization calculates is (ShenZhen, ()).
To sum up, obtained data query result be include: (BeiJing, 2), (ShangHai, 1), (ShenZhen, 0).In one example, the data that the count number for surname is 0 can not be exported, then the data query result exported at this time Are as follows: (BeiJing, 2), (ShangHai, 1).
Fig. 9 shows the method for carrying out aggregate query in inquiry database according to another embodiment of the present disclosure Flow chart.Embodiment shown in Fig. 9 is the modification embodiment of the embodiment shown in above-mentioned Fig. 3.Block 910 in Fig. 9 is to block 940 operation is identical to block 340 as the block 310 in Fig. 3 respectively, no longer describes herein.
In block 940 after output data query result, in block 950, judge whether to reach predetermined merging condition, if reached Predetermined merging condition merges processing to dynamic data tables and static list of data then in block 960, updated quiet to obtain State tables of data.Here, obtained static list of data can be used for inquiry next time.When merging processing, can will move Each incremental data in state tables of data is merged with static data corresponding in static list of data, and then after obtaining merging Data, the data after the merging are the static data stored in updated static list of data.
In the disclosure, predetermined merging condition can be customized setting.In an example of the disclosure, make a reservation for close And condition can be with are as follows: the data volume in dynamic data tables reaches preset data amount threshold value.Preset data amount threshold value, which can be, to be made by oneself Justice setting, for example, preset data amount threshold value is 20G, then when the data volume in dynamic data tables reaches 20G, to dynamic number Processing is merged according to table and static list of data.
In another example of the disclosure, predetermined merging condition can be to receive static list of data more new command.It is quiet State tables of data more new command can be user and trigger transmission.The static list of data more new command is for triggering to dynamic data tables Processing is merged with static list of data.
Then, in block 970, the incremental data in dynamic data tables is emptied, so that no longer storing in dynamic data tables There is the incremental data being already incorporated into static list of data.If not up to predetermined merging condition, in block 980, keep static Tables of data is constant.
Processing is merged to dynamic data tables and static list of data by the predetermined merging condition of setting, and empties dynamic Tables of data.The incremental data accumulated in dynamic data tables can be caused more to avoid because of a large amount of increment modification operation, into And make the time longer problem spent when generating dynamic queries data based on dynamic data tables.Because predetermined merging condition can Aperiodically to empty dynamic data tables, so that dynamic data tables continue the newly-increased incremental number of storage with the storage state after emptying According to, so that the incremental data stored in dynamic data tables keeps lesser data volume, so that needed for aggregate query Time is shorter, improves the efficiency of aggregate query.
Figure 10 is shown according to the embodiment of the present disclosure for carrying out the device of aggregate query (under in inquiry database In text be referred to as aggregate query device) 1000 block diagram.As shown in Figure 10, aggregate query device 1000 includes dynamic queries number According to generation unit 1010, it polymerize calculated result acquiring unit 1020, query result obtaining unit 1030 and query result output are single Member 1040.
Dynamic queries data generating unit 1010 is configured as receiving the aggregate query request for inquiry database Afterwards, dynamic queries data corresponding with aggregate query type are generated based on dynamic data tables.Inquiring database includes dynamic number According to table and static list of data, dynamic data tables are used to store incremental number when carrying out increment modification operation for inquiry database According to static list of data is remained unchanged for storing static data, static data when carrying out the increment modification operation.Dynamic is looked into Asking operation performed by data generating unit 1010 can be with reference to the operation above with reference to Fig. 3 block 310 described.
Polymerization calculated result acquiring unit 1020 is configured as obtaining static polymerization calculated result, static polymerization calculated result It is that polymerization calculating is carried out to static list of data according to polymerization calculation method corresponding with aggregate query type and is obtained.At this In a disclosed example, polymerization calculated result acquiring unit 1020 be can be configured as: from polymerization calculation result data library Obtain and polymerize the corresponding static polymerization calculated result of calculation method, wherein static polymerization calculated result with polymerize calculation method It is correspondingly stored in polymerization calculation result data library.In another example of the disclosure, it polymerize calculated result acquiring unit 1020 can be configured as: carry out polymerization meter to static list of data according to polymerization calculation method corresponding with aggregate query type It calculates, to obtain static polymerization calculated result.Operation performed by polymerization calculated result acquiring unit 1020 can refer to be joined above According to the operation of the block 320 of Fig. 3 description.
Query result obtaining unit 1030 is configured as according to polymerization calculation method come poly- to dynamic queries data and static state It closes calculated result and carries out polymerization calculating, to obtain data query result.Operation performed by query result obtaining unit 1030 can With reference to the operation above with reference to Fig. 3 block 330 described.
Query result output unit 1040 is configured as output data query result.Query result output unit 1040 is held Capable operation can be with reference to the operation above with reference to Fig. 3 block 340 described.
Figure 11 shows the dress for the progress aggregate query in inquiry database according to another embodiment of the present disclosure Set the block diagram of 1100 (hereinafter referred to as aggregate query devices 1100).As shown in figure 11, aggregate query device 1100 includes Dynamic queries data generating unit 1110 polymerize calculated result acquiring unit 1120, query result obtaining unit 1130, inquiry knot Fruit output unit 1140, static list of data updating unit 1150 and empties unit 1160.
Dynamic queries data generating unit 1110 polymerize calculated result acquiring unit 1120, query result obtaining unit 1130, query result output unit 1140 structurally and operationally with the dynamic queries data generating unit that is described above with reference to Figure 10 1010, it polymerize calculated result acquiring unit 1020, query result obtaining unit 1030, the structure of query result output unit 1040 It is identical with operation, it no longer describes herein.
Static list of data updating unit 1150 is configured as when meeting predetermined merging condition, to dynamic data tables and static state Tables of data merges processing, to obtain updated static list of data.Behaviour performed by static list of data updating unit 1150 Making can be with reference to the operation of the above-mentioned block 960 referring to Fig. 9 description.
Unit 1160 is emptied to be configured as emptying dynamic data tables.Empty operation performed by unit 1160 can refer to it is upper Operation of the face referring to the block 970 of Fig. 9 description.
In another example of the disclosure, aggregate query device 1100 can also include judging unit (not shown).This is sentenced Disconnected unit is configured as judging predetermined merging condition, and exports judging result.Specifically, when predetermined merging condition is When data volume in state tables of data reaches preset data amount threshold value, which is configured as judging the number in dynamic data tables Whether reach preset data amount threshold value according to amount.When predetermined merging condition is to receive static list of data more new command, the judgement Module is configured as judging whether to receive static list of data more new command.
Above by reference to Fig. 1 to Figure 11, to according to the aggregate query method of the embodiment of the present disclosure and the reality of aggregate query device Example is applied to be described.
The aggregate query device of the disclosure can use hardware realization, can also be using the group of software or hardware and software It closes to realize.It taking software implementation as an example, as the device on a logical meaning, will be deposited by the processor of equipment where it Corresponding computer program instructions are read into memory what operation was formed in reservoir.In the disclosure, aggregate query device is for example It can use and calculate equipment realization.
Figure 12 is shown according to the embodiment of the present disclosure for carrying out the calculating equipment of aggregate query in inquiry database 1200 block diagram.
As shown in figure 12, calculating equipment 1200 includes processor 1210, memory 1220, memory 1230, communication interface 1240 and internal bus 1250.According to one embodiment, calculating equipment 1200 may include at least one processor 1210, this is extremely A few processor 1210 executes at least one of storage or coding calculating in computer readable storage medium (that is, memory) Machine readable instruction (that is, above-mentioned element realized in a software form).
In one embodiment, computer executable instructions are stored in memory, make at least one when implemented Processor 1210: it after receiving for the aggregate query request of inquiry database, is generated and is polymerize based on dynamic data tables The corresponding dynamic queries data of query type;Obtain static polymerization calculated result, static polymerization calculated result be according to polymerize The corresponding polymerization calculation method of query type come to static list of data carry out polymerization calculating and obtain;According to polymerization calculation method Polymerization calculating is carried out to dynamic queries data and static polymerization calculated result, to obtain data query result;And output number According to query result.
It should be understood that the computer executable instructions stored in memory make at least one processor when implemented 1210 carry out the above various operations and functions described in conjunction with Fig. 1-11 in each embodiment of the disclosure.
According to one embodiment, a kind of program product of such as machine readable media is provided.Machine readable media can be with With instruction (that is, above-mentioned element realized in a software form), the instruction when executed by a machine so that machine executes the disclosure Each embodiment in the above various operations and functions described in conjunction with Fig. 1-11.
Specifically, system or device equipped with readable storage medium storing program for executing can be provided, stored on the readable storage medium storing program for executing Realize above-described embodiment in any embodiment function software program code, and make the system or device computer or Processor reads and executes the instruction being stored in the readable storage medium storing program for executing.
In this case, it is real that any one of above-described embodiment can be achieved in the program code itself read from readable medium The function of example is applied, therefore the readable storage medium storing program for executing of machine readable code and storage machine readable code constitutes of the invention one Point.
The embodiment of readable storage medium storing program for executing include floppy disk, hard disk, magneto-optic disk, CD (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), tape, non-volatile memory card and ROM.It selectively, can be by communication network Network download program code from server computer or on cloud.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims It is interior.In some cases, the movement recorded in detail in the claims or step can be come according to the sequence being different from embodiment It executes and desired result still may be implemented.In addition, process depicted in the drawing not necessarily require show it is specific suitable Sequence or consecutive order are just able to achieve desired result.In some embodiments, multitasking and parallel processing be also can With or may be advantageous.
Not all step and unit are all necessary in above-mentioned each process and each system construction drawing, can be according to reality Need to ignore certain step or units.Each step execution sequence be not it is fixed, can according to need and be determined.It is above-mentioned Apparatus structure described in each embodiment can be physical structure, be also possible to logical construction, that is, some units may be by same Physical entity is realized, is realized alternatively, some units may divide by multiple physical entities, alternatively, can be by multiple autonomous devices Certain components realize jointly.
The term used in entire this specification " exemplary " means " being used as example, example or illustration ", and unexpectedly Taste than other embodiments " preferably " or " have advantage ".For the purpose of the understanding to described technology is provided, it is embodied Mode includes detail.However, it is possible to implement these technologies without these specific details.In some examples In, in order to avoid the concept to described embodiment causes indigestion, well known construction and device is shown in block diagram form.
The optional embodiment of embodiment of the disclosure, still, the implementation of the disclosure is described in detail in conjunction with attached drawing above Example be not limited to the above embodiment in detail, in the range of the technology design of embodiment of the disclosure, can to this The technical solution of disclosed embodiment carries out a variety of simple variants, these simple variants belong to the protection of embodiment of the disclosure Range.
The foregoing description of present disclosure is provided so that any those of ordinary skill in this field can be realized or make Use present disclosure.To those skilled in the art, the various modifications carried out to present disclosure are apparent , also, can also answer generic principles defined herein in the case where not departing from the protection scope of present disclosure For other modifications.Therefore, present disclosure is not limited to examples described herein and design, but disclosed herein with meeting Principle and novel features widest scope it is consistent.

Claims (16)

1. a kind of method for carrying out aggregate query in inquiry database, the inquiry database include dynamic data tables with Static list of data, the dynamic data tables are used to store incremental data when carrying out increment modification operation for inquiry database, The static list of data is remained unchanged for storing static data, the static data when carrying out the increment modification operation, The described method includes:
After receiving for the aggregate query request of the inquiry database, is generated and polymerize based on the dynamic data tables The corresponding dynamic queries data of query type;
Obtain static polymerization calculated result, wherein the static polymerization calculated result be according to the aggregate query type pair The polymerization calculation method answered come to the static list of data carry out polymerization calculating and obtain;
Polymerization meter is carried out to the dynamic queries data and the static polymerization calculated result according to the polymerization calculation method It calculates, to obtain data query result;And
Export the data query result.
2. the method for claim 1, wherein obtaining static polymerization calculated result includes:
The static polymerization calculated result corresponding with the polymerization calculation method is obtained from polymerization calculation result data library, In, the static polymerization calculated result is correspondingly stored in the polymerization calculation result data library with the polymerization calculation method In.
3. the method for claim 1, wherein obtaining static polymerization calculated result includes:
Polymerization calculating is carried out to the static list of data according to polymerization calculation method corresponding with the aggregate query type, with Obtain the static polymerization calculated result.
4. the method as described in claim 1, further includes:
When meeting predetermined merging condition, processing is merged to the dynamic data tables and the static list of data, to obtain Updated static list of data;And
Empty the dynamic data tables.
5. method as claimed in claim 4, wherein the predetermined merging condition includes:
Data volume in the dynamic data tables reaches preset data amount threshold value;Or
Receive static list of data more new command.
6. the method for claim 1, wherein the increment modification operation includes that following increments are modified in operation at least One:
Data insertion operation;
Data delete operation;With
Data update operation.
7. the method as described in any in claims 1 to 6, wherein the aggregate query type includes following aggregate query classes At least one of in type:
Maximum value inquiry;
Minimum value inquiry;
Counting inquiry;
Sum number inquiry;
Average value inquiry;With
Non-duplicate object count inquiry.
8. the method for claim 1, wherein the dynamic queries data and the static polymerization calculated result are indexes Data.
9. the method for claim 1, wherein the inquiry database is the data using the storage of LSM Tree structure Library.
10. a kind of for carrying out the device of aggregate query in inquiry database, the inquiry database includes dynamic data tables And static list of data, the dynamic data tables are used to store incremental number when carrying out increment modification operation for inquiry database According to the static list of data is kept not for storing static data, the static data when carrying out the increment modification operation Become, described device includes:
Dynamic queries data generating unit is configured as after receiving for the aggregate query request of the inquiry database, Dynamic queries data corresponding with aggregate query type are generated based on the dynamic data tables;
It polymerize calculated result acquiring unit, is configured as obtaining static polymerization calculated result, wherein the static polymerization calculates knot Fruit be according to polymerization calculation method corresponding with the aggregate query type come to the static list of data carry out polymerization calculating and It obtains;
Query result obtaining unit is configured as according to the polymerization calculation method come to dynamic queries data and described quiet State polymerization calculated result carries out polymerization calculating, to obtain data query result;And
Query result output unit is configured as exporting the data query result.
11. device as claimed in claim 10, wherein the polymerization calculated result acquiring unit is configured as:
The static polymerization calculated result corresponding with the polymerization calculation method is obtained from polymerization calculation result data library, In, the static polymerization calculated result is correspondingly stored in the polymerization calculation result data library with the polymerization calculation method In.
12. device as claimed in claim 10, wherein the polymerization calculated result acquiring unit is configured as:
Polymerization calculating is carried out to the static list of data according to polymerization calculation method corresponding with the aggregate query type, with Obtain the static polymerization calculated result.
13. device as claimed in claim 10, further includes:
Static list of data updating unit is configured as when meeting predetermined merging condition, to dynamic data tables and described quiet State tables of data merges processing, to obtain updated static list of data;And
Unit is emptied, is configured as emptying the dynamic data tables.
14. device as claimed in claim 13, wherein the predetermined merging condition includes:
Data volume in the dynamic data tables reaches preset data amount threshold value;Or
Receive static list of data more new command.
15. a kind of calculating equipment, comprising:
At least one processor, and
The memory coupled at least one described processor, the memory store instruction, when described instruction by it is described at least When one processor executes, so that at least one described processor executes the method as described in any in claims 1 to 9.
16. a kind of machine readable storage medium, is stored with executable instruction, described instruction makes the machine upon being performed Execute the method as described in any in claims 1 to 9.
CN201910671470.3A 2019-07-24 2019-07-24 For carrying out the method and device of aggregate query in inquiry database Pending CN110457350A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910671470.3A CN110457350A (en) 2019-07-24 2019-07-24 For carrying out the method and device of aggregate query in inquiry database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910671470.3A CN110457350A (en) 2019-07-24 2019-07-24 For carrying out the method and device of aggregate query in inquiry database

Publications (1)

Publication Number Publication Date
CN110457350A true CN110457350A (en) 2019-11-15

Family

ID=68483288

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910671470.3A Pending CN110457350A (en) 2019-07-24 2019-07-24 For carrying out the method and device of aggregate query in inquiry database

Country Status (1)

Country Link
CN (1) CN110457350A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111367897A (en) * 2019-06-03 2020-07-03 杭州海康威视系统技术有限公司 Data processing method, device, equipment and storage medium
CN113282568A (en) * 2021-04-26 2021-08-20 本影(上海)网络科技有限公司 IOT big data real-time sequence flow analysis application technical method
CN114253950A (en) * 2022-02-28 2022-03-29 北京奥星贝斯科技有限公司 Method and device for managing database
CN114265849A (en) * 2022-02-28 2022-04-01 杭州广立微电子股份有限公司 Data aggregation method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103353891A (en) * 2013-07-05 2013-10-16 北京人大金仓信息技术股份有限公司 Database management system and data processing method thereof
CN108804459A (en) * 2017-05-02 2018-11-13 杭州海康威视数字技术股份有限公司 Data query method and device
US20190073390A1 (en) * 2017-09-07 2019-03-07 International Business Machines Corporation Data storage with improved efficiency

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103353891A (en) * 2013-07-05 2013-10-16 北京人大金仓信息技术股份有限公司 Database management system and data processing method thereof
CN108804459A (en) * 2017-05-02 2018-11-13 杭州海康威视数字技术股份有限公司 Data query method and device
US20190073390A1 (en) * 2017-09-07 2019-03-07 International Business Machines Corporation Data storage with improved efficiency

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111367897A (en) * 2019-06-03 2020-07-03 杭州海康威视系统技术有限公司 Data processing method, device, equipment and storage medium
CN111367897B (en) * 2019-06-03 2023-09-08 杭州海康威视系统技术有限公司 Data processing method, device, equipment and storage medium
CN113282568A (en) * 2021-04-26 2021-08-20 本影(上海)网络科技有限公司 IOT big data real-time sequence flow analysis application technical method
CN113282568B (en) * 2021-04-26 2022-08-09 本影(上海)网络科技有限公司 IOT big data real-time sequence flow analysis application technical method
CN114253950A (en) * 2022-02-28 2022-03-29 北京奥星贝斯科技有限公司 Method and device for managing database
CN114265849A (en) * 2022-02-28 2022-04-01 杭州广立微电子股份有限公司 Data aggregation method and system

Similar Documents

Publication Publication Date Title
CN110457350A (en) For carrying out the method and device of aggregate query in inquiry database
CN105786955B (en) Data duplication in data base management system
CN104199816B (en) The management storage of independent accessible data unit
US7962521B2 (en) Index selection in a database system
US9092481B2 (en) Method and system for processing graph queries
CN109189852B (en) Data synchronization method and device for data synchronization
Bassil A comparative study on the performance of the Top DBMS systems
WO2003071447A2 (en) Adaptive acceleration of retrieval queries
US20230394009A1 (en) Data pruning based on metadata
CN108776678B (en) Index creation method and device based on mobile terminal NoSQL database
CN112084161B (en) Database-based data processing method and device and readable storage medium
CN113420026A (en) Database table structure changing method, device, equipment and storage medium
Srivastava et al. TBSAM: An access method for efficient processing of statistical queries
CN107346317A (en) A kind of data query method and apparatus
CN111984688B (en) Method and device for determining business knowledge association relationship
Kvet et al. Master index access as a data tuple and block locator
CN111400303B (en) Intelligent contract data extraction and synchronization method and system
US7275065B2 (en) Method and system for supporting per-user-per-row read/unread tracking for relational databases
CN112632157A (en) Multi-condition paging query method under distributed system
Schöning et al. Cluster mechanisms supporting the dynamic construction of complex objects
Helmer Evaluating different approaches for indexing fuzzy sets
Šaltenis et al. Indexing of now-relative spatio-bitemporal data
Bugiotti et al. A logical approach to nosql databases
US11593366B2 (en) Techniques for pushing joins into union all views
CN108052522A (en) A kind of method and system that dynamic optimization is carried out to OLAP precomputations model

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
TA01 Transfer of patent application right

Effective date of registration: 20201012

Address after: English genus

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: English genus

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201012

Address after: English genus

Applicant after: Advanced innovation technology Co.,Ltd.

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

Applicant before: Alibaba Group Holding Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210203

Address after: 801-10, Section B, 8th floor, 556 Xixi Road, Xihu District, Hangzhou City, Zhejiang Province

Applicant after: Ant financial (Hangzhou) Network Technology Co.,Ltd.

Address before: English genus

Applicant before: Innovative advanced technology Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210908

Address after: 100020 unit 02, 901, floor 9, unit 1, building 1, No.1, East Third Ring Middle Road, Chaoyang District, Beijing

Applicant after: Beijing Aoxing Beisi Technology Co.,Ltd.

Address before: 801-10, Section B, 8th floor, 556 Xixi Road, Xihu District, Hangzhou City, Zhejiang Province 310000

Applicant before: Ant financial (Hangzhou) Network Technology Co.,Ltd.

TA01 Transfer of patent application right