CN114372076A - SQL query method, device, equipment, storage medium and program product - Google Patents

SQL query method, device, equipment, storage medium and program product Download PDF

Info

Publication number
CN114372076A
CN114372076A CN202111575206.3A CN202111575206A CN114372076A CN 114372076 A CN114372076 A CN 114372076A CN 202111575206 A CN202111575206 A CN 202111575206A CN 114372076 A CN114372076 A CN 114372076A
Authority
CN
China
Prior art keywords
sql
statement
preset
database
query
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111575206.3A
Other languages
Chinese (zh)
Inventor
吴冕冠
王磊
谢伟
王豪赞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202111575206.3A priority Critical patent/CN114372076A/en
Publication of CN114372076A publication Critical patent/CN114372076A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/248Presentation of query results
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Mathematical Physics (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure provides a method, an apparatus, a device, a storage medium and a program product for SQL query, which relates to the technical field of big data; the SQL query method comprises the following steps: acquiring a preset statement list, wherein the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement; intercepting SQL sentences which access a database, and matching the SQL sentences with preset sentences; and when the SQL statement is matched with the preset statement, directly outputting a corresponding query result.

Description

SQL query method, device, equipment, storage medium and program product
Technical Field
The present disclosure relates to the field of big data technologies, and in particular, to a method, an apparatus, a device, a storage medium, and a program product for SQL query.
Background
Structured Query Language (SQL), a special purpose programming Language, is a database Query and programming Language for accessing data and querying, updating, and managing relational database systems.
For slow SQL, the traditional optimization method is to analyze the syntax and semantics of SQL, check the execution efficiency of SQL statements, and then optimize the SQL statements for the part with lower execution efficiency, so as to improve the efficiency and speed of SQL query. The method can optimize the SQL execution efficiency to a certain extent, but for complex and variable connection queries, because the complex and variable connection queries involve operations with high time consumption such as aggregation, the code optimization of static SQL has an upper limit, and many complex queries cannot achieve the capability of quick query even after being optimized.
Disclosure of Invention
In view of the above problems, the present disclosure provides an SQL query method, apparatus, device, storage medium and program product, which aim to solve the problem that SQL codes cannot be queried quickly.
According to a first aspect of the present disclosure, there is provided an SQL query method, comprising the steps of:
acquiring a preset statement list, wherein the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement;
intercepting SQL sentences which access a database, and matching the SQL sentences with preset sentences;
and when the SQL statement is matched with the preset statement, directly outputting a corresponding query result.
According to the embodiment of the disclosure, when the SQL statement does not match the preset statement, the SQL statement is released to access the database.
According to the embodiment of the disclosure, when the SQL statement does not match the preset statement, the step of releasing the SQL statement to access the database further includes:
recording the content and the access time of the SQL statement, and acquiring a return result and the return time of the database;
measuring and calculating the execution time consumption of the SQL statement according to the access time and the return time;
and when the execution time consumption exceeds a time threshold, storing the SQL statement and the return result into a preset statement list so as to add a new preset statement and a new query result.
According to the embodiment of the disclosure, a new preset statement and a new query result form an item to be clustered, and the preset statement and the query result form a comparison item;
the step of saving the SQL statement and the return result to a preset statement list comprises the following steps:
clustering the items to be clustered and the comparison items to obtain clustering results;
and storing the clustering result to a preset statement list.
According to the embodiment of the disclosure, the step of intercepting the SQL statement for accessing the database comprises the following steps:
analyzing the type of the database;
and selecting an interception method for intercepting SQL sentences accessing the database according to the type of the database.
According to an embodiment of the present disclosure, before the step of resolving the type of the database, the method further comprises:
and the system is mounted on the database middleware and forms real-time communication with the database.
According to an embodiment of the present disclosure, after the step of selecting an interception method of intercepting an SQL statement that accesses a database, the method further includes:
and saving the type of the database.
A second aspect of the present disclosure provides an SQL query apparatus, including:
the data storage module is used for acquiring a preset statement list, and the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement;
the data interception module is used for intercepting SQL sentences which access the database and matching the SQL sentences with preset sentences; and the number of the first and second groups,
and the data matching module is used for directly outputting a corresponding query result when the SQL statement is matched with the preset statement.
A third aspect of the present disclosure provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the SQL query method described above.
A third aspect of the present disclosure provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the SQL query method described above.
A fourth aspect of the present disclosure provides a computer program product comprising a computer program for execution by a processor of the above-described SQL query method.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram of an SQL query method, apparatus, device, medium and program product according to an embodiment of the disclosure;
FIG. 2 schematically illustrates a flow diagram of a SQL query method according to an embodiment of the disclosure;
FIG. 3 schematically shows a flowchart of an embodiment of step S30 in FIG. 2;
FIG. 4 schematically shows a flowchart of an embodiment of step S33 in FIG. 3;
FIG. 5 schematically shows a flowchart of an embodiment of step S20 in FIG. 2;
FIG. 6 schematically shows a flowchart of a second embodiment of step S20 in FIG. 5;
FIG. 7 schematically shows a flowchart of a third embodiment of step S20 in FIG. 5;
FIG. 8 schematically illustrates a software flow diagram of a particular embodiment of the disclosed SQL query method;
FIG. 9 schematically shows a block diagram of the structure of an SQL query device according to an embodiment of the disclosure;
FIG. 10 schematically illustrates a block diagram of an embodiment of the data matching module of FIG. 9;
FIG. 11 is a block diagram that schematically illustrates an embodiment of the save unit of FIG. 10;
FIG. 12 is a block diagram that schematically illustrates an embodiment of the data interception module of FIG. 9;
FIG. 13 is a block diagram schematically illustrating the structure of a second embodiment of the data interception module of FIG. 9;
FIG. 14 is a block diagram schematically illustrating a third embodiment of the data interception module in FIG. 9;
FIG. 15 schematically illustrates a block diagram of an electronic device adapted to implement the SQL query method, according to an embodiment of the disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, necessary security measures are taken, and the customs of the public order is not violated.
The embodiment of the disclosure provides an SQL query method, which comprises the following steps:
acquiring a preset statement list, wherein the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement;
intercepting SQL sentences which access a database, and matching the SQL sentences with the preset sentences;
and when the SQL statement is matched with the preset statement, directly outputting the corresponding query result, or when the SQL statement is not matched with the preset statement, releasing the SQL statement to access a database.
Fig. 1 schematically shows an application scenario diagram of an SQL query method and apparatus according to an embodiment of the present disclosure.
As shown in fig. 1, the application scenario according to this embodiment may include a financial service field. Network 102 is the medium used to provide communication links between terminal devices 101 and server 103. Network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal device 101 to interact with server 103 over network 102 to receive or send messages and the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (for example only) may be installed on the terminal device 101.
The terminal device 101 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 103 may be a server that provides various services, such as a background management server (for example only) that provides support for websites browsed by users using the terminal devices 101. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the SQL query method provided by the embodiment of the present disclosure may be generally executed by the server 103. Accordingly, the information prompting device provided by the embodiment of the present disclosure may be generally disposed in the server 103. The SQL query method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 103 and is capable of communicating with the terminal device 101 and/or the server 103. Accordingly, the information prompting device provided in the embodiment of the present disclosure may also be disposed in a server or a server cluster that is different from the server 103 and is capable of communicating with the terminal device 101 and/or the server 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Hereinafter, based on the scenario described in fig. 1, the SQL query method according to the disclosed embodiment will be described in detail with fig. 2 to 5.
Fig. 2 schematically shows a flow chart of an SQL query method according to an embodiment of the present disclosure.
As shown in fig. 2, the SQL query method of the embodiment, which may be executed by the SQL query device, includes steps S10 to S30.
In operation S10, a preset statement list is obtained, where the preset statement list includes at least one preset statement and a query result corresponding to the preset statement;
intercepting an SQL statement for accessing the database and matching the SQL statement with a preset statement in operation S20;
in operation S30, when the SQL statement matches the preset statement, the corresponding query result is directly output.
In the technical scheme provided by the disclosure, the preset statement list comprises the preset statements, in this embodiment, the preset statements are SQL with low execution efficiency and low speed, and in the process of accessing the database, when the accessed SQL statements are matched with the preset statements, the statements are proved to be slow SQL, and query results are directly extracted from the preset statement list for the SQL statements, so that more time is not required to be consumed for database query, the slow result query speed of the SQL is greatly improved, and the user experience of application is improved. Compared with the traditional slow SQL performance improvement scheme, the scheme does not need to analyze the reasons of low execution efficiency of different slow SQL one by one, and does not need to customize different optimization schemes for different SQL, so that the investment of manpower and material resources is greatly reduced, and the pressure of the database is greatly reduced.
On the other hand, in this embodiment, the SQL query method further includes:
in operation S40, when the SQL statement does not match the preset statement, the SQL statement is released to access the database.
When the accessed SQL statement is not matched with the preset statement, the SQL statement is indicated to belong to a fast statement or a new unreported statement, and the SQL statement needs to normally access the database so as to obtain a result required by the SQL statement and avoid abnormal query caused by the existence of an SQL query device.
Further, referring to fig. 3, in order to facilitate the use of the SQL query method, the method further includes, after step S40, increasing the number of the preset statements in the preset statement list:
s41, recording the content and the access time of the SQL statement, and acquiring the return result and the return time of the database;
s42, calculating the execution time consumption of the SQL statement according to the access time and the return time;
and S43, when the execution time consumption exceeds the time threshold, saving the SQL sentences and the return results to a preset sentence list so as to add new preset sentences and new query results.
In this embodiment, according to a preset time threshold, SQL statements that are not in a preset statement list and access a database are detected, and when the time consumed for SQL execution exceeds the time threshold, the SQL statements are considered as slow SQL, and for the slow SQL, the obtained return result is cached. Therefore, if the SQL to be executed is detected to be in the preset statement list, the result can be directly taken out from the cache without repeatedly consuming a large amount of time to query the database, so that the query efficiency is improved, the preset statements in the preset statement list can be continuously updated along with the increase of the query times, and the use effect of the preset statement list is improved.
Further, referring to fig. 4, in order to store the new preset statement and the new query result, the new preset statement and the new query result form a to-be-clustered item, and the preset statement and the query result form a comparison item, step S43 includes:
s431, clustering the items to be clustered and the comparison items to obtain clustering results;
and S432, storing the clustering result to a preset statement list.
In the embodiment, the new preset sentences and the new query results which are the same as the preset sentences and the query results are regarded as the same type, the new preset sentences and the new query results are clustered, the clustered clustering results are cached, a preset sentence list is convenient to store, the capacity of the preset sentences is improved, and the clustered cluster group is convenient to query and match the preset sentence list.
On the other hand, referring to fig. 5, step S20 includes:
and S21, analyzing the type of the database, and selecting an interception method for intercepting the SQL statement accessing the database according to the type of the database.
The types of the databases are different, SQL sentences adopted when the databases are accessed are also different, the types of the databases are detected in advance before interception, an interception method is selected according to the types, the SQL sentences can be successfully intercepted, and the database system is convenient to adapt to more different database systems.
Further, referring to fig. 6, before step S21, the method includes:
s201, mounting to a database middleware, and forming real-time communication with a database.
In this embodiment, the method and the system are dynamically mounted with a database middleware, such as jdbc and ojdbc, to realize communication with the database, and establish a connection with the database in a mounting manner, so that the method and the system are conveniently added to the existing database, and the operation of the existing database is not affected.
Referring to fig. 7, after step S21, the method further includes:
and S22, saving the type of the database.
And recording the database consulted by the SQL query method, so that subsequent operators can conveniently query and adjust and update the SQL query method.
Referring to fig. 8, an embodiment of the present disclosure is provided based on the SQL query method.
1. Mounting into a database;
2. analyzing the type of the database, and acquiring a method for intercepting SQL according to the type of the database;
3. intercepting SQL sentences;
4. matching the preset statement list with the SQL, and judging whether the SQL statement is contained in the preset statement list;
5. when the SQL statement is contained in a preset statement list, directly outputting a corresponding query result; and when the SQL sentence is not contained in the preset sentence list, releasing the SQL sentence to access the database, detecting the execution time consumption of the SQL sentence, and clustering and storing the SQL sentence and the corresponding return result when the SQL execution time consumption exceeds a time threshold.
In the present embodiment, the SQL query method and the database middleware such as jdbc,oAnd the jdbc is dynamically mounted to realize communication with the database middleware of the target application program.
When the application program accesses the database, all SQL statements are intercepted, the current time and the content of the SQL statements are recorded, when the SQL statements are returned to the application program after the database is operated, the SQL code acceleration tool also records the returned time, and the execution time consumption of different SQL is measured.
Meanwhile, according to a preset slow SQL execution time threshold, when the actual SQL execution time consumption exceeds the threshold, the SQL is considered as slow SQL, clustering is carried out on the slow SQL according to SQL sentences and query results (the SQL with the same SQL query sentences and query results are considered as the same type), then the query results of the clustered SQL sentences are cached, and therefore if the subsequent S detects that the SQL to be executed is in the clustered SQL preset sentence list, the results can be directly taken out from the cache without repeatedly consuming a large amount of time to query the database. On one hand, the mechanism improves the query efficiency of SQL and simultaneously lightens the query pressure of the database.
Based on the above SQL query method, the present disclosure also provides an SQL query apparatus, which will be described in detail below with reference to fig. 9.
Fig. 9 schematically shows a structural block diagram of an SQL query device according to an embodiment of the present disclosure.
As shown in fig. 9, an SQL query device 200 of the present embodiment includes a data storage module 1, a data interception module 2, and a data matching module 3; the data storage module 1 is used for acquiring a preset statement list, wherein the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement; the data interception module 2 is used for intercepting SQL sentences for accessing the database and matching the SQL sentences with preset sentences; the data matching module 3 is used for directly outputting a corresponding query result when the SQL statement is matched with the preset statement, or releasing the SQL statement to access the database when the SQL statement is not matched with the preset statement.
Further, referring to fig. 10, the data matching module 3 further includes a recording unit 31, a calculating unit 32 and a storing unit 33; the recording unit 31 is used for recording the content and the access time of the SQL statement and acquiring the return result and the return time of the database; the measuring and calculating unit 32 is used for measuring and calculating the execution time consumption of the SQL statement according to the access time and the return time; the saving unit 33 is configured to save the SQL statement and the returned result to the preset statement list when the execution time exceeds the time threshold, so as to add a new preset statement and a new query result.
Further, referring to fig. 11, the storing unit 33 further includes a clustering subunit 331 and a sending subunit 332; the clustering subunit 331 is configured to cluster the to-be-clustered item and the comparison item to obtain a clustering result; the sending subunit 332 is configured to store the clustering result in a preset statement list.
On the other hand, referring to fig. 12, the data interception module 2 includes an analysis unit 21, and the analysis unit 21 is configured to analyze the type of the database, and select an interception method for intercepting the SQL statement accessing the database according to the type of the database.
Further, referring to fig. 13, the data interception module 2 further includes a mounting unit 201, and the mounting unit 201 is used for mounting to the database middleware and forming real-time communication with the database.
In addition, referring to fig. 14, the data interception module 2 further includes a storage unit 22, and the storage unit 22 is used for storing the type of the database.
Any number of modules, sub-modules, units, sub-units, or at least part of the functionality of any number thereof according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware implementations. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
Fig. 15 schematically illustrates a block diagram of an electronic device adapted for the SQL query method according to an embodiment of the disclosure.
As shown in fig. 15, the electronic device 300 according to the embodiment of the present disclosure includes a processor 3001, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)3002 or a program loaded from a storage section 3008 into a Random Access Memory (RAM) 3003. The processor 3001 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 3001 may also include on-board memory for caching purposes. The processor 3001 may include a single processing unit or multiple processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 3003, various programs and data necessary for the operation of the electronic apparatus 300 are stored. The processor 3001, the ROM 3002, and the RAM 3003 are connected to each other by a bus 3004. The processor 3001 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 3002 and/or the RAM 3003. Note that the program may also be stored in one or more memories other than the ROM 3002 and the RAM 3003. The processor 3001 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in one or more memories.
According to an embodiment of the present disclosure, electronic device 300 may also include an input/output (I/O) interface 3005, input/output (I/O) interface 3005 also connected to bus 3004. The electronic device 300 may also include one or more of the following components connected to the I/O interface 3005: an input portion 3006 including a keyboard, a mouse, and the like; an output section 3007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 3008 including a hard disk and the like; and a communication section 3009 including a network interface card such as a LAN card, a modem, or the like. The communication section 3009 performs communication processing via a network such as the internet. Drivers 3010 are also connected to I/O interface 3005 as needed. A removable medium 3011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 3010 as necessary, so that a computer program read out therefrom is mounted in the storage section 3008 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: 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), 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 present disclosure, 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. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include one or more memories other than the ROM 3002 and/or the RAM 3003 and/or the ROM 3002 and the RAM 3003 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated in the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the SQL query method provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 3001. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted in the form of a signal on a network medium, distributed, downloaded and installed via the communication section 3009, and/or installed from the removable medium 3011. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 3009, and/or installed from the removable medium 3011. The computer program performs the above-described functions defined in the system of the embodiment of the present disclosure when executed by the processor 3001. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.
The above-mentioned embodiments are intended to illustrate the objects, aspects and advantages of the present disclosure in further detail, and it should be understood that the above-mentioned embodiments are only illustrative of the present disclosure and are not intended to limit the present disclosure, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.

Claims (11)

1. An SQL query method is characterized by comprising the following steps:
acquiring a preset statement list, wherein the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement;
intercepting SQL sentences which access a database, and matching the SQL sentences with the preset sentences; and the number of the first and second groups,
and when the SQL statement is matched with the preset statement, directly outputting the corresponding query result.
2. The SQL query method of claim 1, wherein the method further comprises:
and when the SQL statement is not matched with the preset statement, releasing the SQL statement to access the database.
3. The SQL query method of claim 2, wherein when the SQL statement does not match the preset statement, the step of releasing the SQL statement to access the database further comprises, after:
recording the content and the access time of the SQL statement, and acquiring the return result and the return time of the database;
measuring and calculating the execution time consumption of the SQL statement according to the access time and the return time;
and when the execution time consumption exceeds a time threshold, storing the SQL statement and the return result to the preset statement list so as to add a new preset statement and a new query result.
4. The SQL query method according to claim 3, wherein the new preset statement and the new query result form a to-be-clustered item, and the preset statement and the query result form a comparison item;
the step of saving the SQL statement and the return result to a preset statement list comprises the following steps:
clustering the items to be clustered and the comparison items to obtain clustering results; and the number of the first and second groups,
and storing the clustering result to the preset statement list.
5. The SQL query method of claim 1, wherein the step of intercepting SQL statements that access a database comprises:
analyzing the type of the database; and
and selecting an interception method for intercepting SQL sentences accessing the database according to the type of the database.
6. The SQL query method of claim 5, wherein prior to the step of parsing the type of the database, the method further comprises:
and the system is mounted on a database middleware and forms real-time communication with the database.
7. The SQL query method of claim 5, wherein after the step of selecting an interception method that intercepts SQL statements that access a database, the method further comprises:
and storing the type of the database.
8. An SQL query device, comprising:
the data storage module is used for acquiring a preset statement list, and the preset statement list comprises at least one preset statement and a query result corresponding to the preset statement;
the data interception module is used for intercepting SQL sentences which access a database and matching the SQL sentences with the preset sentences; and the number of the first and second groups,
and the data matching module is used for directly outputting the corresponding query result when the SQL statement is matched with the preset statement.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-7.
10. A computer-readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 7.
11. A computer program product, characterized in that it comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 7.
CN202111575206.3A 2021-12-21 2021-12-21 SQL query method, device, equipment, storage medium and program product Pending CN114372076A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111575206.3A CN114372076A (en) 2021-12-21 2021-12-21 SQL query method, device, equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111575206.3A CN114372076A (en) 2021-12-21 2021-12-21 SQL query method, device, equipment, storage medium and program product

Publications (1)

Publication Number Publication Date
CN114372076A true CN114372076A (en) 2022-04-19

Family

ID=81139175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111575206.3A Pending CN114372076A (en) 2021-12-21 2021-12-21 SQL query method, device, equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN114372076A (en)

Similar Documents

Publication Publication Date Title
US10963470B2 (en) Website scoring system
US8935293B2 (en) Framework for dynamically generating tuple and page classes
CN113535773B (en) Database optimization method, database optimization device, electronic device and storage medium
US11645179B2 (en) Method and apparatus of monitoring interface performance of distributed application, device and storage medium
CN111125107A (en) Data processing method, device, electronic equipment and medium
CN115587575A (en) Data table creation method, target data query method, device and equipment
US20230194302A1 (en) Method of updating map data, electronic device and storage medium
CN114254389A (en) Message desensitization method, device, electronic equipment and medium
US9639583B2 (en) Caching predefined data for mobile dashboard
EP3642727B1 (en) Resource pre-fetch using age threshold
CN114372076A (en) SQL query method, device, equipment, storage medium and program product
CN115437899A (en) Cluster fault prediction method and device, electronic equipment and medium
CN114546786A (en) Anomaly monitoring method based on multi-level cache
CN114201508A (en) Data processing method, data processing apparatus, electronic device, and storage medium
CN114443663A (en) Data table processing method, device, equipment and medium
CN113688160A (en) Data processing method, processing device, electronic device and storage medium
CN113449886A (en) Data processing method, processing device, equipment and storage medium
US9904707B1 (en) Systems and methods for optimized database sampling
CN113392199A (en) Keyword search method, keyword search device, electronic device, and storage medium
CN115794462A (en) Database monitoring method, device, equipment and storage medium
CN115033416A (en) Method and device for determining abnormal information, electronic equipment and storage medium
CN114564408A (en) Reason analysis method, apparatus, electronic device, medium, and computer program product
CN113392142A (en) Method, device, equipment, medium and product for calculating hit rate of IP address library
US9600505B2 (en) Code optimization based on customer logs
CN113760893A (en) Instruction control method, apparatus, computer system, and computer-readable storage medium

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