CN109325043A - A kind of method, apparatus and electronic equipment marking SQL statement - Google Patents
A kind of method, apparatus and electronic equipment marking SQL statement Download PDFInfo
- Publication number
- CN109325043A CN109325043A CN201810963162.3A CN201810963162A CN109325043A CN 109325043 A CN109325043 A CN 109325043A CN 201810963162 A CN201810963162 A CN 201810963162A CN 109325043 A CN109325043 A CN 109325043A
- Authority
- CN
- China
- Prior art keywords
- sql statement
- type
- sql
- efficiency analysis
- statement
- 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
Links
Abstract
Disclose a kind of method, apparatus and electronic equipment for marking SQL statement, for solving in the prior art invalidation request sentence can not be marked, cause not filtering out invalidation request sentence in subsequent processing, the problem of efficiency and speed of effectively processing and the response of request sentence are low, poor user experience.This method comprises: the SQL statement in SQL execution journal to be classified as to the SQL statement of at least one type;Efficiency analysis is carried out to the SQL statement of any type in the SQL statement of at least one type, determines corresponding efficiency analysis as a result, being marked according to SQL statement of the efficiency analysis result to any type.
Description
Technical field
This disclosure relates to database field more particularly to a kind of method, apparatus and electronic equipment for marking SQL statement.
Background technique
With the development of internet technology, the trade company for providing service using internet platform for user is more and more, simultaneously
Also more and more using the user of internet platform, user often inquires and searches for oneself interested content, these inquiries
Operation with search will appear as request sentence in database level, be referred to as structured query language
(Structured Query Language, SQL) sentence, due to the increase of user, the SQL statement that user issues also increases, because
This requirement to database is also higher and higher.
In the prior art, the request sentence that user issues all is received and is all executed, but in practical applications, and
All request sentences for not being user's sending are all effectively, wherein also will include some invalidation request sentences, for example, repeating to send out
Request sentence, incomplete request sentence or the illegal request sentence sent, is handled and is rung to the invalidation request sentence
It answers, will cause the waste of resource, and influence the efficiency and speed of processing and the response of other effective request sentences.
In conclusion how the invalidation request sentence to be marked, facilitate in subsequent processing to the invalidation request
Sentence filters out, and improves the efficiency and speed of effectively processing and the response of request sentence, promotes user experience, is to need at present
It solves the problems, such as.
Summary of the invention
In view of this, being used for the embodiment of the invention provides a kind of method, apparatus and electronic equipment for marking SQL statement
Invalidation request sentence is marked, facilitates in subsequent processing and the invalidation request sentence is filtered out, improve and effectively ask
The efficiency and speed of processing and the response of sentence are asked, the user experience is improved.
According to a first aspect of the embodiments of the present invention, a kind of method for marking SQL statement is provided, comprising: execute SQL
SQL statement in log is classified as the SQL statement of at least one type;To appointing in the SQL statement of at least one type
A type of SQL statement carries out efficiency analysis, determines corresponding efficiency analysis as a result, according to the efficiency analysis knot
The SQL statement of any type is marked in fruit.
In one embodiment, the SQL statement by SQL execution journal is classified as the SQL language of at least one type
Sentence, specifically includes: the SQL statement in SQL execution journal is classified as to the SQL statement of at least one type according to setting rule.
In one embodiment, the setting rule includes: that the SQL statement is identical or the grammer knot of the SQL statement
Structure is identical.
In one embodiment, the SQL statement of any type in the SQL statement at least one type
Efficiency analysis is carried out, corresponding efficiency analysis is determined as a result, specifically including: obtaining the every of the SQL statement of any type
Influence line number of one SQL statement implementing result to database;The SQL statement that calculating influence line number is zero is in affiliated type
The ratio of SQL statement.
In one embodiment, it is marked according to SQL statement of the efficiency analysis result to any type
Note, specifically includes: if the ratio is greater than or equal to first threshold, the SQL statement of any type being labeled as needing
Optimize;It is if the ratio is less than the first threshold, the SQL statement of any type is excellent labeled as not needing
Change.
In one embodiment, the SQL statement of any type in the SQL statement at least one type
Efficiency analysis is carried out, determines corresponding efficiency analysis as a result, specific further include: determine the SQL language of any type
The invalid SQL statement for including in sentence executes number, wherein the invalid SQL statement is attached most importance to the SQL statement or endless that send of recurrence
Whole SQL statement or illegal SQL statement.
In one embodiment, it is marked according to SQL statement of the efficiency analysis result to any type
Note, specifically includes:
If the execution number is greater than or equal to second threshold, the SQL statement of any type is labeled as needing
Optimize;If the execution number is less than the second threshold, the SQL statement of any type is labeled as not needing
Optimization.
In one embodiment, the invalid SQL statement executes number and is executed according to the SQL statement of any type
The sum of number, and the ratio-dependent of the invalid SQL statement described in the sum for executing number.
According to a second aspect of the embodiments of the present invention, a kind of device for marking SQL statement is provided, comprising: sort out unit,
For the SQL statement in SQL execution journal to be classified as to the SQL statement of at least one type;Determination unit, for it is described extremely
The SQL statement of any type in few a type of SQL statement carries out efficiency analysis, determines corresponding efficiency analysis
As a result;Processing unit, for being marked according to SQL statement of the efficiency analysis result to any type.
In one embodiment, the classification unit is specifically used for:
SQL statement in SQL execution journal is classified as to the SQL statement of at least one type according to setting rule.
In one embodiment, the setting rule includes: that the SQL statement is identical or the grammer knot of the SQL statement
Structure is identical.
In one embodiment, the determination unit is specifically used for: obtaining each of the SQL statement of any type
Influence line number of the SQL statement implementing result to database;SQL language of the SQL statement that calculating influence line number is zero in affiliated type
The ratio of sentence.
In one embodiment, the processing unit is specifically used for:, will if the ratio is greater than or equal to first threshold
The SQL statement of any type is labeled as needing to optimize;If the ratio is less than the first threshold, will be described any
The SQL statement of seed type is labeled as not needing to optimize.
In one embodiment, the determination unit is specifically used for: determining in the SQL statement of any type and includes
Invalid SQL statement execute number, wherein the invalid SQL statement is attached most importance to the recurrence SQL statement or incomplete SQL language that send
Sentence or illegal SQL statement.
In one embodiment, the processing unit is specifically used for: if the execution number is greater than or equal to second threshold,
Then the SQL statement of any type is labeled as needing to optimize;It, will if the execution number is less than the second threshold
The SQL statement of any type is labeled as not needing to optimize.
In one embodiment, the invalid SQL statement executes number and is executed according to the SQL statement of any type
The sum of number, and the ratio-dependent of the invalid SQL statement described in the sum for executing number.
According to a third aspect of the embodiments of the present invention, a kind of computer readable storage medium is provided, storage calculates thereon
Machine program instruction, the computer program instructions realize such as first aspect or any implementation of first aspect when being executed by processor
Method described in example.
According to a fourth aspect of the embodiments of the present invention, a kind of electronic equipment, including memory and processor are provided, it is described
Memory is for storing one or more computer program instructions, wherein one or more computer program instructions are by institute
Processor is stated to execute to realize the method as described in first aspect or first aspect any embodiment.
In the embodiment of the present invention, the SQL statement in SQL execution journal is classified as to the SQL language of at least one type first
Then sentence carries out efficiency analysis, and root to the SQL statement of any type in the SQL statement of at least one type
It is marked according to SQL statement of the efficiency analysis result to any type.Due to any type
SQL statement is marked, and what be can be convenient in subsequent processing filters out invalidation request sentence, has saved processing invalidation request language
The resource of sentence, reduces network burden, and this improves the efficiency and speed of processing and the response of effective request sentence, improves
User experience.
Detailed description of the invention
By referring to the drawings to the description of the embodiment of the present invention, the above-mentioned and other purpose of the embodiment of the present invention,
Feature and advantage will be apparent from, in the accompanying drawings:
Fig. 1 is a kind of method flow diagram for marking SQL statement provided in an embodiment of the present invention;
Fig. 2 is the method flow diagram of another label SQL statement provided in an embodiment of the present invention;
Fig. 3 is that a kind of SQL statement optimum results analysis front end provided in an embodiment of the present invention shows page schematic diagram;
Fig. 4 is a kind of schematic device for marking SQL statement provided in an embodiment of the present invention;
Fig. 5 is a kind of electronic equipment schematic diagram provided in an embodiment of the present invention.
Specific embodiment
Below based on embodiment, present invention is described, but the present invention is not restricted to these embodiments.Under
Text is detailed to describe some specific detail sections in datail description of the invention.Do not have for a person skilled in the art
The present invention can also be understood completely in the description of these detail sections.In order to avoid obscuring essence of the invention, well known method, mistake
There is no narrations in detail for journey, process, element and circuit.
In addition, it should be understood by one skilled in the art that provided herein attached drawing be provided to explanation purpose, and
What attached drawing was not necessarily drawn to scale.
Unless the context clearly requires otherwise, "include", "comprise" otherwise throughout the specification and claims etc. are similar
Word should be construed as the meaning for including rather than exclusive or exhaustive meaning;That is, be " including but not limited to " contains
Justice.
In the description of the embodiment of the present invention, it is to be understood that term " first ", " second " etc. are only used for description mesh
, it is not understood to indicate or imply relative importance.In addition, in the description of the embodiment of the present invention, unless otherwise indicated,
The meaning of " plurality " is two or more.
Fig. 1 is a kind of method flow diagram of label SQL statement of the embodiment of the present invention.As shown in Figure 1, the label SQL
The method of sentence includes:
Step S100, the SQL statement in SQL execution journal is classified as to the SQL statement of at least one type.
Wherein, the SQL execution journal can also become database execution journal, can be database middleware log,
The log for being also possible to each back end of distributed data base can summarize acquisition.
Optionally, the SQL statement in SQL execution journal is classified as to the SQL language of at least one type according to setting rule
Sentence, specifically, the setting rule includes: that the SQL statement is identical or the syntactic structure of the SQL statement is identical.I.e. by SQL
Identical SQL statement is classified as one kind in the SQL statement of execution journal, or syntactic structure in the SQL statement of database is identical,
But the different SQL statement of querying condition is classified as one kind.
For example, example 1, SQL statement identical in the SQL statement of SQL execution journal is classified as one kind, it is assumed that SQL language
Operation indicated by sentence is to update telephone number record, such as updating the telephone number of Zhang San is 13800001111, then counts
One kind is classified as according to the SQL statement that the telephone numbers for updating Zhang San all in library are 13800001111;Example 2, by SQL execution journal
SQL statement in syntactic structure it is identical, but the different SQL statement of querying condition is classified as one kind, it is assumed that SQL statement is to update
Telephone number record, then in SQL execution journal all instructions operation are as follows: " update xx telephone number be xxxxxxxxxxx "
The SQL statement of syntactic structure be classified as one kind;Wherein, " Zhang San " " 13800001111 " in example 1 are querying condition.
In embodiments of the present invention, the SQL statement is referred to as the request sentence of user's transmission, the embodiment of the present invention
Without limitation to it.
Step S101, validity is carried out to the SQL statement of any type in the SQL statement of at least one type
Analysis, determines corresponding efficiency analysis result.
Specifically, the efficiency analysis refers to holding for invalid SQL statement in the SQL statement for analyzing any type
The ratio of SQL statement in row number or the SQL statement of analysis any type on database line number without influence, also
It is ratio shared by effective SQL statement in the SQL statement for analyze any type, or the execution of effective SQL statement
Number, further judges whether the SQL statement of any type needs to optimize.
Optionally, carrying out efficiency analysis to the SQL statement of any type can be wrapped by following two mode
It includes:
Influence row of each SQL statement implementing result of the SQL statement of mode one, any type of acquisition to database
Number;Ratio of the SQL statement that calculating influence line number is zero in the SQL statement of affiliated type.
Specifically, assuming that the telephone number that the SQL statement of any type is update Zhang San is 13800001111, but former
The telephone number of Zhang San is also " 13800001111 " in some telephone number records, executes SQL statement to the telephone number of Zhang San
It is updated, but the telephone number for updating front and back is identical, i.e., to the telephone number record saved in the database row
Number does not influence, or the corresponding user " Zhang San " of telephone number " 13800001111 " updated is inherently not present in data
In the telephone number record saved in library, therefore the line number of the telephone number record saved in the database is not influenced,
Assuming that the quantity of the SQL statement of any type is 10000, do not have to the line number of the telephone number record saved in database
The SQL statement of influence is 3000, then the ratio is 30%.
Mode two determines that the invalid SQL statement for including in the SQL statement of any type executes number, wherein institute
Invalid SQL statement is stated to attach most importance to the SQL statement that send of recurrence or incomplete SQL statement or illegal SQL statement.
Specifically, the invalid SQL statement, which executes number, executes the total of number according to the SQL statement of any type
Number, and the ratio-dependent of the invalid SQL statement described in the sum for executing number.
For example, the SQL statement of any type can be with type A or be type B, it is assumed that in SQL statement one day of type A
It performs 1000 times, wherein the accounting of invalid SQL statement is 80%, then it is 800 that invalid SQL statement, which executes number, type B
SQL statement performs 100,000 times in one day, wherein the accounting of invalid SQL statement is 50%, then invalid SQL statement execution number is
50000 times, wherein the time cycle is 1 day in the above example, or other time, the embodiment of the present invention do not limit it
It is fixed.
Step S102, it is marked according to SQL statement of the efficiency analysis result to any type.
Specifically, the efficiency analysis result determined according to step S101, it is determined whether to the SQL of any type
Sentence is marked, for example, in aforesaid way one, if to the shadow of line number in the database in the SQL statement of any type
The ratio for the SQL statement that sound is zero is more than first threshold, then by the SQL statement of any type labeled as needing to optimize, if not having
First threshold is had more than, then by the SQL statement of any type labeled as not needing to optimize, wherein the first threshold can be with
Be 30%, 50% or 70%, the embodiment of the present invention to it without limitation.Specifically optimal way is, it is assumed that appointing before optimization
A type of SQL statement is 10,000,000, and the SQL statement of any type after optimization is 8,000,000.Aforesaid way two
In, if it is more than second threshold that the invalid SQL statement for including in the SQL statement of any type, which executes number, by any kind
The SQL statement of type is labeled as needing to optimize, if being not above second threshold, by the SQL statement of any type labeled as not
It needs to optimize, for example, the SQL statement of type A performs 1000 times in one day, wherein the accounting of invalid SQL statement is 80%, then
It is 800 that invalid SQL statement, which executes number, is performed 100,000 times in SQL statement one day of type B, wherein invalid SQL statement accounts for
Than being 50%, then it is 50,000 times that invalid SQL statement, which executes number, invalid although the invalid SQL statement accounting of type A is very high
It is less that SQL statement executes number, therefore, can mark as optimization, although and the accounting of the invalid SQL statement of type B with
Type A is compared to less, but to execute number more for invalid SQL statement, therefore, labeled as needing to optimize.
In the embodiment of the present invention, the SQL statement in SQL execution journal is classified as to the SQL language of at least one type first
Then sentence carries out efficiency analysis to the SQL statement of any type in the SQL statement of at least one type, according to
The SQL statement of any type is marked in the efficiency analysis result.Due to the SQL to any type
Sentence is marked, and can effectively filter out invalidation request sentence in subsequent processing, has saved processing invalidation request sentence
Resource, reduce network burden, this improves the efficiency and speed of processing and the response of effective request sentence, improve
User experience.
Below by a specific embodiment, a kind of method marking SQL statement is described in detail, as shown in Fig. 2,
In this embodiment, it selects to carry out efficiency analysis, tool in SQL execution journal in order to update the SQL statement of telephone number record
Steps are as follows for body:
Step S200, the SQL statement in SQL execution journal is sorted out according to syntactic structure is identical, determines a kind of
Type is the SQL statement for updating telephone number record, wherein the telephone number record for needing to be updated is as shown in table 1 below:
Table 1
Name | Telephone number |
Zhang San | 13800001111 |
Li Si | 13800001112 |
King five | 13800001113 |
Zhao Yi | 13800001114 |
Money two | 13800001115 |
Grandson six | 13800001116 |
Lee seven | 13800001117 |
Week eight | 13800001118 |
Wu Jiu | 13800001119 |
Deng ten | 13800001110 |
It step S201, is the SQL statement progress efficiency analysis for updating telephone number record to a seed type.
Specifically, assuming that a seed type is that the SQL statement of update telephone number record includes 10 SQL statements, example
The operation as indicated by SQL statement are as follows: " telephone number for updating Zhang San is 13800001111 " " updates the telephone number of Li Si
For 13800001112 ", " telephone number for updating king five be 13800001113 ", " telephone number of update Zhao one is
13800001000 ", " the more telephone number of fresh money two be 13800001001 ", " telephone number of more Xinsun six is
13800001002 ", " update Lee seven telephone number be 13800001117 ", " update week eight telephone number be
13800001118 ", " telephone number for updating Wu nine is 13800001119 " and " telephone number of more Xinzheng ten is
13800001110".Updated table 2 is generated, as follows:
Table 2
Name | Telephone number |
Zhang San | 13800001111 |
Li Si | 13800001112 |
King five | 13800001113 |
Zhao Yi | 13800001000 |
Money two | 13800001001 |
Grandson six | 13800001002 |
Lee seven | 13800001117 |
Week eight | 13800001118 |
Wu Jiu | 13800001119 |
Deng ten | 13800001110 |
Step S202, determine that a seed type is that influence to table 1 is zero in the SQL statement for update telephone number record
SQL statement ratio.
Specifically, being to update the SQL statement of telephone number record it is found that table 1 according to table 1, table 2 and a seed type
The SQL statement that influence is zero is 7, and the ratio for accounting for sum 10 is 70%.
Step S203, judge whether the ratio is greater than or equal to first threshold.
It is more new phone number by a seed type if step S204, the described ratio is greater than or equal to first threshold
The SQL statement of record is labeled as needing to optimize;
It is the SQL statement mark for updating telephone number record by a seed type if the ratio is less than first threshold
It is denoted as and does not need to optimize.
Assuming that first threshold is set as 50%, the ratio is greater than the first threshold, is to update by a seed type
The SQL statement of telephone number record is labeled as the SQL statement for needing to optimize.
After step s 204, further includes: by the seed type after the label be update telephone number record
SQL statement is sent to backstage and optimizes processing, and the seed type after optimization is the SQL statement for updating telephone number record
Indicated operation are as follows: " telephone number for updating Zhao one is 13800001000 ", " telephone number of more fresh money two is
13800001001 ", " the more telephone number of Xinsun six is 13800001002 ", wherein the backstage can be the transmission SQL
The equipment of sentence, it is more new phone number note that the equipment for sending the SQL statement, which is received with a markd seed type,
After the SQL statement of record, processing is optimized, the invalid SQL statement of user's transmission is no longer received after processing, such as: update Zhang San
Telephone number be 13800001111 ", " telephone number for updating Li Si is 13800001112 ", " update the phone number of king five
Code is 13800001113 " etc..
Optionally, if a seed type is that influence to table 1 is zero in the SQL statement for update telephone number record
The ratio of SQL statement is less than the first threshold, then is marked as not needing to optimize.
The embodiment of the present invention optimizes processing to the SQL statement after label, and the result after optimization processing is shown
Front end shows the page, and the front end shows the schematic diagram of the page as shown in figure 3, such as SQL statement 1, sentence Q before optimization and excellent
Sentence q after change, the quantity m after quantity M and rear optimization before optimization;SQL statement 2, the language after sentence P and optimization before optimization
Sentence p, the quantity n after quantity N and rear optimization before optimization, and so on, wherein the concrete condition of Q, q, M, m, P, p, N, n exist
Show that the disclosure is the explanation of exemplary by practical application in practical application.
Fig. 4 is a kind of schematic device for marking SQL statement provided in an embodiment of the present invention.As shown in figure 4, the present embodiment
The device of label SQL statement include sorting out unit 41, determination unit 42 and processing unit 43.
Wherein, the classification unit 41, for the SQL statement in SQL execution journal to be classified as at least one type
SQL statement;Determination unit 42, the SQL statement for any type in the SQL statement at least one type carry out
Efficiency analysis determines efficiency analysis result;Processing unit 43 is used for according to the efficiency analysis result to described any
The SQL statement of seed type is marked.
Further, the classification unit 41 is specifically used for: by the SQL statement in SQL execution journal according to setting rule
It is classified as the SQL statement of at least one type.
Preferably, the setting rule includes: that the SQL statement is identical or the syntactic structure of the SQL statement is identical.
In embodiments of the present invention, the determination unit 42 is specifically used for: obtaining each of the SQL statement of any type
Influence line number of the SQL statement implementing result to database;
Ratio of the SQL statement that calculating influence line number is zero in the SQL statement of affiliated type.
Further, the processing unit 43 is specifically used for:
It is if the ratio is greater than or equal to first threshold, the SQL statement of any type is excellent labeled as needing
Change;If the ratio is less than the first threshold, the SQL statement of any type is labeled as not needing to optimize.
Preferably, the determination unit 42 is specifically used for: determining include in the SQL statement of any type invalid
SQL statement executes number, wherein the invalid SQL statement attach most importance to the SQL statement that send of recurrence or incomplete SQL statement or
Illegal SQL statement.
Optionally, the processing unit 43 is specifically used for:
If the execution number is greater than or equal to second threshold, the SQL statement of any type is labeled as needing
Optimize;
If the execution number is less than the second threshold, the SQL statement of any type is labeled as being not required to
Optimize.
Further, the invalid SQL statement executes number and executes number according to the SQL statement of any type
Sum, and the ratio-dependent of the invalid SQL statement described in the sum for executing number.
Fig. 5 is the schematic diagram of the electronic equipment of the embodiment of the present invention.Electronic equipment shown in fig. 5 is general data processing dress
It sets comprising general computer hardware structure includes at least processor 51 and memory 52.Processor 51 and memory 52
It is connected by bus 53.Memory 52 is suitable for the instruction or program that storage processor 51 can be performed.Processor 51 can be independence
Microprocessor, be also possible to one or more microprocessor set.Processor 51 is deposited by executing memory 52 as a result,
The instruction of storage is realized thereby executing the method flow of embodiment present invention as described above for the processing of data and for other
The control of device.Bus 53 links together above-mentioned multiple components, while said modules are connected to 54 He of display controller
Display device and input/output (I/O) device 55.Input/output (I/O) device 55 can be mouse, keyboard, modulation /demodulation
Device, network interface, touch-control input device, body-sensing input unit, printer and other devices well known in the art.Typically,
Input/output device 55 is connected by input/output (I/O) controller 56 with system.
As skilled in the art will be aware of, various aspects of the invention may be implemented as system, method or meter
Calculation machine program product.Therefore, various aspects of the invention can take following form: complete hardware embodiment, complete software
Embodiment (including firmware, resident software, microcode etc.) or herein usually can referred to as " circuit ", " module " or
The embodiment that software aspects are combined with hardware aspect of " system ".In addition, aspect of the invention can take following shape
Formula: the computer program product realized in one or more computer-readable medium, computer-readable medium have on it
The computer readable program code of realization.
It can use any combination of one or more computer-readable mediums.Computer-readable medium can be computer
Readable signal medium or computer readable storage medium.Computer readable storage medium can be such as (but not limited to) electronics,
Magnetic, optical, electromagnetism, infrared or semiconductor system, device or any suitable combination above-mentioned.Meter
The more specific example (exhaustive to enumerate) of calculation machine readable storage medium storing program for executing will include the following terms: with one or more electric wire
Electrical connection, hard disk, random access memory (RAM), read-only memory (ROM), erasable is compiled portable computer diskette
Journey read-only memory (EPROM or flash memory), optical fiber, portable optic disk read-only storage (CD-ROM), light storage device,
Magnetic memory apparatus or any suitable combination above-mentioned.In the context of the present invention, computer readable storage medium can be
It can include or store the program used by instruction execution system, device or combine instruction execution system, equipment or dress
Set any tangible medium of the program used.
Computer-readable signal media may include the data-signal propagated, and the data-signal of the propagation has wherein
The computer readable program code realized such as a part in a base band or as carrier wave.The signal of such propagation can use
Any form in diversified forms, including but not limited to: electromagnetism, optical or its any combination appropriate.It is computer-readable
Signal media can be following any computer-readable medium: not be computer readable storage medium, and can be to by instructing
Program that is that execution system, device use or combining instruction execution system, device to use is communicated, is propagated
Or transmission.
Including but not limited to wireless, wired, fiber optic cables, RF etc. or above-mentioned any appropriately combined any can be used
Suitable medium transmits the program code realized on a computer-readable medium.
Computer program code for executing the operation for being directed to various aspects of the present invention can be with one or more programming languages
Any combination of speech is write, and the programming language includes: programming language such as Java, Smalltalk, C++ of object-oriented etc.;
And conventional process programming language such as " C " programming language or similar programming language.Program code can be used as independent software package
Fully on the user computer, partly execute on the user computer;Partly exist on the user computer and partly
It is executed on remote computer;Or it fully executes on a remote computer or server.It in the latter case, can will be remote
Journey computer by include local area network (LAN) or wide area network (WAN) any type of network connection to subscriber computer, or
(such as internet by using ISP) can be attached with outer computer.
It is above-mentioned according to the method for the embodiment of the present invention, the flow chart legend of equipment (system) and computer program product and/
Or block diagram describes various aspects of the invention.It will be appreciated that each of flow chart legend and/or block diagram piece and process
The combination of block in figure legend and/or block diagram can be realized by computer program instructions.These computer program instructions can be with
It is provided to the processor of general purpose computer, special purpose computer or other programmable data processing devices, to generate machine, so that
(being executed via computer or the processor of other programmable data processing devices) instruction creation for realizing flow chart and/or
The device for the function action specified in block diagram or block.
These computer program instructions can also be stored in can instruct computer, other programmable data processing devices
Or in the computer-readable medium that runs in a specific way of other devices, so that the instruction stored in computer-readable medium produces
Raw includes the product for realizing the instruction for the function action specified in flowchart and or block diagram block or block.
Computer program instructions can also be loaded on computer, other programmable data processing devices or other devices
On so that executed on computer, other programmable devices or other devices it is a series of can operating procedure come generate computer reality
Existing process, so that the instruction executed on computer or other programmable devices is provided for realizing in flow chart and/or frame
The process for the function action specified in segment or block.
The above description is only a preferred embodiment of the present invention, is not intended to restrict the invention, for those skilled in the art
For, the invention can have various changes and changes.All any modifications made within the spirit and principles of the present invention are equal
Replacement, improvement etc., should all be included in the protection scope of the present invention.
The embodiment of the present disclosure discloses A1, a method of label SQL statement, comprising:
SQL statement in SQL execution journal is classified as to the SQL statement of at least one type;
Efficiency analysis is carried out to the SQL statement of any type in the SQL statement of at least one type, is determined
Corresponding efficiency analysis result;
It is marked according to SQL statement of the efficiency analysis result to any type.
A2, method according to a1, the SQL statement by SQL execution journal are classified as at least one type
SQL statement specifically includes:
SQL statement in SQL execution journal is classified as to the SQL statement of at least one type according to setting rule.
A3, the method according to A2, the setting rule include:
The SQL statement is identical or the syntactic structure of the SQL statement is identical.
A4, method according to a1, any type in the SQL statement at least one type
SQL statement carries out efficiency analysis, determines corresponding efficiency analysis as a result, specifically including:
Obtain influence line number of each SQL statement implementing result of the SQL statement of any type to database;
Ratio of the SQL statement that calculating influence line number is zero in the SQL statement of affiliated type.
A5, method according to a4, according to the efficiency analysis result to the SQL statement of any type into
Line flag specifically includes:
It is if the ratio is greater than or equal to first threshold, the SQL statement of any type is excellent labeled as needing
Change;
It is if the ratio is less than the first threshold, the SQL statement of any type is excellent labeled as not needing
Change.
A6, method according to a1, any type in the SQL statement at least one type
SQL statement carries out efficiency analysis, determines corresponding efficiency analysis as a result, specifically including:
Determine that the invalid SQL statement for including in the SQL statement of any type executes number, wherein described invalid
SQL statement, which is attached most importance to, recurs the SQL statement sent or incomplete SQL statement or illegal SQL statement.
A7, the method according to A6, according to the efficiency analysis result to the SQL statement of any type into
Line flag specifically includes:
If the execution number is greater than or equal to second threshold, the SQL statement of any type is labeled as needing
Optimize;
If the execution number is less than the second threshold, the SQL statement of any type is labeled as being not required to
Optimize.
A8, the method according to A6, the invalid SQL statement execute number according to the SQL language of any type
Sentence executes the sum of number, and the ratio-dependent of the invalid SQL statement described in the sum for executing number.
The embodiment of the present disclosure also discloses B1, a kind of device for marking SQL statement, comprising:
Sort out unit, for the SQL statement in SQL execution journal to be classified as to the SQL statement of at least one type;
Determination unit, the SQL statement for any type in the SQL statement at least one type have
The analysis of effect property, determines corresponding efficiency analysis result;
Processing unit, for being marked according to SQL statement of the efficiency analysis result to any type.
B2, the device according to B1, the classification unit are specifically used for:
SQL statement in SQL execution journal is classified as to the SQL statement of at least one type according to setting rule.
B3, the device according to B2, the setting rule include:
The SQL statement is identical or the syntactic structure of the SQL statement is identical.
B4, the device according to B1, the determination unit are specifically used for:
Obtain influence line number of each SQL statement implementing result of the SQL statement of any type to database;
Ratio of the SQL statement that calculating influence line number is zero in the SQL statement of affiliated type.
B5, the device according to B4, the processing unit are specifically used for:
It is if the ratio is greater than or equal to first threshold, the SQL statement of any type is excellent labeled as needing
Change;
It is if the ratio is less than the first threshold, the SQL statement of any type is excellent labeled as not needing
Change.
B6, the device according to B1, the determination unit are specifically used for:
Determine that the invalid SQL statement for including in the SQL statement of any type executes number, wherein described invalid
SQL statement, which is attached most importance to, recurs the SQL statement sent or incomplete SQL statement or illegal SQL statement.
B7, the device according to B6, the processing unit are specifically used for:
If the execution number is greater than or equal to second threshold, the SQL statement of any type is labeled as needing
Optimize;
If the execution number is less than the second threshold, the SQL statement of any type is labeled as being not required to
Optimize.
B8, the device according to B6, the invalid SQL statement execute number according to the SQL language of any type
Sentence executes the sum of number, and the ratio-dependent of the invalid SQL statement described in the sum for executing number.
The embodiment of the present disclosure also discloses C1, a kind of computer readable storage medium, stores computer program instructions thereon,
The computer program instructions realize such as the described in any item methods of A1-A8 when being executed by processor.
The embodiment of the present disclosure also discloses D1, a kind of electronic equipment, including memory and processor, and the memory is used for
Store one or more computer program instructions, wherein one or more computer program instructions are held by the processor
Row is to realize the method as described in any one of A1-A8.
Claims (10)
1. a kind of method for marking SQL statement characterized by comprising
SQL statement in SQL execution journal is classified as to the SQL statement of at least one type;
Efficiency analysis is carried out to the SQL statement of any type in the SQL statement of at least one type, determines and corresponds to
Efficiency analysis result;
It is marked according to SQL statement of the efficiency analysis result to any type.
2. the method as described in claim 1, which is characterized in that the SQL statement by SQL execution journal is classified as at least
A type of SQL statement, specifically includes:
SQL statement in SQL execution journal is classified as to the SQL statement of at least one type according to setting rule.
3. method according to claim 2, which is characterized in that the setting rule includes:
The SQL statement is identical or the syntactic structure of the SQL statement is identical.
4. the method as described in claim 1, which is characterized in that appointing in the SQL statement at least one type
A type of SQL statement carries out efficiency analysis, determines corresponding efficiency analysis as a result, specifically including:
Obtain influence line number of each SQL statement implementing result of the SQL statement of any type to database;
Ratio of the SQL statement that calculating influence line number is zero in the SQL statement of affiliated type.
5. method as claimed in claim 4, which is characterized in that according to the efficiency analysis result to any type
SQL statement be marked, specifically include:
If the ratio is greater than or equal to first threshold, the SQL statement of any type is labeled as needing to optimize;
If the ratio is less than the first threshold, the SQL statement of any type is labeled as not needing to optimize.
6. the method as described in claim 1, which is characterized in that appointing in the SQL statement at least one type
A type of SQL statement carries out efficiency analysis, determines corresponding efficiency analysis as a result, specifically including:
Determine that the invalid SQL statement for including in the SQL statement of any type executes number, wherein the invalid SQL language
Sentence, which is attached most importance to, recurs the SQL statement sent or incomplete SQL statement or illegal SQL statement.
7. method as claimed in claim 6, which is characterized in that according to the efficiency analysis result to any type
SQL statement be marked, specifically include:
It is if the execution number is greater than or equal to second threshold, the SQL statement of any type is excellent labeled as needing
Change;
It is if the execution number is less than the second threshold, the SQL statement of any type is excellent labeled as not needing
Change.
8. a kind of device for marking SQL statement characterized by comprising
Sort out unit, for the SQL statement in SQL execution journal to be classified as to the SQL statement of at least one type;
Determination unit, the SQL statement for any type in the SQL statement at least one type carry out validity
Analysis, determines corresponding efficiency analysis result;
Processing unit, for being marked according to SQL statement of the efficiency analysis result to any type.
9. a kind of computer readable storage medium, stores computer program instructions thereon, which is characterized in that the computer program
The method according to claim 1 to 7 is realized in instruction when being executed by processor.
10. a kind of electronic equipment, including memory and processor, which is characterized in that the memory is for storing one or more
Computer program instructions, wherein one or more computer program instructions are executed by the processor to realize such as power
Benefit requires method described in any one of 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810963162.3A CN109325043B (en) | 2018-08-22 | 2018-08-22 | Method and device for marking SQL (structured query language) statements and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810963162.3A CN109325043B (en) | 2018-08-22 | 2018-08-22 | Method and device for marking SQL (structured query language) statements and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109325043A true CN109325043A (en) | 2019-02-12 |
CN109325043B CN109325043B (en) | 2021-07-16 |
Family
ID=65264688
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810963162.3A Active CN109325043B (en) | 2018-08-22 | 2018-08-22 | Method and device for marking SQL (structured query language) statements and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109325043B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050065925A1 (en) * | 2003-09-23 | 2005-03-24 | Salesforce.Com, Inc. | Query optimization in a multi-tenant database system |
CN104123354A (en) * | 2014-07-15 | 2014-10-29 | 大连大学 | Query optimization method based on MySOL database |
CN105653607A (en) * | 2015-12-23 | 2016-06-08 | 北京奇虎科技有限公司 | SQL (Structured Query Language) log collection and analysis method and device |
CN107368582A (en) * | 2017-07-21 | 2017-11-21 | 深信服科技股份有限公司 | A kind of SQL statement detection method and system |
CN107563193A (en) * | 2017-08-28 | 2018-01-09 | 深信服科技股份有限公司 | Access and control strategy of database method and system based on SQL templates |
CN107748782A (en) * | 2017-10-20 | 2018-03-02 | 北京小度信息科技有限公司 | Query statement processing method and processing device |
-
2018
- 2018-08-22 CN CN201810963162.3A patent/CN109325043B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050065925A1 (en) * | 2003-09-23 | 2005-03-24 | Salesforce.Com, Inc. | Query optimization in a multi-tenant database system |
CN104123354A (en) * | 2014-07-15 | 2014-10-29 | 大连大学 | Query optimization method based on MySOL database |
CN105653607A (en) * | 2015-12-23 | 2016-06-08 | 北京奇虎科技有限公司 | SQL (Structured Query Language) log collection and analysis method and device |
CN107368582A (en) * | 2017-07-21 | 2017-11-21 | 深信服科技股份有限公司 | A kind of SQL statement detection method and system |
CN107563193A (en) * | 2017-08-28 | 2018-01-09 | 深信服科技股份有限公司 | Access and control strategy of database method and system based on SQL templates |
CN107748782A (en) * | 2017-10-20 | 2018-03-02 | 北京小度信息科技有限公司 | Query statement processing method and processing device |
Also Published As
Publication number | Publication date |
---|---|
CN109325043B (en) | 2021-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111506801B (en) | Sequencing method and device for application App neutron application | |
CN112800095B (en) | Data processing method, device, equipment and storage medium | |
CN108768840A (en) | A kind of method and apparatus of account management | |
CN110516248A (en) | Method for correcting error of voice identification result, device, storage medium and electronic equipment | |
CN113986933A (en) | Materialized view creating method and device, storage medium and electronic equipment | |
CN107908615A (en) | A kind of method and apparatus for obtaining search term corresponding goods classification | |
CN103425727A (en) | Contextual voice query dilation | |
CN107480268A (en) | Data query method and device | |
CN110781183A (en) | Method and device for processing incremental data in Hive database and computer equipment | |
CN110990350B (en) | Log analysis method and device | |
CN110795069A (en) | Code analysis method, intelligent terminal and computer readable storage medium | |
CN107329583A (en) | A kind of method and apparatus for calculating associational word priority | |
CN106919576A (en) | Using the method and device of two grades of classes keywords database search for application now | |
CN107729001A (en) | A kind of expression processing method and apparatus | |
CN111435406A (en) | Method and device for correcting database statement spelling errors | |
CN110362583A (en) | A kind of data processing method and device for multi-data source | |
CN110019802A (en) | A kind of method and apparatus of text cluster | |
CN107562941A (en) | Data processing method and its system | |
CN109325043A (en) | A kind of method, apparatus and electronic equipment marking SQL statement | |
CN110727759B (en) | Method and device for determining theme of voice information | |
CN107273293B (en) | Big data system performance test method and device and electronic equipment | |
CN107368500A (en) | Data pick-up method and system | |
CN107291749A (en) | A kind of determination method and device of data target incidence relation | |
CN110019531A (en) | A kind of method and apparatus obtaining analogical object set | |
CN110032574A (en) | The processing method and processing device of SQL statement |
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 | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: Room 202, 2 floors, 1-3 floors, No. 11 Shangdi Information Road, Haidian District, Beijing 100085 Applicant after: Beijing Xingxuan Technology Co.,Ltd. Address before: Room 202, 2 floors, 1-3 floors, No. 11 Shangdi Information Road, Haidian District, Beijing 100085 Applicant before: Beijing Xiaodu Information Technology Co.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |