SQL statement optimization method, device and equipment and storage medium

An optimization method and statement technology, applied in the database field, can solve the problems of low performance and low query efficiency, and achieve the effect of reducing the query scope, reducing the query scale, and improving the query execution efficiency.

Pending Publication Date: 2021-01-29
SHANGHAI DAMENG DATABASE
View PDF0 Cites 3 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Because it is convenient to use according to actual needs later, the query scope of CTE is relatively large, so that the data processed in the CTE clause will generally be more. There are more filtered data, so the query efficiency will be lower

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • SQL statement optimization method, device and equipment and storage medium
  • SQL statement optimization method, device and equipment and storage medium
  • SQL statement optimization method, device and equipment and storage medium

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0059] figure 1 It is a flow chart of a SQL statement optimization method provided by Embodiment 1 of the present invention. This embodiment is applicable to the situation of optimizing SQL statements including common expressions, and the method can be executed by the SQL statement optimization device in the embodiment of the present invention. , the device can be implemented in the form of software and / or hardware, as shown in Figure 1, the method specifically includes the following steps:

[0060] S110, acquiring an SQL query statement input by a user.

[0061] Specifically, the SQL query statement input by the user is obtained, and the syntax analysis is performed on the SQL query statement input by the user.

[0062] S120. If the SQL query statement satisfies a first preset condition, obtain an optimizeable view in the SQL query statement, where the optimizeable view includes a common expression.

[0063] Specifically, if the SQL query statement satisfies the first prese...

Embodiment 2

[0083] figure 2 It is a flow chart of a SQL statement optimization method in Embodiment 2 of the present invention. This embodiment is optimized based on the above embodiments. In this embodiment, the target filter condition is determined according to the optimizeable view, including: if There is an equivalence connection condition in the optimizeable view, and one side of the equivalence connection condition is a public expression, and one side of the equivalence connection condition is a single object, then the first filter condition is determined according to the single object; An IN expression is determined by using the equivalence connection condition and the first filter condition; and the final filter condition is determined according to the IN expression.

[0084] Such as figure 2 As shown, the method of this embodiment specifically includes the following steps:

[0085] S210, acquiring the SQL query statement input by the user.

[0086] S220. If the SQL query sta...

Embodiment 3

[0122] image 3 It is a schematic structural diagram of an SQL statement optimization device provided by Embodiment 3 of the present invention. This embodiment can be applicable to the situation that comprises the SQL statement optimization of common expression, and this device can adopt the mode of software and / or hardware to realize, and this device can be integrated in any equipment that provides the function of SQL statement optimization, such as image 3 As shown, the apparatus for optimizing SQL statements specifically includes: a first obtaining module 310 , a second obtaining module 320 , a determining module 330 and an adding module 340 .

[0123] Wherein, the first obtaining module 310 is used to obtain the SQL query statement input by the user;

[0124] The second acquiring module 320 is configured to acquire an optimizeable view in the SQL query statement if the SQL query statement satisfies a first preset condition, wherein the optimizeable view includes a common...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses an SQL statement optimization method, device and equipment and a storage medium. The method comprises the steps of obtaining an SQL query statement input by a user; if the SQLquery statement meets a first preset condition, obtaining an optimizable view in the SQL query statement, wherein the optimizable view comprises a public expression; determining a final filtering condition according to the optimizable view; adding the final filtering condition into a target view to complete SQL statement optimization. According to the method disclosed in the technical scheme, filtering conditions can be added to the public expression to optimize SQL statements, the query range of the public expression is reduced, and therefore the query scale of the intermediate result set isreduced, and the query execution efficiency of the whole statement is improved.

Description

technical field [0001] The embodiments of the present invention relate to the technical field of databases, in particular to a method, device, equipment and storage medium for optimizing SQL statements. Background technique [0002] Structured Query Language (SQL) is a database operation language used to access data and query, update and manage relational database systems. [0003] If there are too many levels of nested SQL statements, it will make the SQL statements difficult to read and maintain. Therefore, a SQL statement will be used to define a common expression (CTE, COMMON TABLE EXPRESSION), which will be used repeatedly in the entire SQL query, which can improve the maintainability of the SQL statement, and at the same time, the CTE is better than the temporary table Much more efficient. Therefore, the CTE query is a common query in the database. [0004] Usually, the database first collects the data in the CTE for use in subsequent statements. Because it is conv...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F16/2453
CPCG06F16/2453
Inventor 扈天阳朱仲颖韩朱忠
Owner SHANGHAI DAMENG DATABASE
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products