CN117171206A - Query method, query device, electronic equipment and storage medium - Google Patents

Query method, query device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117171206A
CN117171206A CN202311196402.9A CN202311196402A CN117171206A CN 117171206 A CN117171206 A CN 117171206A CN 202311196402 A CN202311196402 A CN 202311196402A CN 117171206 A CN117171206 A CN 117171206A
Authority
CN
China
Prior art keywords
filtering
query
complexity
selectivity
data
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
CN202311196402.9A
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.)
Shanghai Dameng Database Co Ltd
Original Assignee
Shanghai Dameng Database 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 Shanghai Dameng Database Co Ltd filed Critical Shanghai Dameng Database Co Ltd
Priority to CN202311196402.9A priority Critical patent/CN117171206A/en
Publication of CN117171206A publication Critical patent/CN117171206A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a query method, a query device, electronic equipment and a storage medium. The method comprises the following steps: acquiring an initial query sentence, wherein the initial query sentence comprises at least two filtering conditions; sequencing the filtering conditions according to the execution complexity of the filtering conditions to obtain a target query statement; and executing the target query statement to obtain a query result. According to the technical scheme, the target query statement is obtained through sequential adjustment of the filtering conditions in the initial query statement, so that the execution complexity is reduced, the query times are reduced, the query process is optimized, the performance of the query process is better, and the query efficiency is improved.

Description

Query method, query device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of databases, in particular to a query method, a query device, electronic equipment and a storage medium.
Background
With the development of the internet and big data, the data query speed becomes more and more important. The existing data query mode is that a server generates a corresponding query instruction according to the filtering condition, and searches data corresponding to the query instruction from a database. However, when the amount of data to be searched corresponding to the query instruction is large and complex, the implementation process of the query instruction is complicated, and a great amount of time is required for performing the query, so that the data to be queried cannot be obtained in time.
Disclosure of Invention
The invention provides a query method, a query device, electronic equipment and a storage medium, so as to realize efficient data query.
In a first aspect, an embodiment of the present invention provides a query method, including:
acquiring an initial query sentence, wherein the initial query sentence comprises at least two filtering conditions;
sequencing the filtering conditions according to the execution complexity of the filtering conditions to obtain a target query statement;
and executing the target query statement to obtain a query result.
In a second aspect, an embodiment of the present invention provides a query apparatus, including:
the acquisition module is used for acquiring an initial query statement, wherein the initial query statement comprises at least two filtering conditions;
the ordering module is used for ordering the filtering conditions according to the execution complexity of the filtering conditions to obtain target query sentences;
and the execution module is used for executing the target query statement to obtain a query result.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the query method as described in the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the query method according to the first aspect.
The embodiment of the invention provides a query method, a query device, electronic equipment and a storage medium, wherein an initial query statement is firstly obtained, and the initial query statement comprises at least two filtering conditions; sequencing the filtering conditions according to the execution complexity of the filtering conditions to obtain a target query statement; and finally, executing the target query statement to obtain a query result. According to the technical scheme, the target query statement is obtained through sequential adjustment of the filtering conditions in the initial query statement, so that the execution complexity is reduced, the query times are reduced, the query process is optimized, the performance of the query process is better, and the query efficiency is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a flowchart of a query method according to a first embodiment of the present invention;
fig. 2 is a schematic structural diagram of a query device according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. Furthermore, embodiments of the invention and features of the embodiments may be combined with each other without conflict. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts steps as a sequential process, many of the steps may be implemented in parallel, concurrently, or with other steps. Furthermore, the order of the steps may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
It should be noted that the concepts of "first," "second," and the like in the embodiments of the present invention are merely used to distinguish between different devices, modules, units, or other objects, and are not intended to limit the order or interdependence of functions performed by the devices, modules, units, or other objects.
Example 1
Fig. 1 is a flowchart of a query method according to a first embodiment of the present invention, where the present embodiment is applicable to a case of efficiently querying data. In particular, the querying method may be performed by a querying device, which may be implemented in software and/or hardware and integrated in an electronic device. Further, the electronic device includes, but is not limited to: desktop computers, notebook computers, smart phones, servers, and other electronic devices.
As shown in fig. 1, the method specifically includes the following steps:
s110, acquiring an initial query statement, wherein the initial query statement comprises at least two filtering conditions.
In this embodiment, a query term may be understood as a term used to retrieve data satisfying a condition from a database, and one of the most basic and most important terms in the database may be, for example, a query term in a structured query language (Structured Query Language, SQL). SQL is understood as a database language with multiple functions such as data manipulation and data definition. The filtering condition may be understood as a statement OR instruction located in the query statement for screening the database for data meeting a specific requirement, AND may be, for example, a filtering condition containing AND/OR.
For example, the user may obtain an initial query statement, e.g., SELECT c1+1FROM T1 WHERE C2>5AND C3 LIKE '%123%' according to actual needs, where C2>5and C3 LIKE '%123%' is a filtering condition. The initial query term means that a data table has three columns, the second column (C2) is greater than 5, and the value of the first column (C1) of the corresponding row containing "123" in the string of the third column (C3) is added with 1, and then the initial query term is selected, so that when the initial query term is executed by the server, the general execution plan is as follows:
PROJECT (calculate C1+1);
select_filter (FILTERs data for c2>5and C3 lie '%123%');
TABLE_SCAN (data from columns C1/C2/C3 is obtained).
S120, sorting the filtering conditions according to the execution complexity of the filtering conditions to obtain a target query statement.
In this embodiment, the execution complexity may be understood as a value indicating the complexity or difficulty level of the server executing the query statement.
Illustratively, when the initial query statement is SELECT c1+1FROM T1 WHERE C2>5AND C3 LIKE '%123%' the general execution plan of the query statement when executed by the server is:
PROJECT (calculate C1+1);
select_filter (FILTERs data for c2>5and C3 lie '%123%');
TABLE_SCAN (data from columns C1/C2/C3 is obtained).
The invention can optimize the selection_filter step for the data from bottom to top transmission when executing the execution plan.
For the filtering condition C2>5AND C3 LIKE '%123%', the server generates corresponding instruction to execute calculation C2 column data and 5 to compare, if the comparison value is TRUE, then executing the calculation instruction of C3 LIKE '%123%' again, otherwise, the calculation is not needed to be continued, and the row data can be directly abandoned without output. If both return values are TRUE, then the line of data need to be returned up.
The implementation process has performance problems, and consider the following scenes: the data in the C2 column of the data table T1 are all greater than 5, but no row of data satisfies LIKE '%123%', then the execution sequence of C2>5and C3 LIKE '%123%' has a significant impact. If the implementation process is still performed normally, all data lines need to be filtered AND performed by C2>5AND C3 LIKE '%123%', but if the filtering condition exchange sequence is changed to be C3 LIKE '%123%' AND C2>5, all data lines need to be performed by C3 LIKE '%123%' in the same way, but no data line needs to be calculated by C2>5, so that the performance is obviously better.
Similarly, the filter conditional expression for the OR type is similar, but the factor that determines the decision to be made in order is somewhat different from the AND type. If the filtering condition is still C2>5OR C3 LIKE '%123%', the scene to be adjusted is not AND, AND all data are required to meet C2>5, AND no data meet C3 LIKE '% 123%'; in contrast, the case where no data satisfies C2>5and all data satisfies C3 lie '%123%' is the case when C3 lie '%123%' OR C2>5 performs better than C2>5OR C3 lie '% 123%'s.
Therefore, the invention can adjust the sequence of each filtering condition through the calculated execution complexity of each filtering condition so as to reduce the query times, further reduce the execution complexity, optimize the query process and be beneficial to improving the query efficiency.
Illustratively, the complete filter term expression BOOL_EXP is processed. If the type of the BOOL_EXP is AND/OR, the execution complexity of each branch is obtained for each branch of the AND/OR, the execution complexity of the BOOL_EXP is accumulated by the execution complexity of each branch, AND the execution complexity of the BOOL_EXP is set to the expression of the BOOL_EXP. After the BOOL_EXP is processed AND the execution complexity is set, traversing the branches of the AND/OR of the BOOL_EXP again, AND sequencing the branches of the BOOL_EXP according to the execution complexity from small to large. Similarly, if the single branch itself is also an AND/OR, the execution complexity determination continues recursively AND the branches are ordered. After the order of the branches of the bool_exp is adjusted, that is, the target query statement is obtained. Wherein a branch may represent a filtering condition.
S130, executing the target query statement to obtain a query result.
The method includes the steps that firstly, a user can obtain an initial query statement according to actual requirements, then, the execution complexity of each filtering condition is calculated according to each filtering condition in the initial query statement, the filtering conditions are arranged in the order from small to large according to the execution complexity to form a target query statement, and finally, a server can be used for executing the target query statement to obtain a query result.
The first query method provided by the embodiment of the invention comprises the steps of firstly, acquiring an initial query sentence, wherein the initial query sentence comprises at least two filtering conditions; sequencing the filtering conditions according to the execution complexity of the filtering conditions to obtain a target query statement; and finally, executing the target query statement to obtain a query result. According to the technical scheme, the target query statement is obtained through sequential adjustment of the filtering conditions in the initial query statement, so that the execution complexity is reduced, the query times are reduced, the query process is optimized, the performance of the query process is better, and the query efficiency is improved.
Optionally, before sorting the filtering conditions according to the execution complexity of the filtering conditions, the method further includes:
determining the calculation complexity and the filtering selectivity of the filtering conditions aiming at the single filtering conditions;
and determining the execution complexity of the filtering condition according to the calculation complexity and the filtering selection rate.
In one embodiment, computational complexity may be understood as a measure of the computational resources (e.g., time or space) consumed by the filtering conditions in execution or runtime. The filter selection rate can be understood as the probability of selection of the filter conditions.
The calculation complexity can be set by roughly counting the number of execution assembly instruction lines of various types of filtering conditions when the filtering conditions are executed and comparing all types to obtain a relative value; the filtering selectivity can be obtained according to common auxiliary means (such as statistical information).
Optionally, determining the computational complexity of the filtering condition includes:
and determining the computational complexity of the filtering condition according to the expression type of the filtering condition.
In one embodiment, the expression types may include a numeric comparison type, a type involving a function operation, or a type of search string matching a specified pattern, etc. The numerical comparison type can be, for example, C1=1, C1> 5, 0 < C1< 5, etc.; the function operation type may be, for example, FUNC (C1) >5; the type of the character string matching the specified pattern may be, for example, C1 LIKE% >, C1 NOT LIKE% >. It should be noted that, the calculation complexity of the numerical comparison type and the character string type is relatively low, but the calculation complexity related to the function operation type is relatively high; the numerical comparison type has higher computational complexity of 0 < C1< 5 than C1> 5, and the specific computational complexity can be determined according to actual requirements.
For example, if the type of a single branch in the complete expression of the filter term is not an AND/OR type, the computational complexity may be obtained according to the expression type of the filter term AND a preset value. The preset value may be understood as a preset computational complexity for a specific expression type of the filtering condition.
Optionally, determining the filtering selectivity of the filtering condition includes:
reading statistical information of a data table to be queried, wherein the statistical information comprises data quantity meeting filtering conditions in the data table and total data quantity of the data table;
and taking the ratio of the data quantity meeting the filtering condition to the total data quantity as the filtering selectivity of the filtering condition.
In one embodiment, a data table may be understood as a grid virtual table that temporarily holds data. The statistical information may include the data amount satisfying the filtering condition in the data table and the total data amount of the data table, and may further include a pre-calculated ratio of the data amount satisfying the filtering condition to the total data amount.
For a more common filtering condition expression, such as C1>1 or C1< = 10 or C1 IN (1, 2, 3), the total data amount N of the data table and the data amount M meeting the filtering condition can be obtained according to the statistical information, and the filtering selectivity B of a single filtering condition is the ratio of the data amount meeting the filtering condition to the total data amount, i.e., b=m/N.
For example, in an idle period, some common statistics may be performed on each data table in the database, for example, statistics may be recorded on how much data is smaller than C1 in a certain column in the data table, how much first name is in last name, how much function operation result is in a preset interval, and statistical information may be recorded, where a ratio of a data amount satisfying a filtering condition to a total data amount is taken as a filtering selectivity of the filtering condition, or a ratio of a pre-calculated data amount satisfying the filtering condition to the total data amount may be stored in the data table as statistical information, and when a query statement is executed, the filtering selectivity of the filtering condition may be directly determined according to the statistical information.
Optionally, determining the filtering selectivity of the filtering condition includes:
if the expression type of the filtering condition is the preset type, taking the default selectivity of the preset type as the filtering selectivity of the filtering condition.
In one embodiment, the preset type may be understood as a specific type of filtering condition expression, for example, a type of related function operation (e.g. FUNC (C1) > 5).
For example, if the expression type of the filtering condition is a preset type, for example, the expression type of the filtering condition is a function operation type (for example, FUNC (C1) > 5), a default selectivity is set for the preset type, that is, a specific value is given as the filtering selectivity of the filtering condition.
Optionally, determining the filtering selectivity of the filtering condition includes:
sampling a data table to be queried according to a set sampling rate to obtain a specified number of sample data;
inquiring the sample data according to the filtering conditions to determine the data quantity meeting the filtering conditions in the sample data;
and taking the ratio of the data quantity meeting the filtering condition to the specified quantity in the sample data as the filtering selectivity of the filtering condition.
The sampling rate may be preset, for example, may be a value between 0 and 100%, and if the sampling rate is 100%, it may be understood that the data of the whole data table is directly used as the data to be queried and a query operation is performed once.
The data table to be queried is sampled according to a set sampling rate (such as 20%) to obtain a specified number of sample data (such as 1 st-20 th line data), the sample data is queried according to the filtering condition, so that the data quantity meeting the filtering condition in the sample data is determined, then the ratio of the data quantity meeting the filtering condition in the sample data to the specified number is calculated, and the ratio is used as the filtering selectivity of the filtering condition of the whole data table. And the whole data in the data table can be executed directly once when the sampling rate is set to be 100%, so that the 100% accurate filtering selectivity can be obtained. That is, the query SELECT COUNT (x) FROM T WHERE FUNC (C1) >5 may be actually performed by using a dynamic sampling calculation method, to obtain the actual number of rows M2, and then dividing the actual number of rows N2 to obtain the filtering selectivity B of the filtering condition. It should be noted that, when the sampling rate is set to be lower than 100%, the accuracy of the determined filtering selectivity is generally lower than that when the sampling rate is set to be 100%, but the efficiency is relatively high, and the specific method to be used may be determined according to specific requirements.
Optionally, determining the execution complexity of the filtering condition according to the calculation complexity and the filtering selectivity includes:
if the filtering conditions are in a relation with each other, the execution complexity is the product of the calculation complexity and the filtering selectivity;
if the filtering conditions are or, the execution complexity is the ratio of the calculation complexity and the filtering selectivity.
For example, if each filtering condition is an AND, the execution complexity C is equal to the calculation complexity a multiplied by the filtering selectivity B, i.e., c=a×b; if each filtering condition is OR, the execution complexity C is equal to the calculation complexity a divided by the filtering selectivity B, i.e. c=a/B.
Example two
Fig. 2 is a schematic structural diagram of a query device according to a second embodiment of the present invention, where the query device may execute the query method according to the embodiment of the present invention. The query device provided in this embodiment includes:
an obtaining module 210, configured to obtain an initial query statement, where the initial query statement includes at least two filtering conditions;
the sorting module 220 is configured to sort the filtering conditions according to the execution complexity of the filtering conditions, so as to obtain a target query statement;
the execution module 230 is configured to execute the target query sentence to obtain a query result.
The second embodiment of the present invention provides a query device, which first obtains an initial query sentence, where the initial query sentence includes at least two filtering conditions; sequencing the filtering conditions according to the execution complexity of the filtering conditions to obtain a target query statement; and finally, executing the target query statement to obtain a query result. According to the technical scheme, the target query statement is obtained through sequential adjustment of the filtering conditions in the initial query statement, so that the execution complexity is reduced, the query times are reduced, the query process is optimized, the performance of the query process is better, and the query efficiency is improved.
Optionally, before the sorting module 220, the apparatus further includes:
the first determining module is used for determining the calculation complexity and the filtering selectivity of the filtering conditions aiming at each filtering condition;
and the second determining module is used for determining the execution complexity of the filtering condition according to the calculation complexity and the filtering selection rate.
Optionally, the first determining module includes:
and the first determining unit is used for determining the calculation complexity of the filtering condition according to the expression type of the filtering condition.
Optionally, the first determining module includes:
the reading unit is used for reading the statistical information of the data table to be queried, wherein the statistical information comprises the data quantity meeting the filtering condition in the data table and the total data quantity of the data table;
and the first determination unit of the selectivity is used for taking the ratio of the data quantity meeting the filtering condition to the total data quantity as the filtering selectivity of the filtering condition.
Optionally, the first determining module includes:
and the second determination unit of the selectivity is used for taking the default selectivity of the preset type as the filtering selectivity of the filtering condition if the expression type of the filtering condition is the preset type.
Optionally, the first determining module includes:
the sampling unit is used for sampling the data table to be queried according to a set sampling rate to obtain a specified number of sample data;
the query unit is used for querying the sample data according to the filtering conditions so as to determine the data quantity meeting the filtering conditions in the sample data;
and the third determination unit of the selectivity is used for taking the ratio of the data quantity meeting the filtering condition to the specified quantity in the sample data as the filtering selectivity of the filtering condition.
Optionally, the second determining module includes:
a complexity determining first unit, configured to, if the filtering conditions are in a relationship with each other, perform complexity as a product of the computational complexity and the filtering selectivity;
the complexity determination second unit is configured to determine the execution complexity as a ratio of the calculation complexity and the filtering selectivity if the filtering conditions are or.
The query device provided by the second embodiment of the present invention can be used for executing the query method provided by any of the above embodiments, and has corresponding functions and beneficial effects.
Example III
Fig. 3 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device 10 may also represent various forms of mobile equipment, such as personal digital assistants, cellular telephones, smartphones, user equipment, wearable devices (e.g., helmets, eyeglasses, watches, etc.), and other similar computing equipment. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 3, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks, wireless networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the query method.
In some embodiments, the query method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. One or more steps of the methods described above may be performed when the computer program is loaded into RAM 13 and executed by processor 11. Alternatively, in other embodiments, the processor 11 may be configured to perform the query method in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device 10, the electronic device 10 having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the electronic device 10. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method of querying, comprising:
acquiring an initial query statement, wherein the initial query statement comprises at least two filtering conditions;
sorting the filtering conditions according to the execution complexity of the filtering conditions to obtain target query sentences;
and executing the target query statement to obtain a query result.
2. The method of claim 1, further comprising, prior to ordering each of the filter terms according to their execution complexity to obtain a target query statement:
determining the computational complexity and the filtering selectivity of the filtering conditions for a single filtering condition;
and determining the execution complexity of the filtering condition according to the calculation complexity and the filtering selection rate.
3. The method of claim 2, wherein determining the computational complexity of the filtering condition comprises:
and determining the computational complexity of the filtering condition according to the expression type of the filtering condition.
4. The method of claim 2, wherein determining a filter selectivity of the filter conditions comprises:
reading statistical information of a data table to be queried, wherein the statistical information comprises data quantity meeting the filtering condition in the data table and total data quantity of the data table;
and taking the ratio of the data quantity meeting the filtering condition to the total data quantity as the filtering selectivity of the filtering condition.
5. The method of claim 2, wherein determining a filter selectivity of the filter conditions comprises:
and if the expression type of the filtering condition is a preset type, taking the default selectivity of the preset type as the filtering selectivity of the filtering condition.
6. The method of claim 2, wherein determining a filter selectivity of the filter conditions comprises:
sampling a data table to be queried according to a set sampling rate to obtain a specified number of sample data;
inquiring the sample data according to the filtering condition to determine the data quantity meeting the filtering condition in the sample data;
and taking the ratio of the data quantity meeting the filtering condition to the specified quantity in the sample data as the filtering selectivity of the filtering condition.
7. The method of claim 2, wherein determining the execution complexity of the filtering condition based on the computational complexity and the filtering selectivity comprises:
if the filtering conditions are in a relation with each other, the execution complexity is the product of the calculation complexity and the filtering selectivity;
and if the filtering conditions are or, the execution complexity is the ratio of the calculation complexity to the filtering selectivity.
8. A query device, comprising:
the acquisition module is used for acquiring an initial query statement, wherein the initial query statement comprises at least two filtering conditions;
the sorting module is used for sorting the filtering conditions according to the execution complexity of the filtering conditions to obtain target query sentences;
and the execution module is used for executing the target query statement to obtain a query result.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the query method of any one of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements a query method as claimed in any one of claims 1-7.
CN202311196402.9A 2023-09-15 2023-09-15 Query method, query device, electronic equipment and storage medium Pending CN117171206A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311196402.9A CN117171206A (en) 2023-09-15 2023-09-15 Query method, query device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311196402.9A CN117171206A (en) 2023-09-15 2023-09-15 Query method, query device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117171206A true CN117171206A (en) 2023-12-05

Family

ID=88935281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311196402.9A Pending CN117171206A (en) 2023-09-15 2023-09-15 Query method, query device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117171206A (en)

Similar Documents

Publication Publication Date Title
CN114861039A (en) Parameter configuration method, device, equipment and storage medium of search engine
CN114564149B (en) Data storage method, device, equipment and storage medium
CN115794744A (en) Log display method, device, equipment and storage medium
CN115328917A (en) Query method, device, equipment and storage medium
CN115438007A (en) File merging method and device, electronic equipment and medium
CN117171206A (en) Query method, query device, electronic equipment and storage medium
CN115080607A (en) Method, device, equipment and storage medium for optimizing structured query statement
CN115617549A (en) Thread decoupling method and device, electronic equipment and storage medium
CN115563310A (en) Method, device, equipment and medium for determining key service node
CN115511014B (en) Information matching method, device, equipment and storage medium
CN116303578A (en) Query expression processing method, device, equipment and storage medium
CN116401269A (en) Data query method and device, electronic equipment and storage medium
CN117763619A (en) Data desensitization method, device, equipment and medium
CN116126296A (en) Control method and device based on multiple associated date selectors and electronic equipment
CN116955394A (en) Data query method, device, equipment and medium
CN115510140A (en) Data extraction method, device, equipment and storage medium
CN117033402A (en) Data access method, device, equipment and storage medium
CN117827840A (en) Index creation method and device, electronic equipment and storage medium
CN115712645A (en) Data processing method, device, equipment and storage medium
CN116244321A (en) Data updating method, device, equipment and medium
CN117632734A (en) Performance test method of database, electronic equipment and storage medium
CN116088769A (en) Asynchronous chip, data carrying method, device, equipment and medium
CN115587091A (en) Data storage method, device, equipment and storage medium
CN115203246A (en) Linked list query method and device, electronic equipment and storage medium
CN116820041A (en) Comparison method, device, equipment and storage medium for controller control logic function

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