CN109376174A - A kind of method and apparatus selecting database - Google Patents

A kind of method and apparatus selecting database Download PDF

Info

Publication number
CN109376174A
CN109376174A CN201811644145.XA CN201811644145A CN109376174A CN 109376174 A CN109376174 A CN 109376174A CN 201811644145 A CN201811644145 A CN 201811644145A CN 109376174 A CN109376174 A CN 109376174A
Authority
CN
China
Prior art keywords
data
database
particle size
query
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.)
Granted
Application number
CN201811644145.XA
Other languages
Chinese (zh)
Other versions
CN109376174B (en
Inventor
周葳
张夏旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201811644145.XA priority Critical patent/CN109376174B/en
Publication of CN109376174A publication Critical patent/CN109376174A/en
Application granted granted Critical
Publication of CN109376174B publication Critical patent/CN109376174B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention provides a kind of method and device for selecting database, by obtaining data inquiry request, the database with data query particle size matching is obtained from preset multiple databases, if the quantity with the database of data query particle size matching is one, using with the database of data query particle size matching as target database, if the quantity with the database of data query particle size matching is at least two, select a database as target database from the database of data query particle size matching according to preset rules, realization selects database of the database as data interaction from multiple databases, and the data query granularity of attribute having for showing the data of inquiry is carried in data inquiry request, so that the database of selection is related to the attribute of the data of data inquiry request, it realizes and is asked according to current data inquiry The attribute for the data asked is dynamically selected database, improves the utilization rate and data acquisition speed of database.

Description

A kind of method and apparatus selecting database
Technical field
The invention belongs to data processing fields, more specifically, more particularly to a kind of method and apparatus for selecting database.
Background technique
The data of current major website are stored in multiple databases, each database purchase same part data, needing When a certain data, when can provide the data in multiple databases, if website obtains data meeting from multiple databases simultaneously So that the page shows that more parts of data cause the page chaotic simultaneously.
It in order to solve this problem, can be by using the corresponding relationship for presetting website and database, although such as one The data of a website are stored in multiple databases, but in data use process, a website is only capable of corresponding from having with it Data are obtained in the database of relationship, so that it is clearly demarcated to work between database, but the corresponding relationship of website and database is solid Fixed, it is too busy there are a database Gu and connects, another database phenomenon occupied with nothing, so that the utilization rate of database is low Under, data acquisition speed reduces.
Summary of the invention
In view of this, the purpose of the present invention is to provide a kind of method and devices for selecting database, for improving data The utilization rate and data acquisition speed in library.
The present invention provides a kind of method for selecting database, which comprises
Data inquiry request is obtained, carries data query granularity, the data query grain in the data inquiry request Spend the attribute having for showing the data of the data inquiry request inquiry;
The database with the data query particle size matching is obtained from preset multiple databases, with the data query Particle size matching shows the attribute that there is the data of the database purchase data query granularity to show;
If the quantity with the database of the data query particle size matching is one, looked into described with the data The database of particle size matching is ask as target database;
If the quantity of the database with the data query particle size matching is at least two, according to preset rules from Select a database as target database in the database with the data query particle size matching.
Preferably, the database packet obtained from preset multiple databases with the data query particle size matching It includes:
To any database in preset multiple databases: whether determining in the data of the database purchase The data for stating data inquiry request inquiry, if there is using the database as standby database;
The database with the data query particle size matching is obtained from multiple standby databases.
Preferably, the database packet obtained from preset multiple databases with the data query particle size matching It includes:
If the data query granularity is time granularity and data inquiry request instruction inquiry current one time Data, obtain the progress for the data that data inquiry request described in each database purchase in the multiple database indicates, institute It states database and partitioned storage data is carried out with the unit time;
The progress of data based on the instruction of data inquiry request described in each database purchase, selects a database As the database with the data query particle size matching;
If the data query granularity is the number of time granularity but data inquiry request instruction inquiry specific time According to the data for whether having database purchase to have the specific time in multiple databases being determined, if so, the spy will be stored with For the database fixed time as the database with the data query particle size matching, the specific time is when being located at current one Between before time;
If not being stored with the database of the data of the specific time, based on number described in each database purchase According to the progress of the data of inquiry request instruction, select a database as the database with the data query particle size matching.
Preferably, the database packet obtained from preset multiple databases with the data query particle size matching It includes:
Whether if the data query granularity is the specified particle size in addition to time granularity, determining in multiple databases has Database purchase has the data of the specified particle size, if so, will be stored with the database of the specified particle size as with it is described The database of data query particle size matching;
If not being stored with the database of the data of the specified particle size, based on each data inventory in multiple databases The progress for storing up the data of data inquiry request instruction, select a database as with the data query particle size matching Database.
Preferably, the method also includes: modify the inquiry tables of data list of a database in the multiple database, The inquiry tables of data list is used to record the tables of data of the database purchase, and records the data stored in the tables of data The attribute having.
The present invention also provides a kind of device for selecting database, described device includes:
Obtaining unit carries data query granularity, institute for obtaining data inquiry request in the data inquiry request State the attribute that data query granularity has for showing the data of the data inquiry request inquiry;
Matching unit, for obtaining the database with the data query particle size matching from preset multiple databases, Show the attribute that there is the data of the database purchase data query granularity to show with the data query particle size matching;
Selection unit, if being one for the quantity with the database of the data query particle size matching, by institute The database with the data query particle size matching is stated as target database, and if for the described and data query The quantity of the database of particle size matching is at least two, according to preset rules from described with data query particle size matching number According to selected in library a database as target database.
Preferably, the matching unit, specifically for any database in preset multiple databases: determining Whether the data of the data inquiry request inquiry are had in the data of the database purchase, if there is using the database as spare Database, and obtain from multiple standby databases the database with the data query particle size matching.
Preferably, the matching unit, it is following specifically for being executed based on the data query granularity in data inquiry request Step:
If the data query granularity is time granularity and data inquiry request instruction inquiry current one time Data, obtain the progress for the data that data inquiry request described in each database purchase in the multiple database indicates, institute It states database and partitioned storage data is carried out with the unit time;
The progress of data based on the instruction of data inquiry request described in each database purchase, selects a database As the database with the data query particle size matching;
If the data query granularity is the number of time granularity but data inquiry request instruction inquiry specific time According to the data for whether having database purchase to have the specific time in multiple databases being determined, if so, the spy will be stored with For the database fixed time as the database with the data query particle size matching, the specific time is when being located at current one Between before time;
If not being stored with the database of the data of the specific time, based on number described in each database purchase According to the progress of the data of inquiry request instruction, select a database as the database with the data query particle size matching.
Preferably, the matching unit, if being the spy in addition to time granularity specifically for the data query granularity Determine granularity, the data for whether having database purchase to have the specified particle size in multiple databases determined, if so, will store The database of specified particle size is stated as the database with the data query particle size matching;If not being stored with the specific grain The database of the data of degree, based on data inquiry request described in each database purchase in multiple databases instruction data into Degree, selects a database as the database with the data query particle size matching.
Preferably, described device further include: modification unit, for modifying in the multiple database looking into for a database Tables of data list is ask, the inquiry tables of data list is used to record the tables of data of the database purchase, and records the data The attribute that the data stored in table have.
From above-mentioned technical proposal it is found that by obtaining data inquiry request, obtained from preset multiple databases and number It is investigated that asking the database of particle size matching, if the quantity with the database of data query particle size matching is one, will be looked into data The database of particle size matching is ask as target database, if the quantity with the database of data query particle size matching is at least two It is a, selected a database as target database from the database of data query particle size matching according to preset rules, it is real Database of the database as data interaction is now selected from multiple databases, and is carried in data inquiry request useful In the data query granularity of attribute for showing that the data of inquiry have, show the number of database purchase with data query particle size matching According to the attribute shown with data query granularity, the database of selection can be made to look into data from there through data query granularity The attribute for asking the data of request is related, realizes and is dynamically selected database according to the attribute of the data of current data inquiry request, The mode in relatively existing fixed data library improves the utilization rate and data acquisition speed of database.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is the present invention Some embodiments for those of ordinary skill in the art without creative efforts, can also basis These attached drawings obtain other attached drawings.
Fig. 1 is a kind of flow chart of method for selecting database provided in an embodiment of the present invention;
Fig. 2 is the flow chart of the method for another selection database provided in an embodiment of the present invention;
Fig. 3 is a kind of structural schematic diagram of device for selecting database provided in an embodiment of the present invention;
Fig. 4 is the structural schematic diagram of the device of another selection database provided in an embodiment of the present invention.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Referring to Fig. 1, it illustrates a kind of method for selecting database provided in an embodiment of the present invention, it is used for from multiple numbers According to a database is selected in library, it is dynamically selected database to realize, may comprise steps of:
S101: data inquiry request is obtained, carries data query granularity in data inquiry request, wherein data query grain The attribute having for showing the data of data inquiry request inquiry is spent, thus, it is possible to look into from a variety of data of database purchase The data for the attribute that there is data query granularity to show are ask, such as data query granularity is used to show data inquiry request inquiry The attribute that data have can include but is not limited to title, time, region and type etc..
In the present embodiment, the name in attribute that data have is referred to as the summary of data, illustrates that data are which aspect Data, the time is the time that data generate, and region is geographical location associated with the data, and type shows what storing data used Form, such as title can be weather, show the data in terms of data are weather, and the time can be 2018.10.01, and region can To be province and country, such as Beijing, type can be video, voice, text, show data can using video, voice and At least one of text form stores.
In the present embodiment, data inquiry request can be the current equipment transmission for needing to obtain data from database, Such as terminal, when exporting some page, page data needed for needing to render the page, terminal then can be to server at this time The tables of data for sending data inquiry request, multiple databases being wherein stored in server, and store in each database may It is identical may also be different, storing the progresses of same part data but data in each database for identical tables of data, have can Can be different, the progress of so-called data shows the data volume that this kind of data store in the database, why there is progress difference It is because the performance difference of each database itself causes, tables of data is then the table of storing data, and recording in the tables of data has The attribute of institute's storing data.
S102: obtaining the database with data query particle size matching from preset multiple databases, with data query grain Degree matching shows that the data of database purchase have the attribute that shows of data query granularity, wherein data query granularity can be from It is extracted in data inquiry request.
Obtain from preset multiple databases is with a kind of feasible pattern of the database of data query particle size matching: right Any database in preset multiple databases: the number for whether having data inquiry request in the data of the database purchase determined According to if there is being obtained from multiple standby databases and data query particle size matching using the database as standby database Database.
In the present embodiment, determine that the one kind for the data for whether having data inquiry request in the data of the database purchase can Line mode is: obtaining the inquiry data list of the database, judges whether can look in the inquiry tables of data list of the database Data to the data with data inquiry request store record, if can find in the inquiry tables of data list of the database pair The data storage record answered, it is determined that have the data of data inquiry request in the data of database purchase, otherwise database purchase Data in there is no the data of data inquiry request.
Wherein, inquiry tables of data list is the tables of data of database of record storage, and records the data stored in tables of data The attribute having can know which data is tables of data be stored with the attribute having by recording data, these data have Which aspect, such as the value of data have in a tables of data attribute is respectively: title is weather, time to be 2018.10.01, region is Beijing, and type is video, then explanation has recorded Beijing in the tables of data with video mode and exists 2018.10.01 weather data.
Whether corresponding judgement can find the number with data inquiry request in the inquiry tables of data list of the database According to data storage record a kind of feasible pattern be: judge attribute possessed by the data of data inquiry request and inquiry data It whether there is consistent attribute between the attribute that the data stored in list records tables of data have, if it is present showing this It can find to store with the data of the data of data inquiry request in the inquiry tables of data list of database and record, otherwise show the number It is recorded according to that cannot find to store with the data of the data of data inquiry request in the inquiry tables of data list in library.
Using preset multiple databases and multiple standby databases as current database, from multiple current databases Middle acquisition is as follows with the feasible pattern of the database of data query particle size matching, and plurality of current database refers in particular to preset more A database or multiple standby databases, and preset multiple databases and multiple standby databases cannot be mixed:
A kind of feasible pattern is: if data query granularity is time granularity and data inquiry request refers to that inquiry is current single The data of position time obtain the progress of the data of each data database storing inquiry request instruction in multiple databases, wherein Database distinguishes storing data with the unit time, and the data based on the instruction of each data database storing inquiry request Progress selects a database as the database with data query particle size matching.
It is to be understood that progress, which can refer in database, to be stored because storing same data in multiple databases Data volume, that is to say, that the storage data volume stored in first database is greater than storage data quantity in second database, then Illustrate that the progress of first database is faster than the progress of second database, since database distinguishes storage number with the unit time According to so needing to obtain from database to obtain multiple matched numbers with the data of the matched unit time storage of time granularity Progress according to library, then based on each database institute storing data selects one from multiple matched databases, such as selects multiple The most fast database of database progress is obtained in matched database as the database with data query particle size matching, progress is most Refer to that the data volume of institute's storing data is most fastly.
Wherein, the unit time can be but not limited to one of week, day, hour and minute etc., every in database A memory block (region of storing data) corresponding unit time.Here, being to illustrate when natural gift are small with the unit time Bright: database is to distinguish storing data when natural gift are small, then each memory block in database corresponds to a hour, thus Each memory block in database of descriptions stores the data of a hour, such as memory block storage 15 points of data of the same day, but To be that the memory block not will record the memory block in storing data currently stored to which at time point, therefore deposits with the unit time Need the progress based on storage come matching database when storing up data.
If data query granularity is the data of time granularity but data inquiry request instruction inquiry specific time, determination is more The data for whether thering is database purchase to have specific time in a database, if so, the database for being stored with specific time is made For the database with data query particle size matching;If not being stored with the database of the data of specific time, it is based on every number According to the progress of the data of library storage data inquiry request instruction, select a database as the number with data query particle size matching According to library.
Wherein specific time is the time before the current one time.That is when specific time is current one Between before historical time, such as can be a historical time section, such as before specific time can be the current one time It past three days, then for this specific time, needs to find from multiple databases and be stored with over three day time Data database, if it is possible to find the data for illustrating there is the database purchase specific time in multiple databases, into And the database of the specific time will be stored as the database of data query particle size matching.
It, can each database that record is stored from inquiry tables of data list number when based on specific time inquiry According to inquiring in the time attribute of table, if the value of time attribute covers the specific time, illustrate to cover the specific time The data of the specific time are stored in database.If not covering the database of the specific time, need to obtain every number The progress of the data of data inquiry request instruction is stored according to library, to be chosen based on progress, such as most fast number of above-mentioned selection progress According to library as the database with data query particle size matching, naturally it is also possible to choose progress some range database as with The database of data query particle size matching.
Another feasible pattern is: if data query granularity is the specified particle size in addition to time granularity, determining multiple The data for whether thering is database purchase to have specified particle size in database, if so, will be stored with the database of specified particle size as Multiple data are based on if not being stored with the database of the data of specified particle size with the database of data query particle size matching The progress of the data of each data database storing inquiry request instruction in library, select a database as with data query grain Spend matched database.
Wherein specified particle size is a granularity in addition to time granularity, as specified particle size can show that except time attribute it At least one attribute in other outer attributes, such as these attributes of above-mentioned title, time, region and type, can be with An attribute is chosen from these attributes specified particle size is arranged.Such as " region " this attribute is chosen from these attributes, then The specified particle size of setting is that region can also further be arranged in specified particle size for searching the data with Regional Property The attribute value of attribute, to search the data with particular attribute-value.
It is still used to search the data with Regional Property with specified particle size, and during the attribute value of the Regional Property can be State, then based on the specified particle size search database when, it is thus necessary to determine that whether have in multiple databases database purchase have with The relevant data of China, such as weather data, the economic data of China and the military-specific data of China of China, if so, then The database of data relevant to China will be stored with as the database with data query particle size matching.
If it is not, it is the same to be also required to same time granularity, the instruction of each database purchase data inquiry request is obtained Data progress, with based on progress choose database, such as the most fast database of above-mentioned selection progress as with data query grain Spend matched database, naturally it is also possible to choose progress in the database of some range as the number with data query particle size matching According to library.
S103:, will be with data query particle size matching if the quantity with the database of data query particle size matching is one Database be target database, that is to say, that be not required in the case that the database of data query particle size matching only has one It to be selected again, but the database uniquely with data query particle size matching is directly determined as target database.
S104: if being at least two with the quantity of the database of data query particle size matching, according to preset rules from Select a database as target database in the database of data query particle size matching.
In the present embodiment, preset rules are to choose database again from the database of data query particle size matching Rule, the preset rules can select a database according to preset rules depending on practical application, such as in the present embodiment A kind of mode be: each database have pre-set priority, then can be pre-set excellent according to each database First grade selects database, such as using with the database of selection highest priority in the database of data query particle size matching as target Database.
Wherein pre-set priority can be determined according to the performance of database, and the priority of high performance database is set It is set to height, the priority of the database of low performance is set as low, and the height of database performance and reading data speed in database Spend related, if specific data reading speed is fast, the performance that can be considered as database is high, selects from there through the mode of priority Target database is taken, it can be in most cases using high performance database as target database, by the database of low performance As backup database.Furthermore in the present embodiment, the type of multiple databases can be different, and such as multiple databases can be The database of the types such as Impala, Infobright and Mysql can also be surveyed with supporting the use of multi-type database simultaneously Try the performance in multiple types of data library.
The another way for selecting a database according to preset rules in the present embodiment is: determining and data query grain The all properties that matched database has are spent, based on the attribute that the database with data query particle size matching has, determine mesh Database is marked, such as using the database most with the attribute that has in the database of data query particle size matching as target data Library, the content that the data obtained in the target database can be made to cover in this way are more comprehensive.
From above-mentioned technical proposal it is found that by obtaining data inquiry request, obtained from preset multiple databases and number It is investigated that asking the database of particle size matching, if the quantity with the database of data query particle size matching is one, will be looked into data The database of particle size matching is ask as target database, if the quantity with the database of data query particle size matching is at least two It is a, selected a database as target database from the database of data query particle size matching according to preset rules, it is real Database of the database as data interaction is now selected from multiple databases, and is carried in data inquiry request useful In the data query granularity of attribute for showing that the data of inquiry have, show the number of database purchase with data query particle size matching According to the attribute shown with data query granularity, the database of selection can be made to look into data from there through data query granularity The attribute for asking the data of request is related, realizes and is dynamically selected database according to the attribute of the data of current data inquiry request, The mode in relatively existing fixed data library improves the utilization rate and data acquisition speed of database.
In addition, can also include: the inquiry tables of data list of a database in the multiple databases of modification in the present embodiment, The tables of data that tables of data list is used for database of record storage is inquired, and records the attribute that the data stored in tables of data have.
If any one database in multiple databases increases data, increase in the inquiry tables of data list of the database The attribute for adding increased data to have, if any one database in multiple databases deletes data, which is looked into It askes tables of data list and deletes the attribute that deleted data have.
Furthermore in the present embodiment, if having a database in multiple databases is newly added database, this is new The database of addition needs to carry out performance of the data test to obtain database, then for this newly added database, it can To modify the inquiry tables of data list of the database in the present embodiment, so that being recorded in the inquiry tables of data list of the database Tables of data quantity less than the quantity of tables of data recorded in the inquiry tables of data list of other databases, can protect in this way Card can also guarantee the data normal use of other databases while testing newly added database.And in order to accelerate newly to add The priority of the newly added database can be disposed above the priority of other databases by the test of the database added, In this way by inquiry tables of data list and priority, will increase using the newly added database as the several of target database Rate, so as to shorten the testing time of newly added database, to accelerate the test to newly added database.
It is illustrated below from method of the different data query granularities to selection database provided in this embodiment, wherein not It include: time granularity and the specified particle size in addition to time granularity with data query granularity, and time granularity is directed to two aspects, On the one hand it is the data for inquiring the current one time, is on the other hand the data for inquiring specific time, detailed process such as Fig. 2 institute Show, may comprise steps of:
S201: data inquiry request is obtained, carries data query granularity in data inquiry request, wherein data query grain Spend the attribute having for showing the data of data inquiry request inquiry.
S202: it is based on data inquiry request, obtains standby database from preset multiple databases.
S203: judge whether the data query granularity in data inquiry request is time granularity and data query granularity indicates Inquire the data of current one time.
S204: if data query granularity is the number of time granularity and data query granularity instruction inquiry current one time According to the progress of the data based on the instruction of each data database storing inquiry request selects a database to look into as with data Ask the database of particle size matching.
S205: if data query granularity is the data of time granularity but data query granularity instruction inquiry specific time, The data for whether having database purchase to have specific time in multiple databases are judged, if there is executing step S206, if do not had Execute step S207.
S206: the database of specific time will be stored with as the database with data query particle size matching.
S207: the progress of the data based on the instruction of each data database storing inquiry request selects a database to make For the database with data query particle size matching.
S208: if data query granularity is specified particle size in addition to time granularity, judge in multiple databases whether There is database purchase there are the data of specified particle size, if there is executing step S209, if being not carried out step S210.
S209: the database of specified particle size will be stored with as the database with data query particle size matching.
S210: the progress of the data based on data database storing inquiry request each in multiple databases instruction, selection One database is as the database with data query particle size matching.
S211: target database is determined from the database of data query particle size matching, if specifically looked into data The quantity for asking the database of particle size matching is one, will be target database with the database of data query particle size matching;If Be at least two with the quantity of the database of data query particle size matching, according to preset rules from data query particle size matching Select a database as target database in database.
Above-described embodiment is please referred to for the detailed process of above-mentioned S201 to S211, this present embodiment is no longer described in detail.
From above-mentioned technical proposal it is found that by data query granularity database can be inquired from different attribute, in this way may be used With the data of attribute needed for searching the user demand under different user demands, can be combined in practical applications certainly more Attribute is inquired, and is met the needs of different users.
For the various method embodiments described above, for simple description, therefore, it is stated as a series of action combinations, but Be those skilled in the art should understand that, the present invention is not limited by the sequence of acts described because according to the present invention, certain A little steps can be performed in other orders or simultaneously.Secondly, those skilled in the art should also know that, it is retouched in specification The embodiment stated belongs to preferred embodiment, and related actions and modules are not necessarily necessary for the present invention.
Corresponding with above method embodiment, the embodiment of the present invention also provides a kind of device for selecting database, structure As shown in figure 3, may include: obtaining unit 11, matching unit 12 and selection unit 13.
Obtaining unit 11 carries data query granularity, data for obtaining data inquiry request in data inquiry request Granularity of query is used to show the attribute that the data of data inquiry request inquiry have.For the explanation and number of data query granularity The explanation in embodiment of the method is please referred to according to the acquisition of inquiry request, this is no longer illustrated.
Matching unit 12, for obtaining the database with data query particle size matching from preset multiple databases, In with data query particle size matching show that the data of database purchase have the attribute that shows of data query granularity.
In the present embodiment, matching unit 12 obtains a kind of feasible pattern with the database of data query particle size matching Be: whether to any database in preset multiple databases: determining in the data of the database purchase has data query to ask The data asked, if there is being obtained from multiple standby databases and data query granularity using the database as standby database Matched database.Mode for choosing standby database please refers to the explanation in embodiment of the method, no longer illustrates this.
Assuming that matching is single using above-mentioned multiple standby databases and preset multiple databases as current database Member 12 obtained from multiple current databases it is as follows with the feasible pattern of the database of data query particle size matching, it is plurality of to work as Preceding database refers in particular to preset multiple databases or multiple standby databases, and cannot be by preset multiple databases and multiple Standby database mixing:
A kind of feasible pattern is: if data query granularity is time granularity and data inquiry request refers to that inquiry is current single The data of position time obtain the progress of the data of each data database storing inquiry request instruction in multiple databases, wherein Database distinguishes storing data with the unit time, and the data based on the instruction of each data database storing inquiry request Progress selects a database as the database with data query particle size matching.
If data query granularity is the data of time granularity but data inquiry request instruction inquiry specific time, determination is more The data for whether thering is database purchase to have specific time in a database, if so, the database for being stored with specific time is made For the database with data query particle size matching;If not being stored with the database of the data of specific time, it is based on every number According to the progress of the data of library storage data inquiry request instruction, select a database as the number with data query particle size matching According to library.
Another feasible pattern is: if data query granularity is the specified particle size in addition to time granularity, determining multiple The data for whether thering is database purchase to have specified particle size in database, if so, will be stored with the database of specified particle size as Multiple data are based on if not being stored with the database of the data of specified particle size with the database of data query particle size matching The progress of the data of each data database storing inquiry request instruction in library, select a database as with data query grain Spend matched database.
Embodiment of the method is please referred to for the explanation of above two mode, and will not be described here in detail.
Selection unit 13 will be looked into if the quantity for the database with data query particle size matching is one with data Ask particle size matching database as target database, and if for the database with data query particle size matching quantity It is at least two, selects a database as number of targets from the database of data query particle size matching according to preset rules According to library.
From above-mentioned technical proposal it is found that by obtaining data inquiry request, obtained from preset multiple databases and number It is investigated that asking the database of particle size matching, if the quantity with the database of data query particle size matching is one, will be looked into data The database of particle size matching is ask as target database, if the quantity with the database of data query particle size matching is at least two It is a, selected a database as target database from the database of data query particle size matching according to preset rules, it is real Database of the database as data interaction is now selected from multiple databases, and is carried in data inquiry request useful In the data query granularity of attribute for showing that the data of inquiry have, show the number of database purchase with data query particle size matching According to the attribute shown with data query granularity, the database of selection can be made to look into data from there through data query granularity The attribute for asking the data of request is related, realizes and is dynamically selected database according to the attribute of the data of current data inquiry request, The mode in relatively existing fixed data library improves the utilization rate and data acquisition speed of database.
The device of above-mentioned selection database can also include: modification unit 14, as shown in Figure 4.Unit 14 is wherein modified, is used In the inquiry tables of data list for modifying a database in multiple databases, inquiry tables of data list is stored for database of record Tables of data, and record the attribute that the data that store have in tables of data.Based on this, if there is a data in multiple databases Library is newly added database, this newly added database needs to carry out performance of the data test to obtain database, then For this newly added database, the inquiry tables of data list of the database can be modified in the present embodiment, so that the number It is less than in the inquiry tables of data list of other databases and records according to the quantity of the tables of data recorded in the inquiry tables of data list in library Tables of data quantity, can guarantee to guarantee the numbers of other databases while testing newly added database in this way According to normal use.And in order to accelerate the test of newly added database, the priority of the newly added database can be set It is set to the priority higher than other databases, in this way by inquiry tables of data list and priority, will increase the new addition Probability of the database as target database, so as to shorten the testing time of newly added database, to accelerate to new addition Database test.
In addition, the embodiment of the present invention also provides a kind of storage medium, it is stored with computer program code on the storage medium, The method that the computer program code realizes above-mentioned selection database when executing.
It should be noted that all the embodiments in this specification are described in a progressive manner, each embodiment weight Point explanation is the difference from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For device class embodiment, since it is basically similar to the method embodiment, so being described relatively simple, related place ginseng See the part explanation of embodiment of the method.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged Except there is also other identical elements in the process, method, article or apparatus that includes the element.
The foregoing description of the disclosed embodiments can be realized those skilled in the art or using the present invention.To this A variety of modifications of a little embodiments will be apparent for a person skilled in the art, and the general principles defined herein can Without departing from the spirit or scope of the present invention, to realize in other embodiments.Therefore, the present invention will not be limited It is formed on the embodiments shown herein, and is to fit to consistent with the principles and novel features disclosed in this article widest Range.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered It is considered as protection scope of the present invention.

Claims (10)

1. a kind of method for selecting database, which is characterized in that the described method includes:
Data inquiry request is obtained, data query granularity is carried in the data inquiry request, the data query granularity is used In the attribute for showing that the data of the data inquiry request inquiry have;
The database with the data query particle size matching is obtained from preset multiple databases, with the data query granularity Matching shows the attribute that there is the data of the database purchase data query granularity to show;
It, will the described and data query grain if the quantity with the database of the data query particle size matching is one Matched database is spent as target database;
If the quantity of the database with the data query particle size matching is at least two, according to preset rules from described Select a database as target database with the database of the data query particle size matching.
2. the method according to claim 1, wherein described obtain and the number from preset multiple databases It is investigated that the database for asking particle size matching includes:
Whether to any database in preset multiple databases: determining has the number in the data of the database purchase According to the data that inquiry request is inquired, if there is using the database as standby database;
The database with the data query particle size matching is obtained from multiple standby databases.
3. the method according to claim 1, wherein described obtain and the number from preset multiple databases It is investigated that the database for asking particle size matching includes:
If the data query granularity is the number of time granularity and data inquiry request instruction inquiry current one time According to obtaining the progress for the data that data inquiry request described in each database purchase in the multiple database indicates, the number Partitioned storage data are carried out with the unit time according to library;
Based on data inquiry request described in each database purchase instruction data progress, select a database as With the database of the data query particle size matching;
If the data query granularity is the data of time granularity but data inquiry request instruction inquiry specific time, really The data for whether thering is database purchase to have the specific time in fixed multiple databases, if so, when will be stored with described specific Between database as the database with the data query particle size matching, the specific time be located at the current one time it The preceding time;
If not being stored with the database of the data of the specific time, looked into based on data described in each database purchase The progress for asking the data of request instruction, selects a database as the database with the data query particle size matching.
4. the method according to claim 1, wherein described obtain and the number from preset multiple databases It is investigated that the database for asking particle size matching includes:
If the data query granularity is the specified particle size in addition to time granularity, determine in multiple databases whether there are data Inventory contains the data of the specified particle size, if so, will be stored with the database of the specified particle size as with the data The matched database of granularity of query;
If not being stored with the database of the data of the specified particle size, based on each database purchase institute in multiple databases The progress for stating the data of data inquiry request instruction, selects a database as the data with the data query particle size matching Library.
5. the method according to claim 1, wherein the method also includes: modify in the multiple database The inquiry tables of data list of one database, the inquiry tables of data list are used to record the tables of data of the database purchase, And record the attribute that the data stored in the tables of data have.
6. a kind of device for selecting database, which is characterized in that described device includes:
Obtaining unit carries data query granularity, the number for obtaining data inquiry request in the data inquiry request It is used to show the attribute that the data of the data inquiry request inquiry have according to granularity of query;
Matching unit, for obtaining the database with the data query particle size matching from preset multiple databases, with institute It states data query particle size matching and shows the attribute that there is the data of the database purchase data query granularity to show;
Selection unit, if the quantity for the database with the data query particle size matching is one, will it is described with The database of the data query particle size matching is as target database, and if for the described and data query granularity The quantity of matched database is at least two, according to preset rules from described with data query particle size matching database It is middle to select a database as target database.
7. device according to claim 6, which is characterized in that the matching unit is specifically used for described preset more Any database in a database: the number for whether having the data inquiry request inquiry in the data of the database purchase determined According to if there is using the database as standby database, and being obtained and the data query granularity from multiple standby databases Matched database.
8. device according to claim 6, which is characterized in that the matching unit, specifically for being asked based on data query Data query granularity in asking executes following steps:
If the data query granularity is the number of time granularity and data inquiry request instruction inquiry current one time According to obtaining the progress for the data that data inquiry request described in each database purchase in the multiple database indicates, the number Partitioned storage data are carried out with the unit time according to library;
Based on data inquiry request described in each database purchase instruction data progress, select a database as With the database of the data query particle size matching;
If the data query granularity is the data of time granularity but data inquiry request instruction inquiry specific time, really The data for whether thering is database purchase to have the specific time in fixed multiple databases, if so, when will be stored with described specific Between database as the database with the data query particle size matching, the specific time be located at the current one time it The preceding time;
If not being stored with the database of the data of the specific time, looked into based on data described in each database purchase The progress for asking the data of request instruction, selects a database as the database with the data query particle size matching.
9. device according to claim 6, which is characterized in that the matching unit, if looked into specifically for the data Asking granularity is the specified particle size in addition to time granularity, and whether determine in multiple databases has database purchase to have the specific grain The data of degree, if so, the database of the specified particle size will be stored with as the data with the data query particle size matching Library;If not being stored with the database of the data of the specified particle size, based on each database purchase institute in multiple databases The progress for stating the data of data inquiry request instruction, selects a database as the data with the data query particle size matching Library.
10. device according to claim 6, which is characterized in that described device further include: modification unit, for modifying The inquiry tables of data list of a database in multiple databases is stated, the inquiry tables of data list is for recording the database The tables of data of storage, and record the attribute that the data stored in the tables of data have.
CN201811644145.XA 2018-12-30 2018-12-30 Method and device for selecting database Active CN109376174B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811644145.XA CN109376174B (en) 2018-12-30 2018-12-30 Method and device for selecting database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811644145.XA CN109376174B (en) 2018-12-30 2018-12-30 Method and device for selecting database

Publications (2)

Publication Number Publication Date
CN109376174A true CN109376174A (en) 2019-02-22
CN109376174B CN109376174B (en) 2021-04-27

Family

ID=65372002

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811644145.XA Active CN109376174B (en) 2018-12-30 2018-12-30 Method and device for selecting database

Country Status (1)

Country Link
CN (1) CN109376174B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821708A (en) * 2020-06-19 2021-12-21 广东美的厨房电器制造有限公司 Cooking information acquisition method and device, terminal and storage medium
CN116821138A (en) * 2023-08-24 2023-09-29 腾讯科技(深圳)有限公司 Data processing method and related equipment

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5926808A (en) * 1997-07-25 1999-07-20 Claritech Corporation Displaying portions of text from multiple documents over multiple databases related to a search query in a computer network
CN1641639A (en) * 2004-01-12 2005-07-20 英业达股份有限公司 Multi data base query system and method thereof
CN101458782A (en) * 2007-12-11 2009-06-17 鸿富锦精密工业(深圳)有限公司 Quality management transversal integration system and method
CN102750384A (en) * 2012-06-28 2012-10-24 用友软件股份有限公司 Device and method for acquiring data from multidatabase engine
CN103403707A (en) * 2010-12-28 2013-11-20 思杰系统有限公司 Systems and methods for database proxy request switching
CN104539713A (en) * 2014-12-31 2015-04-22 北京奇虎科技有限公司 Service request processing method and device
CN105138143A (en) * 2015-08-28 2015-12-09 百度在线网络技术(北京)有限公司 Method and device for obtaining term database
CN105389352A (en) * 2015-10-30 2016-03-09 北京奇艺世纪科技有限公司 Log processing method and apparatus
CN105573996A (en) * 2014-10-09 2016-05-11 阿里巴巴集团控股有限公司 Database processing method, database processing device and database processing system
CN106991029A (en) * 2016-01-21 2017-07-28 阿里巴巴集团控股有限公司 A kind of acquisition methods and device of sequence data
WO2018080187A1 (en) * 2016-10-26 2018-05-03 주식회사 리얼타임테크 Apparatus for operating multiple databases of embedded database system, and method therefor
CN108427684A (en) * 2017-02-14 2018-08-21 华为技术有限公司 Data query method, apparatus and computing device
CN108984569A (en) * 2017-06-05 2018-12-11 中兴通讯股份有限公司 Database switching method, system and computer readable storage medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5926808A (en) * 1997-07-25 1999-07-20 Claritech Corporation Displaying portions of text from multiple documents over multiple databases related to a search query in a computer network
CN1641639A (en) * 2004-01-12 2005-07-20 英业达股份有限公司 Multi data base query system and method thereof
CN101458782A (en) * 2007-12-11 2009-06-17 鸿富锦精密工业(深圳)有限公司 Quality management transversal integration system and method
CN103403707A (en) * 2010-12-28 2013-11-20 思杰系统有限公司 Systems and methods for database proxy request switching
CN102750384A (en) * 2012-06-28 2012-10-24 用友软件股份有限公司 Device and method for acquiring data from multidatabase engine
CN105573996A (en) * 2014-10-09 2016-05-11 阿里巴巴集团控股有限公司 Database processing method, database processing device and database processing system
CN104539713A (en) * 2014-12-31 2015-04-22 北京奇虎科技有限公司 Service request processing method and device
CN105138143A (en) * 2015-08-28 2015-12-09 百度在线网络技术(北京)有限公司 Method and device for obtaining term database
CN105389352A (en) * 2015-10-30 2016-03-09 北京奇艺世纪科技有限公司 Log processing method and apparatus
CN106991029A (en) * 2016-01-21 2017-07-28 阿里巴巴集团控股有限公司 A kind of acquisition methods and device of sequence data
WO2018080187A1 (en) * 2016-10-26 2018-05-03 주식회사 리얼타임테크 Apparatus for operating multiple databases of embedded database system, and method therefor
CN108427684A (en) * 2017-02-14 2018-08-21 华为技术有限公司 Data query method, apparatus and computing device
CN108984569A (en) * 2017-06-05 2018-12-11 中兴通讯股份有限公司 Database switching method, system and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
马红: "基于用户查询请求的Web数据库选择探讨", 《信息系统工程》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113821708A (en) * 2020-06-19 2021-12-21 广东美的厨房电器制造有限公司 Cooking information acquisition method and device, terminal and storage medium
CN116821138A (en) * 2023-08-24 2023-09-29 腾讯科技(深圳)有限公司 Data processing method and related equipment
CN116821138B (en) * 2023-08-24 2023-12-15 腾讯科技(深圳)有限公司 Data processing method and related equipment

Also Published As

Publication number Publication date
CN109376174B (en) 2021-04-27

Similar Documents

Publication Publication Date Title
CN110321344B (en) Information query method and device for associated data, computer equipment and storage medium
JP5661104B2 (en) Method and system for search using search engine indexing and index
US10332075B2 (en) Nearest known person directory function
CN107436725A (en) A kind of data are write, read method, apparatus and distributed objects storage cluster
CN107783980A (en) Index data generates and data query method and device, storage and inquiry system
CN105279236A (en) File cleaning method and device and electronic equipment
CN107203532A (en) Construction method, the implementation method of search and the device of directory system
CN104794228A (en) Search result providing method and device
CN102739622A (en) Expandable data storage system
CN104636349A (en) Method and equipment for compression and searching of index data
CN108228663A (en) A kind of paging search method and device
CN109597574A (en) Distributed data storage method, server and readable storage medium storing program for executing
CN109376174A (en) A kind of method and apparatus selecting database
CN106547870A (en) Point table method and device of data base
CN109981569A (en) Network system access method, device, computer equipment and readable storage medium storing program for executing
CN102968456B (en) A kind of raster data reading and processing method and device
CN108399175B (en) Data storage and query method and device
CN106326462A (en) Video index grading method and device
CN103559307A (en) Caching method and device for query
CN111125557A (en) Resource screening method and device, computer equipment and storage medium
CN108829897A (en) Date storage method and data-storage system
CN111178965B (en) Resource release method and server
CN110471764A (en) A kind of processing method and processing device of memory cleaning
CN116027989A (en) Method and system for storing file set based on storage management chip
CN106970964A (en) Gps data information query method and system based on shared drive

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant