Summary of the invention
Fundamental purpose of the present invention is manner of execution and the device of the query task providing a kind of database, when multiple query manipulation consuming time being performed to a database to solve in prior art simultaneously, and the problem that multiple query manipulation consuming time is seized database resource.
To achieve these goals, according to an aspect of the present invention, a kind of manner of execution of query task of database is provided.
Manner of execution according to the present invention comprises: obtain the first pending query task, wherein, carries the mark of the database shared by execution first query task in the first query task; First query task is preserved the queue pointed by inlet identity; Obtain the mission number of each query task preserved in queue, wherein, each query task of preservation comprises the first query task; Each query task of the preservation in queue is performed according to mission number.
Further, the queue that the first query task is preserved pointed by inlet identity is comprised: detect the queue corresponding to mark whether existing and created; If there is the queue corresponding to mark created, then the first query task is added into the tail of the queue of queue; The queue corresponding to mark created if do not exist, then create queue, and the first query task is saved to queue.
Further, the tail of the queue that the first query task is added into queue is comprised: whether the quantity detecting the second query task preserved in queue reaches predetermined threshold value, and wherein, each query task of preservation comprises the second query task; If the quantity of the second query task preserved in queue does not reach predetermined threshold value, then the first query task is added into the tail of the queue of queue.
Further, comprise according to each query task of the preservation in mission number execution queue: whether detect queue is empty; If queue is not empty, then read the 4th query task that the mission number of current the 3rd complete query task is corresponding, wherein, each query task of preservation comprises the 3rd query task and the 4th query task; Perform the 4th query task, and the 4th query task is removed from queue.
Further, after each query task performing the preservation in queue according to mission number, manner of execution also comprises: obtain the execution result data performing each query task preserved; Execution result data are preserved into result data set.
To achieve these goals, according to a further aspect in the invention, a kind of actuating unit of query task of database is provided.
Actuating unit according to the present invention comprises: the first acquisition module, for obtaining the first pending query task, wherein, carries the mark of the database shared by execution first query task in the first query task; First preserves module, for the first query task being preserved the queue pointed by inlet identity; Second acquisition module, for obtaining the mission number of each query task preserved in queue, wherein, each query task of preservation comprises the first query task; Execution module, for performing each query task of the preservation in queue according to mission number.
Further, first preserves module comprises: first detection module, for detecting the queue corresponding to the mark that whether exists and created; Adding module, for when there is the queue corresponding to the mark that created, the first query task being added into the tail of the queue of queue; Preserve submodule, for when there is not the queue corresponding to the mark that created, creating queue, and the first query task is saved to queue.
Further, add module to comprise: whether the second detection module, reach predetermined threshold value for the quantity detecting the second query task preserved in queue, and wherein, each query task of preservation comprises the second query task; Add submodule, the quantity for the second query task preserved in queue does not reach predetermined threshold value, the first query task is added into the tail of the queue of queue.
Whether further, execution module comprises: the 3rd detection module, be empty for detecting queue; Read module, for not being empty in queue, read the 4th query task that the mission number of current the 3rd complete query task is corresponding, wherein, each query task of preservation comprises the 3rd query task and the 4th query task; Implementation sub-module, for performing the 4th query task, and removes the 4th query task from queue.
Further, actuating unit also comprises: the 3rd acquisition module, for after each query task performing the preservation in queue according to mission number, obtains the execution result data performing each query task preserved; Second preserves module, for preserving execution result data into result data set.
Adopt the embodiment of the present invention, after getting the first pending query task, according to the mark of the database shared by this task of the execution of carrying in the first query task, first query task is preserved the queue pointed by this mark, the order entering queue according to each query task obtains the mission number of each query task preserved in queue successively, and performs each query task according to the mission number serial got successively.In the above-described embodiments, for each database arranges a queue, by query task being preserved in the queue of corresponding database, and the order of queue is entered according to the mission number of each query task preserved in queue and query task, query task is performed to this database, can realize ranking to the query task of each database and each query task preserved in automated serial execution queue, avoid when multiple query task consuming time being performed simultaneously to a database in prior art, the problem that the resource of each consuming task to database is seized.Pass through the embodiment of the present invention, to solve in prior art when multiple inquiry consuming time being performed to a database simultaneously, the problem that multiple inquiry consuming time is seized database resource, achieves the effect simultaneously serialization during a database execution multiple query manipulation consuming time being performed to each query manipulation.
Embodiment
The present invention program is understood better in order to make those skilled in the art person, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the embodiment of a part of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, should belong to the scope of protection of the invention.
It should be noted that, term " first ", " second " etc. in instructions of the present invention and claims and above-mentioned accompanying drawing are for distinguishing similar object, and need not be used for describing specific order or precedence.Should be appreciated that the data used like this can be exchanged in the appropriate case, so as embodiments of the invention described herein can with except here diagram or describe those except order implement.In addition, term " comprises " and " having " and their any distortion, intention is to cover not exclusive comprising, such as, contain those steps or unit that the process of series of steps or unit, method, system, product or equipment is not necessarily limited to clearly list, but can comprise clearly do not list or for intrinsic other step of these processes, method, product or equipment or unit.
It should be noted that, when not conflicting, the embodiment in the application and the feature in embodiment can combine mutually.Below with reference to the accompanying drawings and describe the present invention in detail in conjunction with the embodiments.
Fig. 1 is the process flow diagram of the manner of execution of the query task of database according to the embodiment of the present invention, and as shown in Figure 1, this manner of execution comprises following step S102 to step S108:
Step S102, obtains the first pending query task.
Wherein, the mark of the database shared by execution first query task is carried in the first query task.
Step S104, preserves the queue pointed by inlet identity by the first query task.
Step S106, obtains the mission number of each query task preserved in queue.
Wherein, each query task of preservation comprises the first query task.
Step S108, performs each query task of the preservation in queue according to mission number.
Adopt the embodiment of the present invention, after getting the first pending query task, according to the mark of the database shared by this task of the execution of carrying in the first query task, first query task is preserved the queue pointed by this mark, the order entering queue according to each query task obtains the mission number of each query task preserved in queue successively, and performs each query task according to the mission number serial got successively.In the above-described embodiments, for each database arranges a queue, by query task being preserved in the queue of corresponding database, and the order of queue is entered according to the mission number of each query task preserved in queue and query task, query task is performed to this database, can realize ranking to the query task of each database and each query task preserved in automated serial execution queue, avoid when multiple query task consuming time being performed simultaneously to a database in prior art, the problem that the resource of each consuming task to database is seized.Pass through the embodiment of the present invention, to solve in prior art when multiple inquiry consuming time being performed to a database simultaneously, the problem that multiple inquiry consuming time is seized database resource, achieves the effect simultaneously serialization during a database execution multiple query manipulation consuming time being performed to each query manipulation.
In the above-described embodiment, when obtaining the mission number of each query task preserved in queue, the order entering queue according to query task sequentially obtains mission number; When performing each query task of the preservation in queue according to mission number, perform each query task in queue successively according to the mission number got, instead of with the size of mission number for execution sequence performs each query task.
In an optional embodiment, can by realizing the above embodiment of the present invention for each database arranges unified database access interface, particularly, each query task of each database of access is received by unified database access interface, and packet queue is carried out to each query task, namely use unified database access interface to be saved in same queue by the query task of the same database of access, parallel seriesization performs each query task in queue.
Can automatically create as required for the queue of preserving query task in the present embodiment, without the need to manual creation, the database will be able to accessed according to query task divides into groups to query task, the resource of each database server can be utilized fully, avoid performing the problem that multiple queries task is seized database resource simultaneously.
Queue in above-described embodiment is the linear list of first in first out (First-In-First-Out, i.e. FIFO), and usual chained list or array realize in a particular application, and queue only allows to carry out update in rear end, carries out deletion action in front end.
According to the above embodiment of the present invention, the queue that the first query task is preserved pointed by inlet identity can be comprised: detect the queue corresponding to mark whether existing and created; If there is the queue corresponding to mark created, then the first query task is added into the tail of the queue of queue; The queue corresponding to mark created if do not exist, then create queue, and the first query task is saved to queue.
Particularly, detect the queue corresponding to mark that whether there is the database carried in the first query task created, when the queue corresponding to this mark that existence has created, the first query task is added into the tail of the queue of this queue; When there is not the queue corresponding to this mark of having created (namely this database does not have corresponding queue), creating the queue corresponding to this mark, and the first query task is saved in queue.
In the above-described embodiments, a corresponding queue of database, when receiving query task, the mark of the database shared by this query task of the execution of carrying in query task, determine the database that query task will be accessed, and whether the queue detecting this database exists, and deposits in case in the queue of this database, the query task received is saved to the tail of the queue of queue; In the non-existent situation of the queue of this database, create queue and the query task received is saved in queue.
Pass through the above embodiment of the present invention, when a database receives multiple queries task, the query task received is preserved by the queue of database, parallel series performs the query task preserved in queue, avoid when performing multiple queries operation to database in prior art, multiple queries operation performs simultaneously and causes the problem seizing database resource.
In the above embodiment of the present invention, the tail of the queue the first query task being added into queue can comprise: whether the quantity detecting the second query task preserved in queue reaches predetermined threshold value, and wherein, each query task of preservation comprises the second query task; If the quantity of the second query task preserved in queue does not reach predetermined threshold value, then the first query task is added into the tail of the queue of queue.
Particularly, whether the quantity of the second query task preserved in the queue of Test database reaches predetermined threshold value, if the quantity of the second query task preserved in the queue of database does not reach predetermined threshold value, then the first query task is added into the tail of the queue of queue; If the quantity of the second query task preserved in the queue of database reaches predetermined threshold value, then will generate information, this first query task cannot be processed in time to point out customer data base.
In the above-described embodiments, predetermined threshold value is the higher limit of the query task that the database preset can process in Preset Time, if the quantity of the query task preserved in the queue of database reaches predetermined threshold value, so when receiving new query task, database can not process the query task newly received in Preset Time, and namely database can not process the query task newly received in time.
According to the above embodiment of the present invention, each query task of the preservation performed in queue according to mission number can comprise: whether detect queue is empty; If queue is not empty, then read the 4th query task that the mission number of current the 3rd complete query task is corresponding, wherein, each query task of preservation comprises the 3rd query task and the 4th query task; Perform the 4th query task, and the 4th query task is removed from queue.
Particularly, when performing each query task of the preservation in queue according to mission number, whether the queue of Test database is empty, if the queue of database is not empty, enter the 4th query task of queue after then reading in current the 3rd complete query task, perform the 4th query task and it is removed from queue.
Further, when the queue of database is empty, suspends the flow process performing query task, start the time that timer record suspends, and after time out reaches the default stand-by period, whether the queue of Test database is empty again.
Need to further illustrate, the numerical values recited of the mission number of query task does not affect the precedence performing query task, is only used as to distinguish the sequencing that query task enters queue.
According to the above embodiment of the present invention, after each query task performing the preservation in queue according to mission number, manner of execution can also comprise: obtain the execution result data performing each query task preserved; Execution result data are preserved into result data set.
Particularly, after the mission number according to query task performs each query task of the preservation in queue, obtain the execution result data of each query task performed in queue, and result data is preserved in result data set.
Further, after executing a query task, the Query Result data of this query task are returned to the user sending this query task by result data set.
Fig. 2 is the process flow diagram of the manner of execution of the query task of a kind of optional database according to the embodiment of the present invention, and manner of execution as shown in Figure 2 can comprise the steps:
Step S202, receives query task.
Wherein, the mark performing the database taken needed for this query task is carried in query task.
Step S204, whether the packet queue detected corresponding to query task exists.
Particularly, detect in the database corresponding to mark carried in this query task and whether there is packet queue (queue namely in above-described embodiment), in the non-existent situation of the packet queue corresponding to query task, perform step S206; Packet queue corresponding to query task is deposited in case, performs step S208.
Step S206, for identifying corresponding database initialize packet queue.
Step S208, obtains the packet queue that query task is corresponding.
Step S210, whether the quantity detecting the query task preserved in packet queue reaches predetermined threshold value.
Particularly, whether the quantity detecting the query task (the second query task namely in above-described embodiment) preserved in packet queue reaches predetermined threshold value, namely whether the query task detected in packet queue has reached the process upper limit of database, when the quantity of the query task preserved in packet queue has reached predetermined threshold value, perform step S212; When the quantity of the query task preserved in packet queue does not reach predetermined threshold value, perform step S214.
Step S212, generating prompting cannot the information of query task in time.
Particularly, the quantity of the query task preserved in packet queue reaches predetermined threshold value, i.e. database busy, generates information and cannot process query task in time to point out customer data base.
Step S214, is saved to the queue end of packet queue by query task.
Step S216, waits for that result data set returns execution result data.
Particularly, can perform sub-process perform query task by initiating task, and obtain the execution result data of query task, wherein, tasks carrying sub-process can comprise step S302 as shown in Figure 3 to step S310.
Step S302, initiating task performs sub-process.
Whether step S304, detecting packet queue is empty.
Particularly, detect in packet queue whether have pending query task, when packet queue is empty, perform step S306, when packet queue is not empty, perform step S308.
Step S306, suspended task performs sub-process and starts timer, and logger task performs the time that sub-process is suspended.
Particularly, after the time that tasks carrying sub-process is suspended reaches Preset Time, return and perform step S302.
Step S308, obtains the query task coming head of the queue in packet queue, and is removed from packet queue by this query task.
Step S310, performs query task, and execution result data is saved to result data set.
It should be noted that, can perform in the computer system of such as one group of computer executable instructions in the step shown in the process flow diagram of accompanying drawing, and, although show logical order in flow charts, but in some cases, can be different from the step shown or described by order execution herein.
Fig. 4 is the schematic diagram of the actuating unit of the query task of database according to the embodiment of the present invention, as shown in Figure 4, this actuating unit can comprise: the first acquisition module 10, for obtaining the first pending query task, wherein, the mark of the database shared by execution first query task is carried in the first query task; First preserves module 30, for the first query task being preserved the queue pointed by inlet identity; Second acquisition module 50, for obtaining the mission number of each query task preserved in queue, wherein, each query task of preservation comprises the first query task; Execution module 70, for performing each query task of the preservation in queue according to mission number.
Adopt the embodiment of the present invention, after getting the first pending query task, according to the mark of the database shared by this task of the execution of carrying in the first query task, first query task is preserved the queue pointed by this mark, the order entering queue according to each query task obtains the mission number of each query task preserved in queue successively, and performs each query task according to the mission number serial got successively.In the above-described embodiments, for each database arranges a queue, by query task being preserved in the queue of corresponding database, and the order of queue is entered according to the mission number of each query task preserved in queue and query task, query task is performed to this database, can realize ranking to the query task of each database and each query task preserved in automated serial execution queue, avoid when multiple query task consuming time being performed simultaneously to a database in prior art, the problem that the resource of each consuming task to database is seized.Pass through the embodiment of the present invention, to solve in prior art when multiple inquiry consuming time being performed to a database simultaneously, the problem that multiple inquiry consuming time is seized database resource, achieves the effect simultaneously serialization during a database execution multiple query manipulation consuming time being performed to each query manipulation.
In the above-described embodiment, when obtaining the mission number of each query task preserved in queue, the order entering queue according to query task sequentially obtains mission number; When performing each query task of the preservation in queue according to mission number, perform each query task in queue successively according to the mission number got, instead of with the size of mission number for execution sequence performs each query task.
In an optional embodiment, can by realizing the above embodiment of the present invention for each database arranges unified database access interface, particularly, each query task of each database of access is received by unified database access interface, and packet queue is carried out to each query task, namely use unified database access interface to be saved in same queue by the query task of the same database of access, parallel seriesization performs each query task in queue.
Can automatically create as required for the queue of preserving query task in the present embodiment, without the need to manual creation, the database will be able to accessed according to query task divides into groups to query task, the resource of each database server can be utilized fully, avoid performing the problem that multiple queries task is seized database resource simultaneously.
Queue in above-described embodiment is the linear list of first in first out (First-In-First-Out, i.e. FIFO), and usual chained list or array realize in a particular application, and queue only allows to carry out update in rear end, carries out deletion action in front end.
According to the above embodiment of the present invention, first preserves module can comprise: first detection module, for detecting the queue corresponding to the mark that whether exists and created; Adding module, for when there is the queue corresponding to the mark that created, the first query task being added into the tail of the queue of queue; Preserve submodule, for when there is not the queue corresponding to the mark that created, creating queue, and the first query task is saved to queue.
Particularly, detect the queue corresponding to mark that whether there is the database carried in the first query task created, when the queue corresponding to this mark that existence has created, the first query task is added into the tail of the queue of this queue; When there is not the queue corresponding to this mark of having created (namely this database does not have corresponding queue), creating the queue corresponding to this mark, and the first query task is saved in queue.
In the above-described embodiments, a corresponding queue of database, when receiving query task, the mark of the database shared by this query task of the execution of carrying in query task, determine the database that query task will be accessed, and whether the queue detecting this database exists, and deposits in case in the queue of this database, the query task received is saved to the tail of the queue of queue; In the non-existent situation of the queue of this database, create queue and the query task received is saved in queue.
Pass through the above embodiment of the present invention, when a database receives multiple queries task, the query task received is preserved by the queue of database, parallel series performs the query task preserved in queue, avoid when performing multiple queries operation to database in prior art, multiple queries operation performs simultaneously and causes the problem seizing database resource.
In the above embodiment of the present invention, adding module can comprise: whether the second detection module, reach predetermined threshold value for the quantity detecting the second query task preserved in queue, and wherein, each query task of preservation comprises the second query task; Add submodule, the quantity for the second query task preserved in queue does not reach predetermined threshold value, the first query task is added into the tail of the queue of queue.
Particularly, whether the quantity of the second query task preserved in the queue of Test database reaches predetermined threshold value, if the quantity of the second query task preserved in the queue of database does not reach predetermined threshold value, then the first query task is added into the tail of the queue of queue; If the quantity of the second query task preserved in the queue of database reaches predetermined threshold value, then will generate information, this first query task cannot be processed in time to point out customer data base.
In the above-described embodiments, predetermined threshold value is the higher limit of the query task that the database preset can process in Preset Time, if the quantity of the query task preserved in the queue of database reaches predetermined threshold value, so when receiving new query task, database can not process the query task newly received in Preset Time, and namely database can not process the query task newly received in time.
Whether according to the above embodiment of the present invention, execution module can comprise: the 3rd detection module, be empty for detecting queue; Read module, for not being empty in queue, read the 4th query task that the mission number of current the 3rd complete query task is corresponding, wherein, each query task of preservation comprises the 3rd query task and the 4th query task; Implementation sub-module, for performing the 4th query task, and removes the 4th query task from queue.
Particularly, when performing each query task of the preservation in queue according to mission number, whether the queue of Test database is empty, if the queue of database is not empty, enter the 4th query task of queue after then reading in current the 3rd complete query task, perform the 4th query task and it is removed from queue.
Further, when the queue of database is empty, suspends the flow process performing query task, start the time that timer record suspends, and after time out reaches the default stand-by period, whether the queue of Test database is empty again.
Need to further illustrate, the numerical values recited of the mission number of query task does not affect the precedence performing query task, is only used as to distinguish the sequencing that query task enters queue.
According to the above embodiment of the present invention, actuating unit can also comprise: the 3rd acquisition module, for after each query task performing the preservation in queue according to mission number, obtains the execution result data performing each query task preserved; Second preserves module, for preserving execution result data into result data set.
Particularly, after the mission number according to query task performs each query task of the preservation in queue, obtain the execution result data of each query task performed in queue, and result data is preserved in result data set.
Further, after executing a query task, the Query Result data of this query task are returned to the user sending this query task by result data set.
The modules provided in the present embodiment is identical with the using method that the corresponding step of embodiment of the method provides, application scenarios also can be identical.It is noted, of course, that the scheme that above-mentioned module relates to can be not limited to content in above-described embodiment and scene, and above-mentioned module may operate in terminal or mobile terminal, can pass through software or hardware implementing.
As can be seen from the above description, present invention achieves following technique effect:
Adopt the embodiment of the present invention, after getting the first pending query task, according to the mark of the database shared by this task of the execution of carrying in the first query task, first query task is preserved the queue pointed by this mark, the order entering queue according to each query task obtains the mission number of each query task preserved in queue successively, and performs each query task according to the mission number serial got successively.In the above-described embodiments, for each database arranges a queue, by query task being preserved in the queue of corresponding database, and the order of queue is entered according to the mission number of each query task preserved in queue and query task, query task is performed to this database, can realize ranking to the query task of each database and each query task preserved in automated serial execution queue, avoid when multiple query task consuming time being performed simultaneously to a database in prior art, the problem that the resource of each consuming task to database is seized.Pass through the embodiment of the present invention, to solve in prior art when multiple inquiry consuming time being performed to a database simultaneously, the problem that multiple inquiry consuming time is seized database resource, achieves the effect simultaneously serialization during a database execution multiple query manipulation consuming time being performed to each query manipulation.
Obviously, those skilled in the art should be understood that, above-mentioned of the present invention each module or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on network that multiple calculation element forms, alternatively, they can realize with the executable program code of calculation element, thus, they can be stored and be performed by calculation element in the storage device, or they are made into each integrated circuit modules respectively, or the multiple module in them or step are made into single integrated circuit module to realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.