CN109325043B - Method and device for marking SQL (structured query language) statements and electronic equipment - Google Patents

Method and device for marking SQL (structured query language) statements and electronic equipment Download PDF

Info

Publication number
CN109325043B
CN109325043B CN201810963162.3A CN201810963162A CN109325043B CN 109325043 B CN109325043 B CN 109325043B CN 201810963162 A CN201810963162 A CN 201810963162A CN 109325043 B CN109325043 B CN 109325043B
Authority
CN
China
Prior art keywords
sql
type
statements
sentences
marking
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.)
Active
Application number
CN201810963162.3A
Other languages
Chinese (zh)
Other versions
CN109325043A (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 Xingxuan Technology Co Ltd
Original Assignee
Beijing Xingxuan 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 Xingxuan Technology Co Ltd filed Critical Beijing Xingxuan Technology Co Ltd
Priority to CN201810963162.3A priority Critical patent/CN109325043B/en
Publication of CN109325043A publication Critical patent/CN109325043A/en
Application granted granted Critical
Publication of CN109325043B publication Critical patent/CN109325043B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The method, the device and the electronic equipment are used for solving the problems that invalid request statements cannot be filtered in subsequent processing, the processing and responding efficiency and speed of the valid request statements are low, and the user experience is poor due to the fact that the invalid request statements cannot be marked in the prior art. The method comprises the following steps: classifying SQL sentences in the SQL execution log into at least one type of SQL sentences; and carrying out effectiveness analysis on any type of SQL sentences in the at least one type of SQL sentences, determining corresponding effectiveness analysis results, and marking any type of SQL sentences according to the effectiveness analysis results.

Description

Method and device for marking SQL (structured query language) statements and electronic equipment
Technical Field
The present disclosure relates to the field of databases, and in particular, to a method and an apparatus for marking SQL statements, and an electronic device.
Background
With the development of internet technology, there are more and more merchants using internet platforms to provide services for users, and more users using internet platforms, and users often Query and search contents of interest of themselves, and these Query and search operations are expressed as request statements, which may also be called Structured Query Language (SQL) statements, on a database level.
In the prior art, all request statements sent by a user are received and executed, but in practical applications, not all request statements sent by the user are valid, and some invalid request statements, such as repeatedly sent request statements, incomplete request statements, or illegal request statements, are also included, and processing and responding to the invalid request statements causes waste of resources, and affects efficiency and speed of processing and responding to other valid request statements.
In summary, how to mark the invalid request statement is a problem that needs to be solved at present, which is convenient for filtering the invalid request statement in subsequent processing, improves the efficiency and speed of processing and responding to the valid request statement, and improves user experience.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, and an electronic device for marking an SQL statement, so as to mark an invalid request statement, facilitate filtering of the invalid request statement in subsequent processing, improve efficiency and speed of processing and responding of an valid request statement, and improve user experience.
According to a first aspect of the embodiments of the present invention, there is provided a method for marking an SQL statement, including: classifying SQL sentences in the SQL execution log into at least one type of SQL sentences; and carrying out effectiveness analysis on any type of SQL sentences in the at least one type of SQL sentences, determining corresponding effectiveness analysis results, and marking any type of SQL sentences according to the effectiveness analysis results.
In an embodiment, the classifying the SQL statements in the SQL execution log into at least one type of SQL statements specifically includes: and classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences according to set rules.
In one embodiment, the setting of the rule includes: the SQL sentences are the same or the syntax structures of the SQL sentences are the same.
In an embodiment, the performing validity analysis on any one type of SQL statement in the at least one type of SQL statement to determine a corresponding validity analysis result specifically includes: acquiring the number of influencing lines of each SQL statement execution result of any type of SQL statement on a database; and calculating the proportion of the SQL sentences with the influencing line numbers of zero in the SQL sentences of the belonged types.
In one embodiment, marking any type of SQL statement according to the validity analysis result specifically includes: if the proportion is larger than or equal to a first threshold value, marking the SQL statement of any type as needing optimization; if the proportion is smaller than the first threshold value, the SQL statements of any type are marked as not needing optimization.
In an embodiment, the performing validity analysis on any one type of SQL statement in the at least one type of SQL statement to determine a corresponding validity analysis result specifically further includes: and determining the execution times of invalid SQL statements contained in the SQL statements of any type, wherein the invalid SQL statements are SQL statements sent repeatedly, or incomplete SQL statements, or illegal SQL statements.
In one embodiment, marking any type of SQL statement according to the validity analysis result specifically includes:
if the execution times is larger than or equal to a second threshold value, marking the SQL statement of any type as needing optimization; if the execution times are less than the second threshold value, marking the SQL statement of any type as not needing optimization.
In one embodiment, the execution times of the invalid SQL statements are determined according to the total number of execution times of the SQL statements of any type and the proportion of the invalid SQL statements in the total number of execution times.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for marking an SQL statement, including: the classification unit is used for classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences; the determining unit is used for carrying out validity analysis on any type of SQL sentences in the at least one type of SQL sentences and determining corresponding validity analysis results; and the processing unit is used for marking any type of SQL statement according to the effectiveness analysis result.
In one embodiment, the classification unit is specifically configured to:
and classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences according to set rules.
In one embodiment, the setting of the rule includes: the SQL sentences are the same or the syntax structures of the SQL sentences are the same.
In one embodiment, the determining unit is specifically configured to: acquiring the number of influencing lines of each SQL statement execution result of any type of SQL statement on a database; and calculating the proportion of the SQL sentences with the influencing line numbers of zero in the SQL sentences of the belonged types.
In one embodiment, the processing unit is specifically configured to: if the proportion is larger than or equal to a first threshold value, marking the SQL statement of any type as needing optimization; if the proportion is smaller than the first threshold value, the SQL statements of any type are marked as not needing optimization.
In one embodiment, the determining unit is specifically configured to: and determining the execution times of invalid SQL statements contained in the SQL statements of any type, wherein the invalid SQL statements are SQL statements sent repeatedly, or incomplete SQL statements, or illegal SQL statements.
In one embodiment, the processing unit is specifically configured to: if the execution times is larger than or equal to a second threshold value, marking the SQL statement of any type as needing optimization; if the execution times are less than the second threshold value, marking the SQL statement of any type as not needing optimization.
In one embodiment, the execution times of the invalid SQL statements are determined according to the total number of execution times of the SQL statements of any type and the proportion of the invalid SQL statements in the total number of execution times.
According to a third aspect of embodiments of the present invention, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement a method as described in the first aspect or any of the embodiments of the first aspect.
According to a fourth aspect of embodiments of the present invention, there is provided an electronic device comprising a memory and a processor, the memory being configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method as described in the first aspect or any of the embodiments of the first aspect.
In the embodiment of the invention, the SQL sentences in the SQL execution logs are classified into at least one type of SQL sentences, then the effectiveness analysis is carried out on any type of SQL sentences in the at least one type of SQL sentences, and the SQL sentences of any type are marked according to the effectiveness analysis result. Because any type of SQL statement is marked, invalid request statements can be conveniently filtered in subsequent processing, resources for processing the invalid request statements are saved, and network load is reduced, so that the processing and responding efficiency and speed of the valid request statements are improved, and user experience is improved.
Drawings
The above and other objects, features and advantages of the embodiments of the present invention will become more apparent from the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
fig. 1 is a flowchart of a method for marking SQL statements according to an embodiment of the present invention;
FIG. 2 is a flow chart of another method for marking SQL statements provided by the embodiment of the invention;
fig. 3 is a schematic diagram of a display page of an analysis front end of an SQL statement optimization result according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an apparatus for marking SQL statements according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described below based on examples, but the present invention is not limited to only these examples. In the following detailed description of the present invention, certain specific details are set forth. It will be apparent to one skilled in the art that the present invention may be practiced without these specific details. Well-known methods, procedures, components and circuits have not been described in detail so as not to obscure the present invention.
Further, those of ordinary skill in the art will appreciate that the drawings provided herein are for illustrative purposes and are not necessarily drawn to scale.
Unless the context clearly requires otherwise, throughout the description and the claims, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is, what is meant is "including, but not limited to".
In the description of the embodiments of the present invention, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Further, in the description of the embodiments of the present invention, "a plurality" means two or more unless otherwise specified.
Fig. 1 is a flowchart of a method for marking SQL statements according to an embodiment of the present invention. As shown in fig. 1, the method for marking SQL statements includes:
and S100, classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences.
The SQL execution log may also be a database execution log, which may be a database middleware log, or a summary of logs of each data node of the distributed database.
Optionally, the SQL statements in the SQL execution log are classified into at least one type of SQL statements according to a set rule, specifically, the set rule includes: the SQL sentences are the same or the syntax structures of the SQL sentences are the same. The method is characterized in that the same SQL sentences in the SQL sentences of the SQL execution log are classified into one category, or the SQL sentences of the database with the same syntax structure but different query conditions are classified into one category.
For example, in example 1, the same SQL statements in the SQL execution log are classified into one type, and assuming that the operation indicated by the SQL statements is to update the phone number record, for example, the phone number of the third update is 13800001111, all the SQL statements in the database with the phone number of the third update being 13800001111 are classified into one type; example 2, the SQL statements in the SQL execution log, which have the same syntax structure but different query conditions, are classified into one type, and assuming that the SQL statements are for updating the phone number record, all the indicated operations in the SQL execution log are as follows: "update the SQL statement of the syntax structure of xx telephone number xxxxxxxxx" to be a classification; wherein, Zhang three and 13800001111 in example 1 are query conditions.
In the embodiment of the present invention, the SQL statement may also be referred to as a request statement sent by a user, which is not limited in the embodiment of the present invention.
Step S101, carrying out validity analysis on any type of SQL sentences in the at least one type of SQL sentences, and determining corresponding validity analysis results.
Specifically, the validity analysis is to analyze the number of times of executing an invalid SQL statement in any type of SQL statement or analyze the proportion of SQL statements in any type of SQL statement that have no influence on the number of rows in the database, that is, analyze the proportion of valid SQL statements in any type of SQL statement or the number of times of executing valid SQL statements, and further determine whether any type of SQL statement needs to be optimized.
Optionally, the validity analysis of any type of SQL statement may be performed in two ways, including:
the method comprises the steps that firstly, the number of influencing lines of each SQL statement execution result of any type of SQL statement on a database is obtained; and calculating the proportion of the SQL sentences with the influencing line numbers of zero in the SQL sentences of the belonged types.
Specifically, assuming that any type of SQL statement is 13800001111 for updating the telephone number of zhang san, but the telephone number of zhang san in the original telephone number record is also "13800001111", the SQL statement is executed to update the telephone number of zhang san, but the telephone numbers before and after updating are the same, i.e., there is no influence on the number of lines of the telephone number record stored in the database, or the user "zhang san" corresponding to the updated telephone number "13800001111" does not exist in the telephone number record stored in the database itself, so there is no influence on the number of lines of the telephone number record stored in the database, and assuming that the number of any type of SQL statement is 10000 sentences, and the SQL statement having no influence on the number of lines of the telephone number record stored in the database is 3000 sentences, the ratio is 30%.
And secondly, determining the execution times of invalid SQL statements contained in any type of SQL statements, wherein the invalid SQL statements are SQL statements which are repeatedly sent, or incomplete SQL statements, or illegal SQL statements.
Specifically, the execution times of the invalid SQL statements are determined according to the total number of the execution times of the SQL statements of any type and the proportion of the invalid SQL statements in the total number of the execution times.
For example, any type of SQL statement may be type a or type B, and it is assumed that the SQL statement of type a is executed 1000 times a day, where the proportion of the invalid SQL statement is 80%, the execution time of the invalid SQL statement is 800, the SQL statement of type B is executed 10 ten thousand times a day, where the proportion of the invalid SQL statement is 50%, and the execution time of the invalid SQL statement is 5 ten thousand times, where the time period is 1 day in the above example, and may also be other times, which is not limited by the embodiment of the present invention.
And S102, marking any type of SQL statement according to the effectiveness analysis result.
Specifically, it is determined whether to mark any type of SQL statement according to the validity analysis result determined in step S101, for example, in the first manner, if the proportion of SQL statements having zero influence on the number of rows in the database in any type of SQL statement exceeds a first threshold, any type of SQL statement is marked as needed for optimization, and if the proportion of SQL statements does not exceed the first threshold, any type of SQL statements is marked as not needed for optimization, where the first threshold may be 30%, 50%, or 70%, which is not limited in the embodiment of the present invention. The specific optimization mode is that it is assumed that any type of SQL statement before optimization is 1000 ten thousand, and any type of SQL statement after optimization is 800 ten thousand. In the second mode, if the number of times of execution of the invalid SQL statements included in any type of SQL statements exceeds the second threshold, any type of SQL statements is marked as requiring optimization, and if the number of times of execution of any type of SQL statements does not exceed the second threshold, any type of SQL statements is marked as not requiring optimization, for example, the SQL statements of type a are executed 1000 times a day, wherein the occupation ratio of the invalid SQL statements is 80%, the number of times of execution of the invalid SQL statements is 800, the SQL statements of type B are executed 10 ten thousand times a day, wherein the occupation ratio of the invalid SQL statements is 50%, the number of times of execution of the invalid SQL statements is 5 ten thousand times, although the occupation ratio of the invalid SQL statements of type a is high, the number of times of execution of the invalid SQL statements is small, and therefore, the SQL statements of type B can be marked as not being optimized, while the occupation ratio of the invalid SQL statements of type B is small compared with type a, therefore, the mark is optimized.
In the embodiment of the invention, the SQL sentences in the SQL execution logs are classified into at least one type of SQL sentences, then the effectiveness analysis is carried out on any type of SQL sentences in the at least one type of SQL sentences, and the SQL sentences of any type are marked according to the effectiveness analysis result. Because any type of SQL statement is marked, invalid request statements can be effectively filtered in subsequent processing, resources for processing the invalid request statements are saved, and network load is reduced, so that the processing and responding efficiency and speed of the valid request statements are improved, and user experience is improved.
In the following, a method for marking an SQL statement is described in detail through a specific embodiment, as shown in fig. 2, in this embodiment, an SQL statement in an SQL execution log for updating a phone number record is selected to perform validity analysis, and the specific steps are as follows:
step S200, classifying SQL sentences in the SQL execution log according to the same syntax structure, and determining a type of SQL sentences which are used for updating the telephone number records, wherein the telephone number records to be updated are shown in the following table 1:
TABLE 1
Name (I) Telephone number
Zhang San 13800001111
Li Si 13800001112
Wang Wu 13800001113
Zhao Yi 13800001114
Money two 13800001115
Sun Liu 13800001116
Radix seu folium Pruni Salicinae 13800001117
ZhouBa wine 13800001118
Wujiu 13800001119
Deng Ten 13800001110
Step S201, performing validity analysis on the SQL statement with the type of updating the phone number record.
Specifically, it is assumed that the SQL statement of the type for updating the phone number record includes 10 SQL statements, for example, the operation indicated by the SQL statement is as follows: "the telephone number of update Zhan is 13800001111", "the telephone number of update Li Si is 13800001112", "the telephone number of update Wang is 13800001113", "the telephone number of update Zhao I is 13800001000", "the telephone number of update Qian II is 13800001001", "the telephone number of update Sun Liu is 13800001002", "the telephone number of update Li Qin is 13800001117", "the telephone number of update Wedneigh is 13800001118", "the telephone number of update Wujiu is 13800001119", and "the telephone number of update Zhengnine is 13800001110". Updated table 2 is generated as follows:
TABLE 2
Name (I) Telephone number
Zhang San 13800001111
Li Si 13800001112
Wang Wu 13800001113
Zhao Yi 13800001000
Money two 13800001001
Sun Liu 13800001002
Radix seu folium Pruni Salicinae 13800001117
ZhouBa wine 13800001118
Wujiu 13800001119
Deng Ten 13800001110
Step S202, determining the proportion of SQL sentences with zero influence on the table 1 in the SQL sentences of which the types are the updated telephone number records.
Specifically, as can be seen from table 1 and table 2 and the SQL statement of the type for updating the phone number records, the SQL statement with zero influence on table 1 is 7 statements, and accounts for 70% of 10 statements in total.
Step S203, judging whether the proportion is larger than or equal to a first threshold value.
Step S204, if the proportion is larger than or equal to a first threshold value, the SQL statement of which the type is the update telephone number record is marked as needing to be optimized;
if the proportion is smaller than a first threshold value, the SQL statement of which the type is the update telephone number record is marked as not needing optimization.
And marking the SQL statement of which the type is the updated telephone number record as the SQL statement needing optimization under the condition that a first threshold is set to be 50 percent and the proportion is larger than the first threshold.
After step S204, the method further includes: sending the marked SQL statement with the type of updating the telephone number record to a background for optimization, wherein the operation indicated by the optimized SQL statement with the type of updating the telephone number record is as follows: "update the phone number of zhao yi is 13800001000", "update the phone number of qian bi is 13800001001", and "update the phone number of sunxi is 13800001002", where the background may be a device that sends the SQL statement, and after receiving the SQL statement that is recorded with a flag and is of a type of updating a phone number, the device that sends the SQL statement performs optimization processing, and does not receive invalid SQL statements sent by a user any more after the processing, for example: the telephone number of Zhang III is 13800001111, the telephone number of Lle IV is 13800001112, the telephone number of Uwang V is 13800001113, etc.
Optionally, if the proportion of the SQL statements whose influence on table 1 is zero in the SQL statements of which the type is the updated phone number record is smaller than the first threshold, the SQL statements are marked as not requiring optimization.
The embodiment of the invention optimizes the marked SQL sentences, and displays the result after the optimization on a front-end display page, wherein the schematic diagram of the front-end display page is shown in FIG. 3, for example, SQL sentence 1, sentence Q before optimization, sentence Q after optimization, number M before optimization and number M after optimization; SQL statement 2, statement P before optimization and statement P after optimization, number N before optimization and number N after optimization, and so on, wherein the specific conditions of Q, Q, M, M, P, P, N, N are displayed in practical application according to practical application, and the disclosure is only exemplary.
Fig. 4 is a schematic diagram of an apparatus for marking an SQL statement according to an embodiment of the present invention. As shown in fig. 4, the apparatus for labeling an SQL statement of the present embodiment includes a classifying unit 41, a determining unit 42, and a processing unit 43.
The classifying unit 41 is configured to classify the SQL statements in the SQL execution log into at least one type of SQL statements; a determining unit 42, configured to perform validity analysis on any type of SQL statements in the at least one type of SQL statements, and determine a validity analysis result; and the processing unit 43 is configured to mark the SQL statement of any type according to the validity analysis result.
Further, the classifying unit 41 is specifically configured to: and classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences according to set rules.
Preferably, the setting rule includes: the SQL sentences are the same or the syntax structures of the SQL sentences are the same.
In this embodiment of the present invention, the determining unit 42 is specifically configured to: acquiring the number of influencing lines of each SQL statement execution result of any type of SQL statement on a database;
and calculating the proportion of the SQL sentences with the influencing line numbers of zero in the SQL sentences of the belonged types.
Further, the processing unit 43 is specifically configured to:
if the proportion is larger than or equal to a first threshold value, marking the SQL statement of any type as needing optimization; if the proportion is smaller than the first threshold value, the SQL statements of any type are marked as not needing optimization.
Preferably, the determining unit 42 is specifically configured to: and determining the execution times of invalid SQL statements contained in the SQL statements of any type, wherein the invalid SQL statements are SQL statements sent repeatedly, or incomplete SQL statements, or illegal SQL statements.
Optionally, the processing unit 43 is specifically configured to:
if the execution times is larger than or equal to a second threshold value, marking the SQL statement of any type as needing optimization;
if the execution times are less than the second threshold value, marking the SQL statement of any type as not needing optimization.
Further, the execution times of the invalid SQL statements are determined according to the total number of the execution times of the SQL statements of any type and the proportion of the invalid SQL statements in the total number of the execution times.
Fig. 5 is a schematic diagram of an electronic device of an embodiment of the invention. The electronic device shown in fig. 5 is a general-purpose data processing apparatus comprising a general-purpose computer hardware structure including at least a processor 51 and a memory 52. The processor 51 and the memory 52 are connected by a bus 53. The memory 52 is adapted to store instructions or programs executable by the processor 51. The processor 51 may be a stand-alone microprocessor or a collection of one or more microprocessors. Thus, the processor 51 implements the processing of data and the control of other devices by executing instructions stored by the memory 52 to perform the method flows of embodiments of the present invention as described above. The bus 53 connects the above components together, and also connects the above components to a display controller 54 and a display device and an input/output (I/O) device 55. Input/output (I/O) devices 55 may be a mouse, keyboard, modem, network interface, touch input device, motion sensing input device, printer, and other devices known in the art. Typically, the input/output device 55 is connected to the system through an input/output (I/O) controller 56.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or computer program product. Accordingly, various aspects of the present invention may take the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a "circuit," module "or" system. Further, aspects of the invention may take the form of: a computer program product embodied in one or more computer readable media having computer readable program code embodied thereon.
Any combination of one or more computer-readable media may be utilized. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including, but not limited to: electromagnetic, optical, or any suitable combination thereof. The computer readable signal medium may be any of the following computer readable media: is not a computer readable storage medium and may communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including: object oriented programming languages such as Java, Smalltalk, C + +, and the like; and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package; executing in part on a user computer and in part on a remote computer; or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention described above describe various aspects of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (14)

1. A method of marking SQL statements, comprising:
classifying SQL sentences in the SQL execution log into at least one type of SQL sentences;
carrying out validity analysis on any type of SQL sentences in the at least one type of SQL sentences to determine corresponding validity analysis results;
marking any type of SQL statement according to the effectiveness analysis result;
wherein, the performing validity analysis on any type of SQL statements in the at least one type of SQL statements and determining a corresponding validity analysis result specifically includes:
acquiring the number of influencing lines of each SQL statement execution result of any type of SQL statement on a database;
calculating the proportion of the SQL sentences with the influence line numbers of zero in the SQL sentences of the types to which the SQL sentences belong; alternatively, the first and second electrodes may be,
and determining the execution times of invalid SQL statements contained in the SQL statements of any type, wherein the invalid SQL statements are SQL statements sent repeatedly, or incomplete SQL statements, or illegal SQL statements.
2. The method of claim 1, wherein classifying the SQL statements in the SQL execution log into at least one type of SQL statements comprises:
and classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences according to set rules.
3. The method of claim 2, wherein setting the rule comprises:
the SQL sentences are the same or the syntax structures of the SQL sentences are the same.
4. The method according to claim 1, wherein marking any type of SQL statement according to the validity analysis result specifically comprises:
if the proportion is larger than or equal to a first threshold value, marking the SQL statement of any type as needing optimization;
if the proportion is smaller than the first threshold value, the SQL statements of any type are marked as not needing optimization.
5. The method according to claim 1, wherein marking any type of SQL statement according to the validity analysis result specifically comprises:
if the execution times is larger than or equal to a second threshold value, marking the SQL statement of any type as needing optimization;
if the execution times are less than the second threshold value, marking the SQL statement of any type as not needing optimization.
6. The method of claim 1, wherein said number of executions of invalid SQL statements is determined from a total number of executions of said any type of SQL statements and a proportion of said invalid SQL statements in said total number of executions.
7. An apparatus for marking SQL statements, comprising:
the classification unit is used for classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences;
the determining unit is used for carrying out validity analysis on any type of SQL sentences in the at least one type of SQL sentences and determining corresponding validity analysis results;
wherein the determining unit is specifically configured to: acquiring the number of influencing lines of each SQL statement execution result of any type of SQL statement on a database;
calculating the proportion of the SQL sentences with the influence line numbers of zero in the SQL sentences of the types to which the SQL sentences belong; alternatively, the first and second electrodes may be,
determining the execution times of invalid SQL statements contained in any type of SQL statements, wherein the invalid SQL statements are SQL statements sent repeatedly, or incomplete SQL statements, or illegal SQL statements;
and the processing unit is used for marking any type of SQL statement according to the effectiveness analysis result.
8. The apparatus of claim 7, wherein the classification unit is specifically configured to:
and classifying the SQL sentences in the SQL execution log into at least one type of SQL sentences according to set rules.
9. The apparatus of claim 8, wherein the setting a rule comprises:
the SQL sentences are the same or the syntax structures of the SQL sentences are the same.
10. The apparatus as claimed in claim 7, wherein said processing unit is specifically configured to:
if the proportion is larger than or equal to a first threshold value, marking the SQL statement of any type as needing optimization;
if the proportion is smaller than the first threshold value, the SQL statements of any type are marked as not needing optimization.
11. The apparatus as claimed in claim 7, wherein said processing unit is specifically configured to:
if the execution times is larger than or equal to a second threshold value, marking the SQL statement of any type as needing optimization;
if the execution times are less than the second threshold value, marking the SQL statement of any type as not needing optimization.
12. The apparatus of claim 7, wherein the number of times the invalid SQL statement executes is determined according to a total number of times the any type of SQL statement executes, and a proportion of the invalid SQL statement in the total number of times the execution occurs.
13. A computer-readable storage medium on which computer program instructions are stored, which computer program instructions, when executed by a processor, implement the method of any one of claims 1-6.
14. An electronic device comprising a memory and a processor, wherein the memory is configured to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method of any of claims 1-6.
CN201810963162.3A 2018-08-22 2018-08-22 Method and device for marking SQL (structured query language) statements and electronic equipment Active CN109325043B (en)

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 CN109325043A (en) 2019-02-12
CN109325043B true 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)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7529728B2 (en) * 2003-09-23 2009-05-05 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
CN105653607B (en) * 2015-12-23 2019-05-07 北京奇虎科技有限公司 SQL log collection analysis method and device
CN107368582B (en) * 2017-07-21 2020-12-22 深信服科技股份有限公司 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
CN109325043A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
CN110908997B (en) Data blood relationship construction method and device, server and readable storage medium
US20120254193A1 (en) Processing Data in a Mapreduce Framework
CN110019087B (en) Data processing method and system
CN108255620B (en) Service logic processing method, device, service server and system
CN109933514B (en) Data testing method and device
CN110990447B (en) Data exploration method, device, equipment and storage medium
CN109450969B (en) Method and device for acquiring data from third-party data source server and server
CN114091426A (en) Method and device for processing field data in data warehouse
CN114461644A (en) Data acquisition method and device, electronic equipment and storage medium
CN112328805A (en) Entity mapping method of vulnerability description information and database table based on NLP
CN110990350A (en) Log analysis method and device
WO2018205391A1 (en) Method, system and apparatus for evaluating accuracy of information retrieval, and computer-readable storage medium
CN109325043B (en) Method and device for marking SQL (structured query language) statements and electronic equipment
US11334908B2 (en) Advertisement detection method, advertisement detection apparatus, and storage medium
CN107329956B (en) Project information standardization method and device
CN112434115B (en) Data processing method and device, electronic equipment and readable storage medium
CN114218283A (en) Abnormality detection method, apparatus, device, and medium
CN109241742B (en) Malicious program identification method and electronic device
CN113779017A (en) Method and apparatus for data asset management
CN112307050B (en) Identification method and device for repeated correlation calculation and computer system
CN113901094B (en) Data processing method, device, equipment and storage medium
CN114584616B (en) Message pushing method and device, electronic equipment and storage medium
CN114172725B (en) Illegal website processing method and device, electronic equipment and storage medium
CN110851438A (en) Database index optimization suggestion and verification method and device
CN114185890B (en) Database retrieval method and device, storage medium and electronic equipment

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

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.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant