CN107239485A - Database operation method, apparatus and system - Google Patents

Database operation method, apparatus and system Download PDF

Info

Publication number
CN107239485A
CN107239485A CN201710253093.2A CN201710253093A CN107239485A CN 107239485 A CN107239485 A CN 107239485A CN 201710253093 A CN201710253093 A CN 201710253093A CN 107239485 A CN107239485 A CN 107239485A
Authority
CN
China
Prior art keywords
partition table
subregion
operated
database
granularity
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
CN201710253093.2A
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 Xiaodu Information Technology Co Ltd
Original Assignee
Beijing Xiaodu Information Technology Co 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 Beijing Xiaodu Information Technology Co Ltd filed Critical Beijing Xiaodu Information Technology Co Ltd
Priority to CN201710253093.2A priority Critical patent/CN107239485A/en
Publication of CN107239485A publication Critical patent/CN107239485A/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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • 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

Abstract

The embodiment of the present application provides a kind of database operation method, apparatus and system.Method includes:According to pending data storehouse operation information, partition table to be operated and partition table process demand are determined;According to partition table process demand, the subregion granularity of dynamic adjustment partition table to be operated;Operation information corresponding data base manipulation statement in pending data storehouse is committed to the database belonging to partition table to be operated;Referred database performs data base manipulation statement in the partition table after the adjustment of subregion granularity.The embodiment of the present application can dynamically adjust the subregion granularity of partition table on demand, make scoring area granularity try one's best with the data area that database manipulation is influenceed to match, relevance between reduction reduction forward/backward operation in data area, and then the probability that subsequent operation waits previous action is reduced, improve overall execution efficiency.

Description

Database operation method, apparatus and system
Technical field
The application is related to database technical field, more particularly to a kind of database operation method, apparatus and system.
Background technology
In big data application scenarios, the tables of data (table) in database is generally divided into partition table and case of non-partitioned tables two Kind;Partition table is preferential using the time as subregion dimension, and can have multiple subregions.Data can be closed by partition table Disperseing for reason, so need to only be scanned when performing inquiry operation for partial-partition, it is not necessary to institute in tables of data Some data are all scanned, and are conducive to improving search efficiency.
The content of the invention
As shown in figure 1, being the system architecture diagram that client accesses database in the prior art.Database B shown in Fig. 1 includes Tri- tables of data of T1, T2 and T3, T1 and T2 are partition table, and P1 is a subregion in T1, and P2 is a subregion in T2; T3 is case of non-partitioned tables, and C1 is the example in T3, is related to certain field.Wherein, customer end A access database B flow is as follows:
Step 1:Customer end A is by Java databases connection (Java Data Base Connectivity, JDBC) or opens The interface protocols such as database connection (Open Database Connectivity, ODBC) are put, sets up and is connected with database B;
Step 2:Customer end A sends SQL (Structured Query Language, SQL) sentence To database B;
Step 3:Database B performs corresponding operating according to the SQL statement received, and returns to operating result to customer end A.
If customer end A receives the normal outcome of database B returns, database access flow terminates;If customer end A Fail to receive the normal outcome that database B is returned, then repeat above-mentioned steps 2-3, exceed setting until completing or retrying Duration or number of times prove an abortion.
In addition, in database, in order to ensure the uniformity and integrality of data, can typically use lock mechanism.If right Database carries out insertion operation, it is necessary to locking list exclusive lock, or needs if having subregion in table to associate subregion in locking list Exclusive lock.If being updated operation to database, need locking is row exclusive lock.
The use of exclusive lock can ensure the uniformity and integrality of data, at the same also can to insertion below, update or Deletion action is adversely affected, i.e., insertion, renewal or deletion action below need to wait the exclusive lock of above corresponding operating, Overall execution efficiency comparison is slow, and also subsequent query operation can be resulted in blockage using exclusive lock, influences search efficiency.So How using in the case of exclusive lock, the overall execution efficiency of database manipulation is improved, it is to be solved to be that database field has One big problem.
For above-mentioned technical problem, present inventor provides a solution, and central principle is:For being related to subregion The subregion granularity of the database manipulation of table, on demand dynamic adjustment partition table so that what subregion granularity was influenceed with database manipulation Data area is tried one's best matching so that exclusive lock only needs to lock necessary data, association of the reduction forward/backward operation in data area Property, and then the probability that subsequent operation waits previous action is reduced, improve overall execution efficiency.
Based on a kind of above-mentioned, database operation method of the embodiment of the present application offer, including:Operated according to pending data storehouse Information, determines partition table to be operated and partition table process demand;According to the partition table process demand, treated described in dynamic adjustment Operate the subregion granularity of partition table;Operation information corresponding data base manipulation statement in the pending data storehouse is committed to described Database belonging to partition table to be operated;Indicate that execution is described in partition table of the database after subregion granularity adjustment Data base manipulation statement.
It is described according to the partition table process demand, the dynamic adjustment subregion to be operated in an optional embodiment The subregion granularity of table, including:If the partition table process demand, which is subregion, refines demand, the partition table to be operated is refined Subregion granularity.
In an optional embodiment, the subregion granularity of the refinement partition table to be operated, including:Treated described in reducing The granularity of at least one existing subregion dimension of partition table is operated, to refine the subregion in the partition table to be operated;And/or, Increase new subregion dimension for the partition table to be operated, to refine the subregion in the partition table to be operated.
It is described according to the partition table process demand, the dynamic adjustment subregion to be operated in an optional embodiment The subregion granularity of table, in addition to:If the partition table process demand, which is subregion, merges demand, merge the partition table to be operated In subregion.
In an optional embodiment, the subregion merged in the partition table to be operated, including:Wait to grasp described in increase Make the granularity of at least one existing subregion dimension of partition table, to merge the subregion in the partition table to be operated;And/or, close And at least two existing subregion dimensions of the partition table to be operated, to merge the subregion in the partition table to be operated.
It is described according to pending data storehouse operation information in an optional embodiment, determine partition table to be operated and Partition table process demand, including:Table mark in the operation information of the pending data storehouse, determines the subregion to be operated Table;Data to be operated, action type and/or partition table processing parameter in the operation information of the pending data storehouse, really The fixed partition table process demand.
In an optional embodiment, data to be operated and behaviour in the operation information according to the pending data storehouse Make type, determine the partition table process demand, including:If the action type is updates, insertion or delete, and described waits to grasp The temperature for making data meets the temperature condition of setting, it is determined that the partition table process demand is that subregion refines demand;If described Action type is inquiry, or the temperature of the data to be operated does not meet the temperature condition of setting, it is determined that at the partition table Reason demand is that subregion merges demand.
It is described by the corresponding data base manipulation statement of pending data storehouse operation information in an optional embodiment The database belonging to the partition table to be operated is committed to, including:The database behaviour being currently executing according to the database Make sentence, count the running status of the database;If the running status meets the service requirement of setting, by the database Action statement is committed to the database.
In an optional embodiment, held in the partition table for indicating the database after subregion granularity adjustment The row data base manipulation statement, including:By the data to be operated in the operation information of the pending data storehouse, it is mapped to described In the respective partition in partition table after the adjustment of subregion granularity;The database is indicated in the respective partition, is performed described Data base manipulation statement.
In an optional embodiment, the data to be operated in the operation information by the pending data storehouse, mapping In the respective partition in partition table after being adjusted to the subregion granularity, including:Obtain the unique mark of the data to be operated; Under the subregion dimension of the lowest level of partition table after subregion granularity adjustment, the cryptographic Hash of the unique mark is calculated; The data to be operated are mapped in the corresponding subregion of the cryptographic Hash.
In an optional embodiment, the unique mark for obtaining the data to be operated, including:Wait to grasp described in obtaining Make the single major key of data, be used as the unique mark;Or, the MD5 values of the joint major key of the data to be operated are calculated, are made For the unique mark.
It is described according to pending data storehouse operation information in an optional embodiment, determine partition table to be operated and Before partition table process demand, in addition to:The notification message that order caching device is pushed, the buffer storage is used for caching The database manipulation message that each client of the database is submitted;According to the notification message, read from the buffer storage Take pending data storehouse operation information.
Correspondingly, the embodiment of the present application also provides a kind of database manipulation device, including:Determining unit, is treated for basis Process database operations information, determines partition table to be operated and partition table process demand;Adjustment unit, for according to described point Area's list processing demand, the subregion granularity of the dynamic adjustment partition table to be operated;Unit is submitted, for by the pending data Operation information corresponding data base manipulation statement in storehouse is committed to the database belonging to the partition table to be operated;Indicating member, is used The data base manipulation statement is performed in partition table of the instruction database after subregion granularity adjustment.
In an optional embodiment, the adjustment unit includes:Subelement is refined, for being needed in the subregion list processing When asking as subregion refinement demand, the subregion granularity of the partition table to be operated is refined.
In an optional embodiment, it is described refinement subelement specifically for:Reduce the partition table to be operated at least The granularity of one existing subregion dimension, to refine the subregion in the partition table to be operated;And/or, it is the subregion to be operated Table increases new subregion dimension, to refine the subregion in the partition table to be operated.
In an optional embodiment, the adjustment unit also includes:Merge subelement, in the subregion list processing When demand is that subregion merges demand, merge the subregion in the partition table to be operated.
In an optional embodiment, it is described merging subelement specifically for:Increase the partition table to be operated at least The granularity of one existing subregion dimension, to merge the subregion in the partition table to be operated;And/or, merge described to be operated point The existing subregion dimension of at least two of area's table, to merge the subregion in the partition table to be operated.
In an optional embodiment, the determining unit includes:Partition table determination subelement, for waiting to locate according to The table mark in database manipulation message is managed, the partition table to be operated is determined;Process demand determination subelement, for according to institute Data to be operated, action type and/or the partition table processing parameter in the operation information of pending data storehouse are stated, the subregion is determined List processing demand.
In an optional embodiment, the process demand determination subelement specifically for:If the action type is more Newly, insert or delete, and the temperature of the data to be operated meets the temperature condition of setting, determines the partition table process demand Demand is refined for subregion;If the action type is inquiry, or the temperature of the data to be operated does not meet the temperature bar of setting Part, determines that the partition table process demand merges demand for subregion.
In an optional embodiment, it is described submission unit specifically for:It is currently executing according to the database Data base manipulation statement, counts the running status of the database;If the running status meets the service requirement of setting, by institute State data base manipulation statement and be committed to the database.
In an optional embodiment, the indicating member includes:Subelement is mapped, for by the pending data storehouse Data to be operated in operation information, are mapped in the respective partition in the partition table after the subregion granularity adjustment;Indicate son Unit, for indicating the database in the respective partition, performs the data base manipulation statement.
In an optional embodiment, it is described mapping subelement specifically for:Obtain unique mark of the data to be operated Know;Under the subregion dimension of the lowest level of partition table after subregion granularity adjustment, the Hash of the unique mark is calculated Value;The data to be operated are mapped in the corresponding subregion of the cryptographic Hash.
In an optional embodiment, it is described mapping subelement specifically for:Obtain the single master of the data to be operated Key, is used as the unique mark;Or, the MD5 values of the joint major key of the data to be operated are calculated, unique mark is used as Know.
In an optional embodiment, the database manipulation device also includes:Receiving unit, for order caching device The notification message of push, the buffer storage is used to cache the database manipulation letter submitted using each client of the database Breath;Acquiring unit, for according to the notification message, reading the pending data storehouse operation letter from the buffer storage Breath.
Correspondingly, the embodiment of the present application also provides a kind of database operating system, including:Database and with the data The database manipulation device of storehouse connection;The database manipulation device, for according to pending data storehouse operation information, it is determined that treating Operate partition table and partition table process demand;According to the partition table process demand, the dynamic adjustment partition table to be operated Subregion granularity;Operation information corresponding data base manipulation statement in the pending data storehouse is committed to the database;With And indicate to perform the data base manipulation statement in partition table of the database after subregion granularity adjustment;The data Storehouse, is filled for receiving the data base manipulation statement that the database manipulation device is submitted, and according to the database manipulation The data base manipulation statement is performed in the instruction put, the partition table after subregion granularity adjustment.
In an optional embodiment, the Database Systems also include:Buffer storage, with the database manipulation device Connection, the database manipulation message that each client for caching using the database is submitted, and having database manipulation To the database manipulation device sending out notice message when information arrives;The database manipulation device is additionally operable to:Receive described The notification message that buffer storage is pushed, according to the notification message, reads the pending number from the buffer storage According to storehouse operation information.
The embodiment of the present application also provides a kind of electronic equipment, including memory and processor;The memory is used to store One or more computer instruction, wherein, one or more computer instruction is following to realize by the computing device Step;
According to pending data storehouse operation information, partition table to be operated and partition table process demand are determined;According to described Partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;By pending data storehouse operation information Corresponding data base manipulation statement is committed to the database belonging to the partition table to be operated;Indicate the database at described point The data base manipulation statement is performed in partition table after area's granularity adjustment.
The embodiment of the present application provides a kind of computer-readable storage medium, the database behaviour for storing above-described embodiment offer Make the computer software instructions used in device, it is above-mentioned that it, which includes the database operation method for being used for performing above-described embodiment offer, The program involved by database manipulation device that embodiment is provided.
In the embodiment of the present application, for the subregion of the database manipulation, on demand dynamic adjustment partition table that are related to partition table Granularity so that subregion granularity is tried one's best with the data area that database manipulation is influenceed and matched so that exclusive lock only needs locking necessary Data, reduction reduces relevance in data area between forward/backward operation, and then reduces subsequent operation and wait previous action Probability, improve overall execution efficiency.
Brief description of the drawings
Accompanying drawing described herein is used for providing further understanding of the present application, constitutes the part of the application, this Shen Schematic description and description please is used to explain the application, does not constitute the improper restriction to the application.In the accompanying drawings:
Fig. 1 accesses a kind of system architecture diagram of database for the client that prior art is provided;
The structural representation for the database operating system that Fig. 2 provides for the embodiment of the application one;
Data and the schematic diagram of subregion mapping process that Fig. 3 provides for the embodiment of the application one;
The structural representation for the database operating system that Fig. 4 provides for another embodiment of the application;
The schematic flow sheet for the database operation method that Fig. 5 provides for the another embodiment of the application;
The schematic flow sheet for the database operation method that Fig. 6 provides for the another embodiment of the application;
The structural representation for the database manipulation device that Fig. 7 provides for the another embodiment of the application;
The structural representation for the database manipulation device that Fig. 8 provides for the another embodiment of the application.
Embodiment
To make the purpose, technical scheme and advantage of the application clearer, below in conjunction with the application specific embodiment and Technical scheme is clearly and completely described corresponding accompanying drawing.Obviously, described embodiment is only the application one Section Example, rather than whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not doing Go out the every other embodiment obtained under the premise of creative work, belong to the scope of the application protection.
The structural representation for the database operating system that Fig. 2 provides for the embodiment of the application one.As shown in Fig. 2 the system System includes:Database 10 and the database manipulation device 20 being connected with database 10.Alternatively, database manipulation device 20 can It is connected with being set up by JDBC or ODBC with database 10.Alternatively, on implementing, database manipulation device 20 can be Optimize engine, but not limited to this.
Database 10, is mainly used in coming tissue, storage and management data according to the data structure of setting.Realizing structure On, database 10 includes at least one tables of data, and at least one tables of data is divided into partition table and the class of case of non-partitioned tables two.It is non- Partition table is mainly used in storage some growth rate are slow or variation frequency is relatively low data, such as some dimension dictionary tables, such as Sex, nationality, educational background, using (Aplication, APP) version, page etc..It is very fast that partition table is mainly used in storage growth rate Or the higher data of variation frequency, such as order data.Of course, it is possible to using different subregion dimensions, further by partition table Multiple subregions are divided into, such as first subregion dimension is the time, and second subregion dimension is administrative grade, the 3rd subregion dimension It is geographical position etc..Data can be reasonably disperseed by partitioning technique, while need to only be directed to portion when inquiry Divide subregion hit, without being all scanned to all data in partition table.
What Fig. 2 showed a kind of database 10 realizes structure, multiple tables of data such as including T1, T2 and T3, T1 and T2 for point Area's table, P1 is a subregion in T1, and P2 is a subregion in T2;T3 is case of non-partitioned tables, and C1 is the example in T3, is related to certain Individual field.
In addition, uniformity and integrality in order to ensure data, database 10 support lock mechanism.If an insertion into (insert) operate, then need to use exclusive lock locking data table, be partition table if tables of data and need if there are multiple subregions Subregion is locked using exclusive lock.If updating (update) operation, then exclusive lock locking data row is needed to use.If deleting Except (delete) operation, then exclusive lock locking data row is needed to use.The use of exclusive lock can ensure data uniformity and Integrality, while can also be adversely affected to insertion below, renewal or deletion action, i.e., insertion below, updates or deletes Division operation needs to wait the exclusive lock of above corresponding operating, and overall execution efficiency comparison is slow, and can also be to rear using exclusive lock Continuous inquiry operation results in blockage, and influences search efficiency.
For existing database, the subregion in partition table and partition table delimited in advance before the use, once Can not dynamically it be changed by delimiting.Database 10 and the main distinction of existing database in the present embodiment are:Support database Operation device 20 optimizes operation to the partition table in it.Correspondingly, database manipulation device 20 is also with using database 10 Each client 30 connect, be mainly used in the database manipulation message according to each client 30, in optimization database 10 Partition table.According to the difference of database 10, it would also vary from using the client 30 of database 10.For example, with data Then the use of the client 30 of database 10 can be the client that class applies that does shopping exemplified by storehouse 10 is the database of e-commerce field End and/or server, or shopping class website, or take out client and/or service end of class application etc..Alternatively, The database operating system of the present embodiment can include client 30, can not also include client 30.System shown in Figure 2 is to wrap Exemplified by including client 30, but it is not limited to this.
Database manipulation device 20 mainly includes to the process that the partition table in database 10 is optimized:According to pending Database manipulation message, determines partition table to be operated and partition table process demand;According to partition table process demand, dynamic adjustment The subregion granularity of partition table to be operated;Operation information corresponding data base manipulation statement in pending data storehouse is committed to database Data base manipulation statement is performed in 10, and partition table of the referred database 10 after the adjustment of subregion granularity.In the present embodiment, To simplify description, the database manipulation message that client is submitted is referred to as pending data storehouse operation information, will be objective in database Family end needs the partition table (partition table that i.e. pending data storehouse operation information is related to) operated to be referred to as partition table to be operated.
Correspondingly, database 10 also needs the operation of response database operation device 20, is primarily referred to as receiving database manipulation The data base manipulation statement that device 20 is submitted, and according to the instruction of database manipulation device 20, point after the adjustment of subregion granularity Data base manipulation statement is performed in area's table.
What deserves to be explained is, it is contemplated that the data growth rate stored in case of non-partitioned tables is relatively low compared with slow or variation frequency, It is relatively low generally directed to the operating frequency of case of non-partitioned tables, therefore the present embodiment pays close attention to the optimization to partition table.
As seen from the above analysis, in the database operating system of the present embodiment, in the client and number using database According to database manipulation device is increased between storehouse, when client needs to perform database and operated, by database manipulation device root According to the database manipulation message of client, the partition table to be operated and partition table process demand in database are determined, then base In partition table process demand, dynamic changes the subregion granularity of partition table to be operated, can so ensure subregion granularity and database The influenceed data area of operation is tried one's best matching so that exclusive lock only needs to lock necessary data, reduces forward/backward operation in data Relevance in scope, and then the probability that subsequent operation waits previous action is reduced, improve overall execution efficiency.
In above-described embodiment or following embodiments, database manipulation device 20, which needs to be operated according to pending data storehouse, to be believed Breath, determines partition table to be operated and partition table process demand.Alternatively, pending data storehouse operation information includes carrying out data Various information needed for the operation of storehouse, such as mark (referred to as table mark), data to be operated, the action type of partition table to be operated (such as updating, deleting, inserting or inquiring about) and subregion field.
Based on above-mentioned, database manipulation device 20 can be identified according to the table in the operation information of pending data storehouse, it is determined that Partition table to be operated, i.e., it is partition table to be operated that described table, which identifies corresponding partition table,.
In a kind of optional embodiment, database manipulation device 20 can be according in the operation information of pending data storehouse Data and action type to be operated, determine partition table process demand.
Alternatively, if action type to update, insertion or delete, and the temperature of data to be operated meets the temperature bar of setting Part, then database manipulation device 20 can determine partition table process demand for subregion refine demand.According to application scenarios or application The difference of demand, temperature condition can be different.For example, temperature condition can be at the appointed time in the range of, such as nearest 3 days or Nearest 5 hours, renewal frequency was more than setting renewal frequency threshold value.Based on this, if data to be operated are nearest 3 days or nearest 5 small When it is interior, renewal frequency is more than the data of setting renewal frequency threshold value, and is to update, delete to the action types of the data to be operated Remove or insert, then can determine to need to refine the subregion granularity of the partition table where data to be operated, i.e. subregion refinement demand.
Alternatively, if action type is inquiry, or the temperature of data to be operated does not meet the temperature condition of setting, then counts It can determine that partition table process demand merges demand for subregion according to storehouse operation device 20.The subregion granularity of partition table is refined, to inserting Enter, update or deletion action is favourable, but for inquiry operation, subarea-scanning number can be increased, increase data aggregate operation is led Search efficiency is caused to decline.For inquiry operation, the quantity of subregion is more few better actually in partition table, therefore can be in operation When type is inquiry, determine that partition table process demand merges demand for subregion.In addition, for the relatively low data of temperature, entering to it Row updates or the frequency of deletion action is relatively low, mutually opposes that its frequency for carrying out inquiry operation can be higher, this is required in partition table The quantity of subregion is more few better, will can be stored in these data sets in larger subregion, reduced multi partition and inquiry is grasped Make the adverse effect caused.Therefore, when the temperature of data to be operated does not meet the temperature condition of setting, it may be determined that Partition table process demand is that subregion merges demand.
Further, pending data storehouse operation information can also include partition table processing parameter, the subregion list processing ginseng Number major embodiment identifies the process demand of identified partition table to table.Based on this, database manipulation device 20 can be according to treating Partition table processing parameter in process database operations information, determines partition table process demand.
Alternatively, the partition table processing parameter can include time and the subregion refinement side for performing subregion Refinement operation Formula.Based on this, database manipulation device 20 can determine the process demand to partition table to be operated by partition table processing parameter It is subregion refinement demand.
Alternatively, the partition table processing parameter can include time and the subregion merging side for performing subregion union operation Formula.Based on this, database manipulation device 20 can determine the process demand to partition table to be operated by partition table processing parameter It is that subregion merges demand.
Alternatively, the partition table processing parameter can include time, the subregion refinement side for performing subregion Refinement operation simultaneously Formula, the time of execution subregion union operation and subregion merging mode after subregion Refinement operation is performed.Based on this, database Operation device 20 can determine it is that first subregion refines demand to the process demand of partition table to be operated by partition table processing parameter, Rezone merging demand.
Exemplified by updating operation, the renewal operation can be real-time update operation or update operation offline.Real-time update Operation need to ensure after data source header is changed, and can embody in time in database.When offline renewal operation, It is updated generally be directed to the high-volume data in historical events, under the scene for frequently occurring in data backtracking.In the scene Under, pending data storehouse operation information can include partition table processing parameter, be first carried out for referred database operation device 20 Subregion Refinement operation, then specify execution subregion union operation after the time.
In above-described embodiment or following embodiments, it is determined that after partition table process demand, database manipulation device 20 Need to be according to partition table process demand, the subregion granularity of dynamic adjustment partition table to be operated.Alternatively, however, it is determined that subregion list processing Demand is that subregion refines demand, then database manipulation device 20 can refine the subregion granularity of partition table to be operated;Correspondingly, if The partition table process demand of determination is that subregion merges demand, then database manipulation device 20 can merge in partition table to be operated Subregion.
Wherein, database manipulation device 20 refine partition table to be operated subregion granularity can use but be not limited to it is following extremely A kind of few embodiment:
First way:The granularity of at least one existing subregion dimension of partition table to be operated is reduced, it is to be operated to refine Subregion in partition table.Wherein, existing subregion dimension refers to before the subregion granularity of partition table to be operated is refined, to be operated point The subregion dimension that area's table has been used in subregion.Preferably, existing subregion dimension here is primarily referred to as most starting waiting to grasp Make partition table and divide the subregion dimension used during subregion.
For example, when creating partition table to be operated, the subregion of partition table to be operated delimited using time dimension, now the time The granularity of dimension is annual, i.e., the data storage of each year is in a subregion.The granularity of the time dimension is thicker, then database Operation device 20 can reduce the granularity of time dimension, be refined as being monthly a granularity, i.e., data storage monthly is in one In subregion, this is further subdivided into 12 subregions equivalent to by an original subregion, and subregion granularity is smaller, in each subregion Data volume reduce, it means that the data area that influences is reduced during exclusive lock locking subregion.
Further, if the existing subregion dimension of partition table to be operated has multiple, database manipulation device 20 can be therefrom The one or more existing subregion dimensions of selection, to the existing subregion dimension of each selection, further reduce its granularity.Preferably, There is certain hierarchical relationship, i.e., each subregion dimension has a subregion rank between subregion dimension, based on this, database is grasped The minimum existing subregion dimension of rank in the existing subregion dimension of partition table to be operated can be selected by making device 20, further be reduced The granularity of the minimum existing subregion dimension of the rank.For example, the order according to rank from high to low, subregion to be operated has divided Area's dimension is followed successively by time dimension and geographic area dimension, then can further be reduced geographical with prioritizing selection geographic area dimension The granularity of region dimension, such as the granularity of original region class (as North China, south China, Central China) is contracted into the granularity of City-level (such as Beijing, Shanghai, Tianjin).
The second way:Increase new subregion dimension for partition table to be operated, to refine the subregion in partition table to be operated. Wherein, new subregion dimension refers to that before the subregion granularity of partition table to be operated is refined partition table to be operated is in subregion fashion Untapped subregion dimension.Preferably, new subregion dimension can further be increased under the minimum existing subregion dimension of rank Degree.
For example, when creating partition table to be operated, the subregion of partition table to be operated delimited using time dimension, now the time The granularity of dimension is annual, i.e., the data storage of each year is in a subregion.Based on this, database manipulation device 20 can be Partition table to be operated increases new subregion dimension, such as band of position dimension, you can with by annual data further according to position Region division is put, the data storage in annual interior diverse location region is in the data in a subregion, such as 2015 location A regions Data storage in the first subregion, B location region in 2015 is stored in the second subregion, this is equivalent to by an original subregion The subregion in correspondence diverse location region is further subdivided into, subregion granularity is smaller, and the data volume in each subregion is reduced, this Mean that exclusive lock locks the data area influenceed during subregion and reduced.
Further, database manipulation device 20 can increase one or more new subregion dimensions for partition table to be operated. If the multiple new subregion dimensions of increase, can successively increase according to the subregion rank of setting.
What deserves to be explained is, database manipulation device 20 can be individually using the existing subregion dimension for reducing partition table to be operated The mode of the granularity of degree, be either individually adopted as partition table to be operated increase new subregion dimension mode or can also be same Shi Caiyong two ways, reaches the purpose for the subregion granularity for refining partition table to be operated.
Wherein, the subregion that database manipulation device 20 merges in partition table to be operated can use but be not limited to it is following at least A kind of embodiment:
First way:Increase the granularity of at least one existing subregion dimension of partition table to be operated, it is to be operated to merge Subregion in partition table.Wherein, existing subregion dimension refers to before the subregion in merging partition table to be operated, subregion to be operated The subregion dimension that table has been used in subregion.Preferably, existing subregion dimension here is primarily referred to as most starting to be to be operated Partition table divides the subregion dimension used during subregion.
For example, before the subregion in merging partition table to be operated, point of partition table to be operated delimited using time dimension Area, now the granularity of time dimension is that monthly, i.e., data storage monthly is in a subregion.Database manipulation device 20 can be with Increase the granularity of time dimension, be increased to it is annual for a granularity, i.e., annual data storage in a subregion, this equivalent to 12 original subregions are merged into a subregion, subregion granularity becomes big, and the data volume in each subregion is increased.
The second way:Merge at least two existing subregion dimensions of partition table to be operated, to merge partition table to be operated In subregion.Wherein, existing subregion dimension refers to before the subregion in merging partition table to be operated, and partition table to be operated is dividing The subregion dimension used during area.Alternatively, existing subregion dimension here can refine the subregion of partition table to be operated Increased subregion dimension during granularity.
For example, before the subregion in merging partition table to be operated, divided and treated using time dimension and geographic area dimension The subregion of partition table is operated, and the subregion rank of time dimension manages the subregion rank in region above Ground.Database manipulation device 20 Geographic area dimension and time dimension can be merged into a dimension, for example, merge into time dimension, this was equivalent to by originally The corresponding subregion of different geographic regions merges into the subregion of a time dimension, and subregion granularity becomes big, the number in each subregion Increased according to amount.
Preferably, database manipulation device 20 is when merging at least two existing subregion dimension of partition table to be operated, if The subregion rank of at least two existing subregion dimensions is different, the other subregion dimension of relatively low partition level can be merged into higher subregion In the subregion dimension of rank, in other words, the other subregion dimension of relatively low partition level can be taken away, only retains higher subregion rank Subregion dimension.
In above-described embodiment or following embodiments, after the dynamically subregion granularity of adjustment partition table to be operated, data Operation information corresponding data base manipulation statement in pending data storehouse need to be committed to database 10 by storehouse operation device 20.The number It can be SQL (Structured Query Language, SQL) sentence according to storehouse action statement, but be not limited to This.Alternatively, database manipulation device 20 can splice generation SQL statement according to pending data storehouse operation information.
Alternatively, database manipulation device 20 can plan as a whole the operations all to database 10, unlike making in the prior art Operation with the client 30 of database 10 like that each other to database 10 is all independent, so database manipulation device 20 can To be apparent from the data base manipulation statement that database 10 is currently executing, and then can be current according to database 10 The data base manipulation statement of execution, the running status of staqtistical data base 10, for example whether there is delay, whether handling capacity is excessively high; It is then possible to according to the running status of database 10, adaptively submit data base manipulation statement to database 10.If for example, The running status of database 10 meets the service requirement of setting, throughput threshold and/or sound of such as handling capacity less than setting The time delay threshold value of setting should be less than time delay, then data base manipulation statement can be committed to database 10.If conversely, The running status of database 10 is unsatisfactory for the service requirement of setting, throughput threshold of such as handling capacity greater than or equal to setting And/or response time is greater than or equal to the time delay threshold value of setting, then it can reduce to database 10 and submit database The frequency of action statement, or can postpone to submit data base manipulation statement to database 10, reduce the processing pressure of database 10 Power so that database 10, which is maintained at, preferably handles state.
In above-described embodiment or following embodiments, database manipulation device 20 to database 10 except submitting database behaviour Make outside sentence, also need to perform the data base manipulation statement in partition table of the referred database 10 after the adjustment of subregion granularity. A kind of embodiment that the referred database 10 of database manipulation device 20 performs data base manipulation statement includes:Database manipulation is filled 20 are put by the data to be operated in the operation information of pending data storehouse, is mapped to corresponding in the partition table after the adjustment of subregion granularity In subregion;Referred database 10 performs the data base manipulation statement in the respective partition.
The above-mentioned process being mapped to data to be operated in respective partition in partition table after the adjustment of subregion granularity is actual On be that after the subregion granularity of partition table to be operated is adjusted, the process of assignment is carried out to the subregion in partition table.Assignment procedure Following two situations can be divided into:
The first situation:Data to be operated have single major key in itself, and such as field id can from increasing and not be repeatedly in order Sky, thus can as data to be operated single major key.For the data to be operated with single major key, its can be obtained single Major key is used as unique mark;Under the subregion dimension of the lowest level of partition table after the adjustment of subregion granularity, unique mark is calculated Hash (hash) value of knowledge, for example, can calculate cryptographic Hash by mode%n;Data to be operated are mapped to the cryptographic Hash pair In the subregion answered.
Second of situation:Data to be operated by multiple fields in itself without single major key, it is necessary to join together to be used as Joint major key is with unique mark data to be operated, and the numbering of the vegetable id joint third-party platforms of such as third-party platform can conduct Joint major key.For the data to be operated with joint major key, the MD5 values of its joint major key can be obtained as unique mark; Under the subregion dimension of the lowest level of partition table after the adjustment of subregion granularity, Hash (hash) value of the unique mark is calculated, For example cryptographic Hash can be calculated by mode%n;Data to be operated are mapped in the corresponding subregion of the cryptographic Hash.
In above-mentioned expression formula mode%n, n is datum, the subregion that can be included under the subregion dimension for representing lowest level The maximum of quantity.N can based on experience value or experiment be obtained ahead of time.
Partition table example with reference to shown in Fig. 3, is illustrated to above-mentioned mapping process.The lowermost level of partition table shown in Fig. 3 Other subregion dimension is mod dimensions, and the other subregion dimension of upper level is time dimension, and the granularity of time dimension is day.In Fig. 3 In partition table shown in left side, due to not yet data storage, therefore do not occur mod subregions, on October 10th, 1 corresponding One subregion, on October 11st, 2016 corresponding second subregion, on October 12nd, 2016 corresponding 3rd subregion.Then, when needing to be grasped Need to be mapped to below some mod subregion as data, can be according to expression formula mode%n, where calculating data to be operated Mod subregions, the partition table as shown in right side in Fig. 3.In the partition table on the right side of Fig. 3, the first subregion includes two mod subregions, Second subregion includes 3 mod subregions, and the 3rd subregion includes more than 3 mod subregions.From above-mentioned, by higher level's subregion Split for multiple subordinate's subregions, it is possible to reduce the data volume of each subregion, reduce subsequent operation and operate phase with previous action With the probability of subregion, while reducing the data volume of exclusive lock locking, adverse effect of the exclusive lock to subsequent operation is reduced, is carried High overall execution efficiency.
The structural representation for the database operating system that Fig. 4 provides for another embodiment of the application.With system shown in Figure 2 phase Than, system shown in Figure 3 except including:Database 10, the database manipulation device 20 being connected with database 10 and client 30 Outside, in addition to:The buffer storage 40 being connected with database manipulation device 20.
Buffer storage 40 is located between each client 30 and database manipulation device 20 using database 10, can be used for The database manipulation message of each client 30 submission is cached, in performing optimization operating process in database manipulation device 20, Ensure that database manipulation message will not be lost.Wherein, between database manipulation device 20 and buffer storage 40, and client 30 The communication protocol that can be supported between buffer storage 40 using buffer storage 40 sets up communication connection.
Database manipulation device 20 can subscribe to Push Service in advance to buffer storage 40.Based on this, buffer storage 40 exists After the database manipulation message for receiving the submission of client 30, it can be sent a notification message to database manipulation device 20.It is right For database manipulation device 20, the notification message that can be pushed with order caching device 40;According to the notification message, from caching Pending data storehouse operation information is read in device 40.Still optionally further, buffer storage 40 can be using redundancy backup storage Mode, the database manipulation message that storage client 30 is submitted, can so ensure the reliability of database manipulation message.
Alternatively, on implementing, buffer storage 40 can be message-oriented middleware, for example can using kafka, Hbase or apacheMQ etc. is realized.Wherein, Kafka is a kind of distributed post subscription message system of high-throughput.HBase It is a PostgreSQL database distributed, towards row.ApacheMQ is the message-oriented middleware increased income.
Because the presence of buffer storage 40, for client 30, database manipulation is changed into from the original method of synchronization Asynchronous system, it is not necessary to wait database returning result, is conducive to improving the execution efficiency of client 30.Here the method for synchronization Refer to that client 30 after database manipulation message is submitted, can only wait database 10 to return to result, only receiving Follow-up work could be performed after the result returned to database 10.Here asynchronous system refers to that client 30 is submitting database After operation information, the result of the return of database 10 will not be instantly available, but follow-up work can be performed.
In addition, because by the presence of buffer storage 40, with reference to the control of database operation device 20, being submitted to client 30 Deletion, renewal, insertion or inquiry operation can enter row buffering, be conducive to mitigate database 10 processing load, improve data The stability in storehouse 10.
Based on above-mentioned database operating system, the another embodiment of the application provides a kind of database operation method, the side The executive agent of method can be database manipulation device, but not limited to this.As shown in figure 5, methods described includes:
501st, according to pending data storehouse operation information, partition table to be operated and partition table process demand are determined.
502nd, according to partition table process demand, the subregion granularity of dynamic adjustment partition table to be operated.
503rd, operation information corresponding data base manipulation statement in pending data storehouse is committed to belonging to partition table to be operated Database.
504th, data base manipulation statement is performed in partition table of the referred database after subregion granularity adjustment.
Referring to step 501, pending data storehouse operation information mainly includes database is carried out to operate required information, one As by using database client submit.That is, when client, which needs to perform database, to be operated, database manipulation can be submitted Information, for describing to perform database the essential information needed for operation, for example, needs mark, the subregion word of the partition table of operation Section, action type, data to be operated etc..According to pending data storehouse operation information, on the one hand it is known that needing what is operated Partition table, partition table referred to as to be operated, on the other hand it is known that needing which kind of operation, letter carried out for partition table to be operated Referred to as partition table process demand.
, can be according to subregion before database manipulation is carried out based on pending data storehouse operation information referring to step 502 List processing demand, the subregion granularity of dynamic adjustment partition table to be operated.The subregion granularity of partition table to be operated can be for example refined, Or the subregion in merging partition table to be operated, to increase the subregion granularity of partition table to be operated.
Referring to step 503 and 504, after the dynamically subregion granularity of adjustment partition table to be operated, by pending data storehouse The corresponding database statement of operation information is committed in database, and partition table of the referred database after the adjustment of subregion granularity and held The row database statement, so as to complete database manipulation.
In the present embodiment, when needing to perform operation to database, according to pending data storehouse operation information, number is determined According to the partition table to be operated and partition table process demand in storehouse, partition table process demand is next based on, dynamic changes to be operated The subregion granularity of partition table, can so ensure that subregion granularity is tried one's best with the data area that database manipulation is influenceed and match, make Obtaining exclusive lock only needs to lock necessary data, relevance of the reduction forward/backward operation in data area, and then reduces subsequent operation The probability of previous action is waited, overall execution efficiency is improved.
The schematic flow sheet for the database operation method that Fig. 6 provides for the another embodiment of the application.The execution of methods described Main body can be database manipulation device, but not limited to this.As shown in fig. 6, methods described includes:
601st, the notification message that order caching device is pushed, the buffer storage is used to cache each client using database Hold the database manipulation message submitted.
602nd, according to notification message, pending data storehouse operation information is read from buffer storage.
603rd, according to pending data storehouse operation information, partition table to be operated and partition table process demand are determined.
604th, identification partition table process demand is that subregion refinement demand or subregion merge demand;If the subregion list processing Demand is subregion refinement demand, then performs step 605;If the partition table process demand, which is subregion, merges demand, step is performed Rapid 606.
605th, the subregion granularity of partition table to be operated is refined, and continues executing with step 607.
606th, merge the subregion in partition table to be operated, and continue executing with step 607.
607th, operation information corresponding data base manipulation statement in pending data storehouse is committed to belonging to partition table to be operated Database, and continue executing with step 608.
608th, indicate to perform the database manipulation language in partition table of the database after subregion granularity adjustment Sentence.
Referring to step 601, in the present embodiment, the database manipulation message that client is submitted is buffered by buffer storage. For buffer storage, whenever the database manipulation message of client submission is received, send logical to database manipulation device Know message.Alternatively, on implementing, buffer storage can be message-oriented middleware, for example can using kafka, Hbase or ApacheMQ etc. is realized.The notification message that database manipulation device order caching device is sent;Upon receipt of the notification message, may be used To read pending data storehouse operation information from buffer storage;Then the operation described in step 603 is performed, to be operated point is determined Area's table and partition table process demand.
When identifying partition table process demand for refinement partition requirements, the subregion granularity of refinement partition table to be operated is performed Operation;When identifying that partition table process demand merges demand for subregion, execution merges the subregion in partition table to be operated Operation.
Afterwards, by the corresponding data base manipulation statement of pending data storehouse operation information, such as SQL statement is committed to data Storehouse, and referred database performs the data base manipulation statement in the partition table after the adjustment of subregion granularity, completes database behaviour Make.
Alternatively, after data base manipulation statement is performed, database can be by database manipulation device to client Return to implementing result.
In the present embodiment, the database manipulation message submitted by buffer unit buffer client, in database manipulation During device refines the subregion in the subregion granularity or merging partition table to be operated of partition table to be operated, it is ensured that data Storehouse operation information will not lose;Furthermore it is possible to which database manipulation is changed into asynchronous from original synchronization, be conducive to improving client Execution efficiency;Furthermore, row buffering can be entered to the operation in feeding database, be conducive to mitigating the processing load of database, Improve the stability of database.
In an optional embodiment, step 605, that is, refining the subregion granularity of partition table to be operated can use with lower section Formula:
The granularity of at least one existing subregion dimension of partition table to be operated is reduced, to refine point in partition table to be operated Area;And/or, it is that partition table to be operated increases new subregion dimension, to refine the subregion in partition table to be operated.Each side concerned's formula Detailed description, reference can be made to the corresponding description in said system embodiment, will not be repeated here.
In an optional embodiment, step 606, that is, merging the subregion in partition table to be operated can use with lower section Formula:
Increase the granularity of at least one existing subregion dimension of partition table to be operated, to merge point in partition table to be operated Area;And/or, merge at least two existing subregion dimensions of partition table to be operated, to merge the subregion in partition table to be operated.Have The detailed description of each mode is closed, reference can be made to the corresponding description in said system embodiment, will not be repeated here.
In an optional embodiment, step 501 or 603, that is, according to pending data storehouse operation information, is determined to be operated Partition table and partition table process demand, including:
Table mark in the operation information of pending data storehouse, determines partition table to be operated;
Data to be operated, action type and/or partition table processing parameter in the operation information of pending data storehouse, really The fixed partition table process demand.
, can be according to the data to be operated in the operation information of pending data storehouse and operation class in an optional embodiment Type, determines partition table process demand.If specifically, the action type is updates, insertion or delete, and data to be operated Temperature meet the temperature condition of setting, it is determined that the partition table process demand is that subregion refines demand.If the operation class Type is inquiry, or the temperature of the data to be operated does not meet the temperature condition of setting, it is determined that the partition table process demand Merge demand for subregion.
In above-described embodiment or following embodiments, step 503 or 607, i.e., by pending data storehouse operation information correspondence Data base manipulation statement be committed to database belonging to partition table to be operated, including:
The data base manipulation statement being currently executing according to database, the running status of staqtistical data base;If running shape State meets the service requirement of setting, and data base manipulation statement is committed into database.
In an optional embodiment, point of step 504 or 608, i.e. referred database after subregion granularity adjustment Data base manipulation statement is performed in area's table, including:
By the data to be operated in the operation information of pending data storehouse, the partition table after the subregion granularity adjustment is mapped to In respective partition in;Referred database performs the data base manipulation statement in the respective partition.
Further, the data to be operated in the above-mentioned operation information by pending data storehouse, are mapped to the subregion granularity and adjust In the respective partition in partition table after whole, including:
Obtain the unique mark of data to be operated;The subregion of the lowest level of partition table after subregion granularity adjustment Under dimension, the cryptographic Hash of the unique mark is calculated;By the data to be operated, the corresponding subregion of the cryptographic Hash is mapped to It is interior.
Further, the unique mark of above-mentioned acquisition data to be operated, including:The single major key of data to be operated is obtained, It is used as unique mark;Or, the MD5 values of the joint major key of data to be operated are calculated, unique mark is used as.
It should be noted that the executive agent that above-described embodiment provides each step of method may each be same equipment, Or, this method is also used as executive agent by distinct device.Such as, the executive agent of step 501 to step 503 can be equipment A;Again such as, step 501 and 502 executive agent can be device A, and step 503 and 504 executive agent can be equipment B; Etc..
The structural representation for the database manipulation device that Fig. 7 provides for the another embodiment of the application.As shown in fig. 7, data Storehouse operation device includes:Determining unit 71, adjustment unit 72, submission unit 73 and indicating member 74.
Determining unit 71, for according to pending data storehouse operation information, determining at partition table to be operated and partition table Reason demand.
Adjustment unit 72, for the partition table process demand determined according to determining unit 71, dynamic adjustment determining unit 71 The subregion granularity of the partition table to be operated determined.
Unit 73 is submitted, it is to be operated for operation information corresponding data base manipulation statement in pending data storehouse to be committed to Database belonging to partition table.
Indicating member 74, is performed for referred database in the partition table that adjustment unit 72 carries out after subregion granularity adjustment The data base manipulation statement for submitting unit 73 to submit.
In an optional embodiment, as shown in figure 8, one kind of adjustment unit 72 realizes that structure includes:Refine subelement 721.Subelement 721 is refined, for when partition table process demand is that subregion refines demand, refining the subregion of partition table to be operated Granularity.
In an optional embodiment, refinement subelement 721 specifically for:Reduce partition table to be operated at least one There is the granularity of subregion dimension, to refine the subregion in partition table to be operated;And/or, it is that partition table to be operated increases new subregion Dimension, to refine the subregion in partition table to be operated.
In an optional embodiment, as shown in figure 8, one kind of adjustment unit 72 realizes that structure also includes:Merge son single Member 722.
Merge subelement 722, for when partition table process demand is that subregion merges demand, merging in partition table to be operated Subregion.
In an optional embodiment, merge subelement 722 specifically for:Increase partition table to be operated at least one There is the granularity of subregion dimension, to merge the subregion in partition table to be operated;And/or, merge at least two of partition table to be operated Existing subregion dimension, to merge the subregion in partition table to be operated.
In an optional embodiment, as shown in figure 8, one kind of determining unit 71 realizes that structure includes:Partition table is determined Subelement 711 and process demand determination subelement 712.
Partition table determination subelement 711, for the table mark in the operation information of pending data storehouse, it is determined that described treat Operate partition table.
Process demand determination subelement 712, for the data to be operated in the operation information of pending data storehouse, operation Type and/or partition table processing parameter, determine partition table process demand.
In an optional embodiment, process demand determination subelement 712 specifically for:If action type is renewal, inserted Enter or delete, and the temperature of data to be operated meets the temperature condition of setting, determining that partition table process demand refines for subregion needs Ask;If action type is inquiry, or the temperature of data to be operated does not meet the temperature condition of setting, determines partition table process demand Merge demand for subregion.
In an optional embodiment, submit unit 73 specifically for:The database being currently executing according to database Action statement, the running status of staqtistical data base;If running status meets the service requirement of setting, data base manipulation statement is carried Hand over to database.
In an optional embodiment, as shown in figure 8, one kind of indicating member 74 realizes that structure includes:Map subelement 741 and indicate subelement 742.
Subelement 741 is mapped, for by the data to be operated in the operation information of pending data storehouse, being mapped to subregion granularity In the respective partition in partition table after adjustment.
Subelement 742 is indicated, for referred database in the respective partition, data base manipulation statement is performed.
In an optional embodiment, mapping subelement 741 specifically for:Obtain unique mark of the data to be operated Know;Under the subregion dimension of the lowest level of partition table after subregion granularity adjustment, the cryptographic Hash of unique mark is calculated;Will Data to be operated, are mapped in the corresponding subregion of the cryptographic Hash.
In an optional embodiment, mapping subelement 741 specifically for:The single major key of data to be operated is obtained, is made For the unique mark;Or, the MD5 values of the joint major key of data to be operated are calculated, unique mark is used as.
In an optional embodiment, as shown in figure 8, the database manipulation device also includes:Receiving unit 75 and obtain Take unit 76.
Receiving unit 75, the notification message pushed for order caching device, the buffer storage uses number for caching The database manipulation message submitted according to each client in storehouse.
Acquiring unit 76, for the notification message received according to receiving unit 75, reads pending from buffer storage Database manipulation message.
Alternatively, on implementing, above-mentioned buffer storage can be message-oriented middleware, for example can using kafka, Hbase or apacheMQ etc. is realized.
Alternatively, the database manipulation device that the present embodiment is provided can be realized as optimization engine, but be not limited to This.
The database manipulation device that the present embodiment is provided, can perform the flow that above method embodiment is provided, and can be real The institute of database manipulation device is functional in existing system embodiment, will not be repeated here, refers to the description of previous embodiment.
The database manipulation device that the present embodiment is provided, can be directed to the database manipulation for being related to partition table, and dynamic is adjusted on demand The subregion granularity of whole partition table so that subregion granularity is tried one's best with the data area that database manipulation is influenceed and matched so that exclusive Lock only needs to lock the relevance between necessary data, reduction reduction forward/backward operation in data area, and then reduces follow-up behaviour Make the probability of wait previous action, improve overall execution efficiency.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer program Product.Therefore, the present invention can be using the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware Apply the form of example.Moreover, the present invention can be used in one or more computers for wherein including computer usable program code The computer program production that usable storage medium is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.) The form of product.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program product Figure and/or block diagram are described.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagram Journey and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided The processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce A raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for real The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which is produced, to be included referring to Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that in meter Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, thus in computer or The instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one The step of function of being specified in individual square frame or multiple square frames.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net Network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory (RAM) and/or The forms such as Nonvolatile memory, such as read-only storage (ROM) or flash memory (flash RAM).Internal memory is computer-readable medium Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method Or technology come realize information store.Information can be computer-readable instruction, data structure, the module of program or other data. The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moved State random access memory (DRAM), other kinds of random access memory (RAM), read-only storage (ROM), electric erasable Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only storage (CD-ROM), Digital versatile disc (DVD) or other optical storages, magnetic cassette tape, the storage of tape magnetic rigid disk or other magnetic storage apparatus Or any other non-transmission medium, the information that can be accessed by a computing device available for storage.Define, calculate according to herein Machine computer-readable recording medium does not include temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
It should also be noted that, term " comprising ", "comprising" or its any other variant are intended to non-exclusionism Comprising so that process, method, commodity or equipment including a series of key elements are not only including those key elements, but also wrap Include other key elements being not expressly set out, or also include for this process, method, commodity or equipment intrinsic want Element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that wanted including described Also there is other identical element in process, method, commodity or the equipment of element.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer program product. Therefore, the application can be using the embodiment in terms of complete hardware embodiment, complete software embodiment or combination software and hardware Form.Deposited moreover, the application can use to can use in one or more computers for wherein including computer usable program code The shape for the computer program product that storage media is implemented on (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.) Formula.
Embodiments herein is the foregoing is only, the application is not limited to.For those skilled in the art For, the application can have various modifications and variations.It is all any modifications made within spirit herein and principle, equivalent Replace, improve etc., it should be included within the scope of claims hereof.
The embodiment of the present application discloses A1, a kind of database operation method, including:
According to pending data storehouse operation information, partition table to be operated and partition table process demand are determined;
According to the partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;
Operation information corresponding data base manipulation statement in the pending data storehouse is committed to the partition table to be operated Affiliated database;
Indicate to perform the data base manipulation statement in partition table of the database after subregion granularity adjustment.
It is described according to the partition table process demand, the dynamic adjustment subregion to be operated in A2, the method as described in A1 The subregion granularity of table, including:
If the partition table process demand, which is subregion, refines demand, the subregion granularity of the partition table to be operated is refined.
In A3, the method as described in A2, the subregion granularity of the refinement partition table to be operated, including:
The granularity of at least one existing subregion dimension of the partition table to be operated is reduced, to refine the subregion to be operated Subregion in table;And/or
Increase new subregion dimension for the partition table to be operated, to refine the subregion in the partition table to be operated.
It is described according to the partition table process demand, the dynamic adjustment subregion to be operated in A4, the method as described in A1 The subregion granularity of table, in addition to:
If the partition table process demand, which is subregion, merges demand, merge the subregion in the partition table to be operated.
In A5, the method as described in A4, the subregion merged in the partition table to be operated, including:
Increase the granularity of at least one existing subregion dimension of the partition table to be operated, to merge the subregion to be operated Subregion in table;And/or
Merge at least two existing subregion dimensions of the partition table to be operated, to merge in the partition table to be operated Subregion.
It is described according to pending data storehouse operation information in A6, the method as described in A1, determine partition table to be operated and Partition table process demand, including:
Table mark in the operation information of the pending data storehouse, determines the partition table to be operated;
Data to be operated, action type and/or subregion list processing ginseng in the operation information of the pending data storehouse Number, determines the partition table process demand.
In A7, the method as described in A6, data to be operated in the operation information according to the pending data storehouse and Action type, determines the partition table process demand, including:
If the action type is updates, insertion or delete, and the temperature of the data to be operated meets the temperature of setting Condition, it is determined that the partition table process demand is that subregion refines demand;
If the action type is inquiry, or the temperature of the data to be operated does not meet the temperature condition of setting, then really The fixed partition table process demand is that subregion merges demand.
It is described by the corresponding data of pending data storehouse operation information in A8, the method as described in any one of A1-A7 Storehouse action statement is committed to the database belonging to the partition table to be operated, including:
The data base manipulation statement being currently executing according to the database, counts the running status of the database;
If the running status meets the service requirement of setting, the data base manipulation statement is committed to the data Storehouse.
It is described to indicate the database after subregion granularity adjustment in A9, the method as described in any one of A1-A7 The data base manipulation statement is performed in partition table, including:
By the data to be operated in the operation information of the pending data storehouse, point after the subregion granularity adjustment is mapped to In respective partition in area's table;
The database is indicated in the respective partition, the data base manipulation statement is performed.
In A10, the method as described in A9, the data to be operated in the operation information by the pending data storehouse are reflected It is mapped in the respective partition in the partition table after the subregion granularity adjustment, including:
Obtain the unique mark of the data to be operated;
Under the subregion dimension of the lowest level of partition table after subregion granularity adjustment, the unique mark is calculated Cryptographic Hash;
The data to be operated are mapped in the corresponding subregion of the cryptographic Hash.
In A11, the method as described in A10, the unique mark for obtaining the data to be operated, including:
The single major key of the data to be operated is obtained, the unique mark is used as;Or
The MD5 values of the joint major key of the data to be operated are calculated, the unique mark is used as.
It is described according to pending data storehouse operation information in A12, the method as described in any one of A1-A7, determine to be operated Before partition table and partition table process demand, in addition to:
The notification message that order caching device is pushed, the buffer storage is used to cache each client using the database Hold the database manipulation message submitted;
According to the notification message, pending data storehouse operation information is read from the buffer storage.
B13, a kind of database manipulation device is also disclosed in the embodiment of the present application, including:
Determining unit, for according to pending data storehouse operation information, determining partition table to be operated and subregion list processing Demand;
Adjustment unit, for according to the partition table process demand, the subregion grain of the dynamic adjustment partition table to be operated Degree;
Unit is submitted, it is described for operation information corresponding data base manipulation statement in the pending data storehouse to be committed to Database belonging to partition table to be operated;
Indicating member, for indicating to perform the data in partition table of the database after subregion granularity adjustment Storehouse action statement.
In B14, the device as described in B13, the adjustment unit includes:
Subelement is refined, for when the partition table process demand is that subregion refines demand, refining described to be operated point The subregion granularity of area's table.
In B15, the device as described in B14, it is described refinement subelement specifically for:
The granularity of at least one existing subregion dimension of the partition table to be operated is reduced, to refine the subregion to be operated Subregion in table;And/or
Increase new subregion dimension for the partition table to be operated, to refine the subregion in the partition table to be operated.
In B16, the device as described in B13, the adjustment unit also includes:
Merge subelement, for when the partition table process demand is that subregion merges demand, merging described to be operated point Subregion in area's table.
In B17, the device as described in B16, it is described merging subelement specifically for:
Increase the granularity of at least one existing subregion dimension of the partition table to be operated, to merge the subregion to be operated Subregion in table;And/or
Merge at least two existing subregion dimensions of the partition table to be operated, to merge in the partition table to be operated Subregion.
In B18, the device as described in B13, the determining unit includes:
Partition table determination subelement, for the table mark in the operation information of the pending data storehouse, it is determined that described Partition table to be operated;
Process demand determination subelement, for the data to be operated in the operation information of the pending data storehouse, behaviour Make type and/or partition table processing parameter, determine the partition table process demand.
In B19, the device as described in B18, the process demand determination subelement specifically for:
If the action type is updates, insertion or delete, and the temperature of the data to be operated meets the temperature of setting Condition, determines that the partition table process demand refines demand for subregion;
If the action type is inquiry, or the temperature of the data to be operated does not meet the temperature condition of setting, it is determined that The partition table process demand is that subregion merges demand.
In B20, the device as described in any one of B13-B19, it is described submission unit specifically for:
The data base manipulation statement being currently executing according to the database, counts the running status of the database;
If the running status meets the service requirement of setting, the data base manipulation statement is committed to the data Storehouse.
In B21, the device as described in any one of B13-B19, the indicating member includes:
Subelement is mapped, for by the data to be operated in the operation information of the pending data storehouse, being mapped to described point In the respective partition in partition table after area's granularity adjustment;
Subelement is indicated, for indicating the database in the respective partition, the data base manipulation statement is performed.
In B22, the device as described in B21, it is described mapping subelement specifically for:
Obtain the unique mark of the data to be operated;
Under the subregion dimension of the lowest level of partition table after subregion granularity adjustment, the unique mark is calculated Cryptographic Hash;
The data to be operated are mapped in the corresponding subregion of the cryptographic Hash.
In B23, the device as described in B22, it is described mapping subelement specifically for:
The single major key of the data to be operated is obtained, the unique mark is used as;Or
The MD5 values of the joint major key of the data to be operated are calculated, the unique mark is used as.
B24, the device as described in any one of B13-B19, in addition to:
Receiving unit, the notification message pushed for order caching device, the buffer storage is used to cache using described The database manipulation message that each client of database is submitted;
Acquiring unit, for according to the notification message, reading the pending data storehouse behaviour from the buffer storage Make information.
C25, a kind of database operating system is also disclosed in the embodiment of the present application, including:Database and with the database The database manipulation device of connection;
The database manipulation device, for according to pending data storehouse operation information, determine partition table to be operated and Partition table process demand;According to the partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;By institute State the corresponding data base manipulation statement of pending data storehouse operation information and be committed to the database;And indicate the database The data base manipulation statement is performed in partition table after subregion granularity adjustment;
The database, the data base manipulation statement for receiving the database manipulation device submission, and according to The database manipulation language is performed in the instruction of the database manipulation device, the partition table after subregion granularity adjustment Sentence.
C26, the Database Systems as described in C25, in addition to:
Buffer storage, is connected with the database manipulation device, and each client for caching using the database is carried The database manipulation message of friendship, and disappear when there is database manipulation message arrival to the database manipulation device sending out notice Breath;
The database manipulation device is additionally operable to:The notification message that the buffer storage is pushed is received, according to described Notification message, reads pending data storehouse operation information from the buffer storage.
D27, a kind of electronic equipment, including memory and processor is also disclosed in the embodiment of the present application;The memory is used for One or more computer instruction is stored, wherein, one or more computer instruction is by the computing device to realize Following steps;
According to pending data storehouse operation information, partition table to be operated and partition table process demand are determined;
According to the partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;
Operation information corresponding data base manipulation statement in the pending data storehouse is committed to the partition table to be operated Affiliated database;
Indicate to perform the data base manipulation statement in partition table of the database after subregion granularity adjustment.
In addition to the step of D27 is described, the electronic equipment of the application can also be used to perform any one of above-mentioned A2-A12 institutes The step of stating.
E28, a kind of computer-readable storage medium is also disclosed in the embodiment of the present application, including:
First store instruction, for according to pending data storehouse operation information, determining partition table to be operated and partition table Process demand;
Second store instruction, for according to the partition table process demand, point of the dynamic adjustment partition table to be operated Area's granularity;
3rd store instruction, for operation information corresponding data base manipulation statement in the pending data storehouse to be committed to Database belonging to the partition table to be operated;
4th store instruction, for indicating that execution is described in partition table of the database after subregion granularity adjustment Data base manipulation statement.
In addition to the step of E28 is described, the computer-readable storage medium of the application can also be used to perform in above-mentioned A2-A12 and appoint Step described in one.

Claims (10)

1. a kind of database operation method, it is characterised in that including:
According to pending data storehouse operation information, partition table to be operated and partition table process demand are determined;
According to the partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;
Operation information corresponding data base manipulation statement in the pending data storehouse is committed to belonging to the partition table to be operated Database;
Indicate to perform the data base manipulation statement in partition table of the database after subregion granularity adjustment.
2. according to the method described in claim 1, it is characterised in that described according to the partition table process demand, dynamic adjustment The subregion granularity of the partition table to be operated, including:
If the partition table process demand, which is subregion, refines demand, the subregion granularity of the partition table to be operated is refined.
3. method according to claim 2, it is characterised in that the subregion granularity of the refinement partition table to be operated, Including:
The granularity of at least one existing subregion dimension of the partition table to be operated is reduced, to refine in the partition table to be operated Subregion;And/or
Increase new subregion dimension for the partition table to be operated, to refine the subregion in the partition table to be operated.
4. according to the method described in claim 1, it is characterised in that described according to the partition table process demand, dynamic adjustment The subregion granularity of the partition table to be operated, in addition to:
If the partition table process demand, which is subregion, merges demand, merge the subregion in the partition table to be operated.
5. method according to claim 4, it is characterised in that the subregion in the merging partition table to be operated, bag Include:
Increase the granularity of at least one existing subregion dimension of the partition table to be operated, to merge in the partition table to be operated Subregion;And/or
Merge at least two existing subregion dimensions of the partition table to be operated, to merge point in the partition table to be operated Area.
6. according to the method described in claim 1, it is characterised in that described according to pending data storehouse operation information, it is determined that treating Partition table and partition table process demand are operated, including:
Table mark in the operation information of the pending data storehouse, determines the partition table to be operated;
Data to be operated, action type and/or partition table processing parameter in the operation information of the pending data storehouse, really The fixed partition table process demand.
7. the method according to claim any one of 1-7, it is characterised in that the instruction database is in the subregion The data base manipulation statement is performed in partition table after granularity adjustment, including:
By the data to be operated in the operation information of the pending data storehouse, the partition table after the subregion granularity adjustment is mapped to In respective partition in;
The database is indicated in the respective partition, the data base manipulation statement is performed.
8. the method according to claim any one of 1-7, it is characterised in that described operated according to pending data storehouse is believed Breath, before determining partition table to be operated and partition table process demand, in addition to:
The notification message that order caching device is pushed, the buffer storage is used to cache to be carried using each client of the database The database manipulation message of friendship;
According to the notification message, pending data storehouse operation information is read from the buffer storage.
9. a kind of database manipulation device, it is characterised in that including:
Determining unit, for according to pending data storehouse operation information, determining partition table to be operated and partition table process demand;
Adjustment unit, for according to the partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;
Unit is submitted, described waits to grasp for operation information corresponding data base manipulation statement in the pending data storehouse to be committed to Make the database belonging to partition table;
Indicating member, for indicating to perform the database behaviour in partition table of the database after subregion granularity adjustment Make sentence.
10. a kind of database operating system, it is characterised in that including:Database and the database being connected with the database Operation device;
The database manipulation device, for according to pending data storehouse operation information, determining partition table to be operated and subregion List processing demand;According to the partition table process demand, the subregion granularity of the dynamic adjustment partition table to be operated;Treated described The corresponding data base manipulation statement of process database operations information is committed to the database;And indicate the database in institute State in the partition table after the adjustment of subregion granularity and perform the data base manipulation statement;
The database, for receiving the data base manipulation statement that the database manipulation device is submitted, and according to described The data base manipulation statement is performed in the instruction of database manipulation device, the partition table after subregion granularity adjustment.
CN201710253093.2A 2017-04-18 2017-04-18 Database operation method, apparatus and system Pending CN107239485A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710253093.2A CN107239485A (en) 2017-04-18 2017-04-18 Database operation method, apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710253093.2A CN107239485A (en) 2017-04-18 2017-04-18 Database operation method, apparatus and system

Publications (1)

Publication Number Publication Date
CN107239485A true CN107239485A (en) 2017-10-10

Family

ID=59983754

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710253093.2A Pending CN107239485A (en) 2017-04-18 2017-04-18 Database operation method, apparatus and system

Country Status (1)

Country Link
CN (1) CN107239485A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107861989A (en) * 2017-10-17 2018-03-30 平安科技(深圳)有限公司 Partitioned storage method, apparatus, computer equipment and the storage medium of data
CN108108434A (en) * 2017-12-19 2018-06-01 福建中金在线信息科技有限公司 A kind of method and device for managing database
CN108628972A (en) * 2018-04-25 2018-10-09 咪咕音乐有限公司 A kind of processing method of tables of data, device and storage medium
CN110995851A (en) * 2019-12-11 2020-04-10 贝壳技术有限公司 Message processing method, device, storage medium and equipment
CN112035486A (en) * 2020-09-03 2020-12-04 中国银行股份有限公司 Partition establishing method, device and equipment for partition table
CN115203226A (en) * 2022-09-08 2022-10-18 北京奥星贝斯科技有限公司 Distributed meter lock operation method, device and equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521234A (en) * 2010-10-28 2012-06-27 微软公司 Partitioning online databases
CN102799628A (en) * 2012-06-21 2012-11-28 新浪网技术(中国)有限公司 Method and device for data partitioning in key-value database
CN103902544A (en) * 2012-12-25 2014-07-02 中国移动通信集团公司 Data processing method and system
CN104731864A (en) * 2015-02-26 2015-06-24 国家计算机网络与信息安全管理中心 Data storage method for mass unstructured data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102521234A (en) * 2010-10-28 2012-06-27 微软公司 Partitioning online databases
CN102799628A (en) * 2012-06-21 2012-11-28 新浪网技术(中国)有限公司 Method and device for data partitioning in key-value database
CN103902544A (en) * 2012-12-25 2014-07-02 中国移动通信集团公司 Data processing method and system
CN104731864A (en) * 2015-02-26 2015-06-24 国家计算机网络与信息安全管理中心 Data storage method for mass unstructured data

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107861989A (en) * 2017-10-17 2018-03-30 平安科技(深圳)有限公司 Partitioned storage method, apparatus, computer equipment and the storage medium of data
CN108108434A (en) * 2017-12-19 2018-06-01 福建中金在线信息科技有限公司 A kind of method and device for managing database
CN108628972A (en) * 2018-04-25 2018-10-09 咪咕音乐有限公司 A kind of processing method of tables of data, device and storage medium
CN108628972B (en) * 2018-04-25 2020-11-06 咪咕音乐有限公司 Data table processing method and device and storage medium
CN110995851A (en) * 2019-12-11 2020-04-10 贝壳技术有限公司 Message processing method, device, storage medium and equipment
CN110995851B (en) * 2019-12-11 2021-12-24 贝壳找房(北京)科技有限公司 Message processing method, device, storage medium and equipment
CN112035486A (en) * 2020-09-03 2020-12-04 中国银行股份有限公司 Partition establishing method, device and equipment for partition table
CN112035486B (en) * 2020-09-03 2023-09-19 中国银行股份有限公司 Partition establishing method, device and equipment of partition table
CN115203226A (en) * 2022-09-08 2022-10-18 北京奥星贝斯科技有限公司 Distributed meter lock operation method, device and equipment
CN115203226B (en) * 2022-09-08 2023-02-24 北京奥星贝斯科技有限公司 Distributed meter lock operation method, device and equipment

Similar Documents

Publication Publication Date Title
CN107239485A (en) Database operation method, apparatus and system
JP6356675B2 (en) Aggregation / grouping operation: Hardware implementation of hash table method
CN110268394B (en) Method, system and machine readable storage medium for storing and manipulating key value data
CN110383261B (en) Stream selection for multi-stream storage
US8224829B2 (en) Database
US9767131B2 (en) Hierarchical tablespace space management
US9495398B2 (en) Index for hybrid database
KR102564170B1 (en) Method and device for storing data object, and computer readable storage medium having a computer program using the same
CN105975587B (en) A kind of high performance memory database index organization and access method
AU2002222096A1 (en) Method of organising, interrogating and navigating a database
US20150006509A1 (en) Incremental maintenance of range-partitioned statistics for query optimization
US20170351726A1 (en) Method and computing device for minimizing accesses to data storage in conjunction with maintaining a b-tree
WO2018129500A1 (en) Optimized navigable key-value store
CN108268476A (en) Data query method and device
EP3365803A1 (en) Parallel execution of queries with a recursive clause
CN109344157A (en) Read and write abruption method, apparatus, computer equipment and storage medium
US8015195B2 (en) Modifying entry names in directory server
CN107154957A (en) Distributed storage control method based on virtual ring load-balancing algorithm
CN107818114A (en) A kind of data processing method, device and database
JP2014502756A (en) Apparatus and method for mass data storage based on tree structure
CN116662019B (en) Request distribution method and device, storage medium and electronic device
US10366067B2 (en) Adaptive index leaf block compression
WO2015129109A1 (en) Index management device
CN112988911B (en) Block chain data storage method and device and electronic equipment
CN111949439B (en) Database-based data file updating method and device

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20171010

RJ01 Rejection of invention patent application after publication