Distributed database query method, device and equipment based on sparrow search algorithm

By applying the sparrow search algorithm in distributed database query, the problems of low query efficiency and local optimal solutions in traditional databases are solved, and more efficient and accurate query performance is achieved.

CN119646025APending Publication Date: 2025-03-18CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411820059.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In traditional database query technology, there are problems such as low query efficiency and optimization algorithms that are prone to local optimal solutions.

Method used

A distributed database query method based on sparrow search algorithm is used to obtain and parse query SQL statements, generate the initial sparrow population, update the location to optimize the execution plan until the optimal execution plan meets the preset optimization goal is found.

Benefits of technology

Improve the performance of distributed database query, avoid local optimal solutions, and improve query efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119646025A_ABST
    Figure CN119646025A_ABST
Patent Text Reader

Abstract

The invention provides a distributed database query method, device and equipment based on a sparrow search algorithm, and relates to the technical field of database query, the method comprises the following steps: obtaining a received first query SQL statement, and analyzing the first query SQL statement to obtain a plurality of fragment statements; performing execution scheme query on the plurality of fragment statements through a query optimization model based on a sparrow search algorithm to obtain a first execution scheme meeting a preset optimization target, the optimization target at least comprising a minimum query cost, and the first execution scheme being a connection scheme of service nodes corresponding to the fragment statements; and executing the first execution scheme to obtain a first query result, and outputting the first query result. The scheme provided by the invention has stronger global exploration and local development capabilities, and the optimal database query scheme can be found more effectively, so that the distributed database query performance is improved, manual intervention is reduced, and the query efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database query technology, and in particular to a distributed database query method, device and equipment based on a sparrow search algorithm. Background Art

[0002] With the rapid development of Internet technology, business is growing and expanding, the cloud computing field is becoming more mature, and intelligent computing based on artificial intelligence technology has been widely used in the industry. As a frontier for direct interaction with users, the web console is an important entry point for operating cloud resources. As the scale of databases continues to expand, query efficiency has become an important indicator for measuring the performance of cloud database systems.

[0003] Distributed database management systems have better scalability than traditional database systems, and therefore have gradually become the mainstream of database management today. Existing related technologies include optimizing query solutions in database queries through optimization algorithms such as genetic algorithms, particle swarm algorithms, simulated annealing algorithms, and firefly algorithms, but they are more limited to considering external factors or improving a single link operation, ignoring other factors within the algorithm that may lead to a reduction in population diversity. Therefore, it is easy to reduce population diversity in advance due to invalid operations, which is not conducive to the emergence of the optimal solution. Summary of the invention

[0004] The technical purpose to be achieved by the embodiments of the present application is to provide a distributed database query method, device and equipment based on the sparrow search algorithm, so as to solve the problems existing in the current traditional database query technology, such as low query efficiency and the existing optimization algorithm easily falling into the local optimal solution.

[0005] In order to solve the above technical problems, the embodiment of the present application provides a distributed database query method based on the sparrow search algorithm, including:

[0006] Acquire the received first query SQL statement, and parse the first query SQL statement to obtain multiple fragment statements;

[0007] By querying the execution schemes of the plurality of fragmented statements based on a query optimization model based on a Sparrow Search Algorithm (SSA), a first execution scheme satisfying a preset optimization goal is obtained, wherein the optimization goal at least includes: a minimum query cost, and the first execution scheme is a connection scheme of service nodes corresponding to each fragmented statement;

[0008] Execute the first execution scheme to obtain a first query result and output it.

[0009] Specifically, the method as described above, wherein the query optimization model based on the sparrow search algorithm is used to query the execution plan of the plurality of fragmented statements to obtain a first execution plan that meets the preset optimization goal, further comprises:

[0010] Initializing algorithm parameters of the query optimization model;

[0011] Randomly generate a first position of an initial sparrow population according to the multiple fragmented statements, each individual in the sparrow population represents a possible execution scheme, and the position of the individual represents a code corresponding to the execution scheme;

[0012] Obtaining a first fitness value associated with each of the individuals and the corresponding first position;

[0013] Based on the first fitness value and a preset position update algorithm, obtaining a second position corresponding to each of the individuals;

[0014] Obtaining a second fitness value corresponding to each of the individuals and the second position;

[0015] If the second fitness value corresponding to the same individual is less than the first fitness value, the first position corresponding to the individual is updated to the second position; otherwise, the first position remains unchanged;

[0016] Under the condition that at least one preset condition is met, the individual with the largest first fitness value is determined as the first execution scheme, wherein the preset condition includes: the number of iterations corresponding to the current iteration reaches a first preset number, and the number of iterations in which all the individuals maintain the first position unchanged reaches a second preset number.

[0017] Specifically, in the method described above, the step of obtaining the second position corresponding to each of the individuals based on the first fitness value and a preset position update algorithm includes:

[0018] Determine the second position corresponding to the discoverer in the sparrow population based on a preset discoverer position update algorithm;

[0019] Determine the second position corresponding to the joiner in the sparrow population based on a preset joiner position update algorithm;

[0020] Based on a preset scout position update algorithm, the second position corresponding to the scout is determined.

[0021] Preferably, in the above method, the obtaining of the second position corresponding to each of the individuals based on the first fitness value and a preset position update algorithm further includes:

[0022] Generate a conversion random number;

[0023] If the conversion random number is less than the conversion probability obtained in advance, the positions of all the individuals in the sparrow population are updated again according to the firefly algorithm, and the conversion probability is related to the number of the individuals in the sparrow population;

[0024] If the conversion random number is greater than or equal to the conversion probability, the positions of the joiners and scouts in the sparrow population are updated again according to the particle swarm algorithm.

[0025] Preferably, in the method as described above, the randomly generating the positions of the initial sparrow population according to the multiple fragment statements comprises:

[0026] The Tent chaotic mapping function is used to generate the initial positions of the sparrow population uniformly distributed in the entire solution space.

[0027] Preferably, the method as described above, after obtaining the first query SQL statement, further includes:

[0028] storing the first query SQL statement and the first execution scheme and / or the first query result corresponding to the first query SQL statement;

[0029] If the first query SQL statement is received again, the first query result corresponding to the first query SQL statement is output, or the first execution plan corresponding to the first query SQL statement is executed, and a second query result after execution is output.

[0030] Another embodiment of the present application further provides a control device for distributed database query based on a sparrow search algorithm, comprising:

[0031] A preprocessing module, used for acquiring the received first query SQL statement, and parsing the first query SQL statement to obtain a plurality of fragment statements;

[0032] A first processing module is used to query the execution schemes of the plurality of fragmented statements through a query optimization model based on a sparrow search algorithm, and obtain a first execution scheme that meets a preset optimization goal, wherein the optimization goal at least includes: a minimum query cost, and the execution scheme is a connection scheme of service nodes corresponding to each fragmented statement;

[0033] The second processing module is used to execute the first execution scheme, obtain the first query result, and output it.

[0034] Yet another embodiment of the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the distributed database query method based on the sparrow search algorithm as described above.

[0035] Another embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the distributed database query method based on the sparrow search algorithm as described above are implemented.

[0036] Another embodiment of the present application further provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of the distributed database query method based on the sparrow search algorithm as described above.

[0037] Compared with the prior art, the method, device and apparatus for distributed database query based on the sparrow search algorithm provided in the embodiments of the present application have at least the following beneficial effects:

[0038] The present application provides a distributed database query method based on the sparrow search algorithm. Compared with the traditional optimization algorithm, which is prone to fall into the defect of local optimal solution when solving database query optimization problems, the sparrow search algorithm has stronger global exploration and local development capabilities, and can more effectively find the optimal database query solution, thereby improving the distributed database query performance. The use of a distributed database improves data access speed and concurrent processing capabilities, increases implementation flexibility and reliability, so as to obtain higher response speed and query performance when processing large-scale, high-concurrency and geographically dispersed data. In addition, after the user enters the query target, the system uses the optimization algorithm to adaptively iterate to find the optimal query solution and obtain the query results, reducing manual intervention and improving query efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 This is one of the flow charts of the distributed database query method based on the sparrow search algorithm of the present application;

[0040] Figure 2 This is the second flow chart of the distributed database query method based on the sparrow search algorithm of the present application;

[0041] Figure 3 The third flowchart of the distributed database query method based on the sparrow search algorithm of the present application;

[0042] Figure 4 This is the fourth flow chart of the distributed database query method based on the sparrow search algorithm of the present application;

[0043] Figure 5 This is a schematic diagram of the structure of a control device for distributed database query based on a sparrow search algorithm of the present application. DETAILED DESCRIPTION

[0044] In order to make the technical problems, technical solutions and advantages to be solved by the application clearer, the following will be described in detail in conjunction with the accompanying drawings and specific embodiments. In the following description, specific details such as specific configurations and components are provided only to help fully understand the embodiments of the application. Therefore, it should be clear to those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the application. In addition, for clarity and brevity, the description of known functions and structures has been omitted.

[0045] It should be understood that the references to "one embodiment" or "an embodiment" throughout the specification mean that the specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0046] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0047] It should be understood that the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0048] In the embodiments provided in the present application, it should be understood that "B corresponding to A" means that B is associated with A, and B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.

[0049] When describing the embodiments of the present application, some concepts used in the following description and related prior arts are first explained.

[0050] The database has a cost-based query optimizer that selects the best connection strategy from all execution plans. For the database, an appropriate query execution strategy will greatly improve system performance. For a given multi-connection query statement, the database can generate multiple execution plans for it. The query optimizer will analyze all execution plans and then find the execution plan with the lowest cost and the least time.

[0051] Distributed database queries usually require multiple tables to be linked, and non-procedural high-level languages ​​are used to obtain the desired data, but there is no specific description of how to obtain the data. This part does not require manual processing and can be directly processed by the system. Distributed database management systems divide user query statements into several operations and complete these operations in a more optimal order.

[0052] In system operation, due to the close coordination between various parts, the query costs include the following:

[0053] (1) I / O overhead

[0054] After the query is issued, the database processing system needs to read, find, and write the data required in the query, which is called I / O overhead. In addition to the database files stored in the external memory, there are also a large number of temporary files that cannot be stored in the memory because of their large size.

[0055] (2) Storage overhead

[0056] Storage overhead refers to the cost of storing intermediate files safely and conveniently.

[0057] (3) CPU / computational overhead

[0058] CPU / computational overhead refers to the use of processor resources when executing queries. Data is also calculated during the processing process and requires overhead.

[0059] (4) Communication overhead

[0060] Communication overhead is unique to distributed databases. The data in a distributed database may be distributed in different physical locations, so the transmission of data in the network will incur a cost.

[0061] Below, in conjunction with the accompanying drawings and specific embodiments, a distributed database query method, device and equipment based on a sparrow search algorithm provided by an embodiment of the present application are described in detail:

[0062] See also Figure 1 An embodiment of the present application provides a distributed database query method based on a sparrow search algorithm, comprising:

[0063] Step S101, obtaining a received first query SQL statement, and parsing the first query SQL statement to obtain a plurality of fragment statements;

[0064] Step S102, querying the execution plans of the plurality of fragmented statements through a query optimization model based on a sparrow search algorithm, and obtaining a first execution plan that meets a preset optimization goal, wherein the optimization goal at least includes: a minimum query cost, and the first execution plan is a connection plan of a service node corresponding to each fragmented statement;

[0065] Step S103: execute the first execution plan, obtain a first query result, and output it.

[0066] In this embodiment, a received first query SQL statement is obtained. To facilitate querying based on the first query SQL statement, the first query SQL statement is parsed and syntax parsed to obtain a plurality of fragmented statements, so as to determine the processing nodes corresponding to each fragmented statement. The plurality of fragmented statements obtained above are then input into a query optimization model based on a sparrow search algorithm. By querying the execution plans of the plurality of fragmented statements through the sparrow search algorithm, a first execution plan that meets the preset optimization goal can be obtained. The first execution plan is then executed to query, and the corresponding query result is obtained and output for the user to obtain the query result.

[0067] In summary, the present application provides a distributed database query method based on the sparrow search algorithm. Compared with the traditional optimization algorithm, which is prone to fall into the defect of local optimal solution when solving database query optimization problems, the sparrow search algorithm has stronger global exploration and local development capabilities, and can more effectively find the optimal database query solution, thereby improving the distributed database query performance. The use of a distributed database improves data access speed and concurrent processing capabilities, increases implementation flexibility and reliability, so as to obtain higher response speed and query performance when processing large-scale, high-concurrency and geographically dispersed data. In addition, in this embodiment, after the user enters the query target, the system uses the optimization algorithm to adaptively iterate to find the optimal query solution and obtain the query result, which reduces manual intervention and improves query efficiency and accuracy.

[0068] It should be noted that in this embodiment, the console technology is used to interact with the user using the web console, receive the query SQL statement input by the user, and output the obtained query results to the web console for display, so that the user can query and obtain the query results.

[0069] It should be noted that the database query method in this embodiment is applied to a distributed database, so the query cost is minimized as the optimization goal. Since the data in the distributed database is scattered in each node, when considering the query cost as the optimization goal, not only the I / O and CPU / computation costs need to be considered, but also the communication cost needs to be considered. However, in a remote communication network, since the data transmission speed between nodes is many times slower than that in a single machine, the CPU and I / O costs when executing the query command can be ignored, so the communication cost becomes the main goal in the query optimization of the distributed database system. Specifically, the query cost is the sum of the input / output (I / O) cost, the CPU / computation cost, and the communication cost, where the communication cost can be expressed as: T(X) = C0 + C1X, where C0 represents the time for two nodes to complete a communication, in seconds (s), C1 is the transmission rate, specifically the reciprocal of the transmission speed, and X is the data transmission volume, in bits (bits).

[0070] It should be noted that, in this embodiment, the step of parsing the first query SQL statement to obtain multiple fragment statements corresponds to the query decomposition step of the distributed database, and is also used to gradually decompose the entire complex problem into small problems of data processing in available nodes.

[0071] See also Figure 2 Specifically, the method as described above, wherein the query optimization model based on the sparrow search algorithm is used to query the execution plan of the plurality of fragmented statements to obtain a first execution plan that meets the preset optimization goal, further comprising:

[0072] Step S201, initializing the algorithm parameters of the query optimization model, wherein the algorithm parameters include but are not limited to: population size, maximum number of iterations, discoverer ratio, joiner ratio, explorer ratio, warning value and safety value, etc.;

[0073] Step S202, randomly generating the first position of the initial sparrow population according to the plurality of fragmented statements, each individual in the sparrow population represents a possible execution scheme, the position of the individual is the position of the sparrow in the solution space, this position represents a potential solution, i.e., an execution scheme, in the optimization problem, and can be used to represent the code corresponding to the execution scheme. This step is equivalent to localizing the data, i.e., the decomposed statements are claimed and processed by each node;

[0074] Step S203, obtaining the first fitness value of each individual associated with the corresponding first position. At this time, the minimum first fitness value can be expressed as the current optimal solution, so that this step is equivalent to global optimization. In one embodiment, the fitness function of the sparrow population is expressed as Among them, d represents the dimension of the variable to be optimized, n represents the number of sparrows, and the matrix of x represents the population of all sparrows;

[0075] Step S204, based on the first fitness value and the preset position update algorithm, obtain the second position corresponding to each of the individuals. In this step, based on the fitness value of each individual and the preset position update algorithm, the second position corresponding to each individual can be calculated respectively, wherein the position update algorithm is related to the identity of the individual (explorer, discoverer and joiner), and the identity of the individual can be determined by random determination or based on the sorting of the first fitness value, wherein the discoverer is the individuals in the first preset proportion after sorting, the joiner is the remaining individuals or the individuals in the second preset proportion, and the explorer is the individuals in the random third preset proportion. This step is equivalent to making further local optimization of each node on the premise of finding the global optimal solution;

[0076] Step S205, obtaining a second fitness value corresponding to each of the individuals and the second position;

[0077] Step S206, if the second fitness value corresponding to the same individual is less than the first fitness value, the first position corresponding to the individual is updated to the second position, otherwise, the first position is kept unchanged. In this step, when the final position of the individual is updated, a judgment is made based on the second fitness value and the first fitness value, wherein the smaller the fitness value is, the closer it is to the optimization target, and the better its position is. Therefore, if the second fitness value is less than the first fitness value, the first position corresponding to the individual is updated to the position specifically corresponding to the second position, otherwise the specific position of the first position is kept unchanged;

[0078] Step S207, in the case of satisfying at least one preset condition, determining the individual with the largest first fitness value as the first execution scheme, wherein the preset condition includes: the number of iterations corresponding to the current iteration reaches the first preset number, and the number of iterations in which all the individuals keep the first position unchanged reaches the second preset number. In this step, if it is determined according to the above-mentioned iteration process that at least one preset condition is satisfied, it is determined that the expected iteration effect has been achieved, so the individual with the largest first fitness value is determined as the final first execution scheme. Specifically, when the number of iterations corresponding to the current iteration reaches the first preset number, iterating again at this time will affect the time of the result output, etc., so it is used as a preset condition; if the number of iterations in which all the individuals keep the first position unchanged reaches the second preset number, it can be determined that the current algorithm has converged, so it is used as a preset condition.

[0079] In summary, the steps of the sparrow search algorithm are exemplified in this embodiment, enabling those skilled in the art to understand and implement the technical solutions in this embodiment based on the above steps. Specifically, for the method described above, obtaining the second position corresponding to each individual based on the first fitness value and a preset position update algorithm includes:

[0080] Determining the second position corresponding to the discoverers in the sparrow population based on a preset discoverer position update algorithm, where the discoverer position update algorithm can be expressed as:

[0081]

[0082] where X i,j is the position information of the j-th dimension of the i-th sparrow individual, and satisfies j = 1, 2, 3,..., d. t and t + 1 are the current iteration number and the next iteration number of the iteration respectively, iter max is the maximum iteration number, L is a matrix with all elements of 1×d dimension being 1, the random number α satisfies α ∈ (0, 1], the random number Q satisfies the normal distribution, the warning value R2 satisfies R2 ∈ (0, 1], and the safety value ST satisfies ST ∈ (0.5, 1]. When R2 < ST, it indicates that the current environment is safe and the discoverers can continue to search, otherwise it means that the scouts have sounded the alarm and the population updates its position;

[0083] Determining the second position corresponding to the joiners in the sparrow population based on a preset joiner position update algorithm, where the joiner position update algorithm can be expressed as:

[0084]

[0085] where, and are the best position occupied by the discoverers and the global worst position respectively. A is a matrix with all elements of 1×d dimension being 1 or -1, and satisfies A + = A T (AA T ) -1 , N is the population size. When , it means that the i-th joiner flies to other positions to forage due to low fitness value, otherwise it competes with the discoverers for the foraging position;

[0086] Determining the second position corresponding to the scouts based on a preset scout position update algorithm, where the scout position update algorithm can be expressed as:

[0087]

[0088] where, is the current global optimal position and f iis the current global best fitness, the global worst fitness and the individual fitness value of the sparrow in the current iteration. The random number K satisfies K∈[-1,1], which is the direction and step length control parameter of the sparrow's movement. The random number β satisfies the normal distribution with mean 0 and variance 1. ε is the smallest constant. i >f best and f i =f best They respectively indicate that the sparrows at the edge of the population move to the safe zone and the sparrows in the middle of the population randomly change their positions.

[0089] In order to further improve the effect of the sparrow search algorithm, the sparrow search algorithm is improved based on the multi-intelligent optimization algorithm to obtain the improved sparrow search algorithm (Ehanced Sparrow Search Algorithm, ESSA).

[0090] See also Figure 3 Preferably, the method as described above, wherein the second position corresponding to each of the individuals is obtained based on the first fitness value and a preset position update algorithm, further comprises:

[0091] Step S301, generating a conversion random number;

[0092] Step S302, if the conversion random number is less than the pre-obtained conversion probability, then updating the positions of all the individuals in the sparrow population again according to the firefly algorithm, wherein the conversion probability is related to the number of the individuals in the sparrow population;

[0093] Step S303: if the conversion random number is greater than or equal to the conversion probability, the positions of the joiners and scouts in the sparrow population are updated again according to the particle swarm algorithm.

[0094] In this embodiment, after the second position is obtained by the position update algorithm corresponding to each identity, a conversion random number is obtained by directly calling a random function, and the conversion random number is compared with the conversion probability obtained in advance, wherein the conversion random number rand satisfies rand∈(0,1], and the algorithm for obtaining the conversion probability can be expressed as: ,in, is the second type Euler integral.

[0095] Based on the comparison results of the conversion random number and the conversion probability, different optimization algorithms can be used to update the positions of all or part of the individuals to increase the ability to jump out of the local optimal solution, so that it has excellent optimization accuracy and optimization effect.

[0096] It should be noted that the light generated by each individual in the firefly algorithm serves as an information carrier, which can guide the remaining fireflies to update their positions. The specific algorithm can be expressed as:

[0097] x best (t+1)=x best (t)+α(rand-1 / 2)

[0098] Among them, x best (t) and x best (t+1) is the best individual in the previous iteration and this iteration, rand is a random number satisfying rand∈(0,1], and α∈[0,1] is the step size factor.

[0099] In the particle swarm algorithm, the i-th particle finds the individual extreme value p at the t-th iteration best and the global extremum g best When , the velocity of the i-th particle can be expressed as: Among them, ω is the inertia constant, c1 and c2 are acceleration constants, r1 and r2 are random numbers on [0,1], is the position of the i-th particle; and the position update algorithm of the i-th particle at the t-th iteration can be expressed as:

[0100] Furthermore, during the optimization, the step of initializing the population may also be optimized. Preferably, in the above method, the position of the initial sparrow population is randomly generated according to the multiple fragment statements, including:

[0101] The Tent chaotic mapping function is used to generate the initial positions of the sparrow population uniformly distributed in the entire solution space.

[0102] Since the chaotic sequence has randomness, ergodicity and uniformity in a deterministic system, the chaotic sequence generated by the Tent chaotic mapping function has better ergodicity, uniformity and iteration speed than the traditional Logistic mapping function, so it is used to increase the population diversity of the algorithm in the search optimization problem of this application. Its calculation formula can be expressed as:

[0103] See also Figure 4 Preferably, the method as described above, after obtaining the first query SQL statement, further includes:

[0104] Step S401, storing the first query SQL statement and the first execution plan and / or the first query result corresponding to the first query SQL statement;

[0105] Step S402: if the first query SQL statement is received again, output the first query result corresponding to the first query SQL statement, or execute the first execution plan corresponding to the first query SQL statement and output the second query result after execution.

[0106] In this embodiment, by caching the first query SQL statement received for the first time and the first execution plan and / or the first query result corresponding to the first query SQL statement, the optimized query plan can be directly executed to obtain the second query result after execution when it is not the first query, or the query result, i.e. the first query result, can be directly obtained from the cache, thereby improving the subsequent query performance of the entire system.

[0107] In the most commonly used subscription, cancellation, change and renewal services of the bare metal console, distributed database query is the most common operation. The web console of the distributed database established in this application is associated with the distributed database query method based on the sparrow search algorithm in the background, which can concretize the abstract query method described in this application and effectively apply it in the query process of the cloud page.

[0108] See also Figure 5 Another embodiment of the present application further provides a control device for distributed database query based on a sparrow search algorithm, comprising:

[0109] A preprocessing module 501 is used to obtain a received first query SQL statement, and then parse the first query SQL statement to obtain multiple fragment statements;

[0110] The first processing module 502 is used to query the execution schemes of the plurality of fragmented statements through a query optimization model based on a sparrow search algorithm, and obtain a first execution scheme that meets a preset optimization goal, wherein the optimization goal at least includes: a minimum query cost, and the execution scheme is a connection scheme of service nodes corresponding to each fragmented statement;

[0111] The second processing module 503 is used to execute the first execution solution, obtain a first query result, and output it.

[0112] Specifically, in the control device as described above, the first processing module further includes:

[0113] An initialization parameter submodule, used to initialize the algorithm parameters of the query optimization model;

[0114] An initialization population submodule is used to randomly generate a first position of an initial sparrow population according to the plurality of fragmented statements, wherein each individual in the sparrow population represents a possible execution scheme, and the position of the individual represents a code corresponding to the execution scheme;

[0115] A first fitness acquisition submodule, used to acquire a first fitness value of each individual related to the corresponding first position;

[0116] A first position updating submodule, configured to obtain a second position corresponding to each of the individuals based on the first fitness value and a preset position updating algorithm;

[0117] A second fitness acquisition submodule, used to acquire a second fitness value corresponding to each of the individuals and the second position;

[0118] A second position updating submodule, configured to update the first position corresponding to the individual to the second position if the second fitness value corresponding to the same individual is less than the first fitness value, otherwise, keep the first position unchanged;

[0119] A processing submodule is used to determine that the individual with the largest first fitness value is the first execution scheme when at least one preset condition is met, wherein the preset condition includes: the number of iterations corresponding to the current iteration reaches a first preset number, and the number of iterations in which all the individuals maintain the first position unchanged reaches a second preset number.

[0120] Specifically, in the control device as described above, the first position updating submodule includes:

[0121] A first position updating unit, configured to determine the second position corresponding to the discoverer in the sparrow population based on a preset discoverer position updating algorithm;

[0122] A second position updating unit, configured to determine the second position corresponding to the joiner in the sparrow population based on a preset joiner position updating algorithm;

[0123] The third position updating unit is used to determine the second position corresponding to the scout based on a preset scout position updating algorithm.

[0124] Preferably, in the control device as described above, the first position updating submodule further includes:

[0125] A random number generating unit, used for generating a conversion random number;

[0126] a fourth position updating unit, which updates the positions of all the individuals in the sparrow population again according to a firefly algorithm if the conversion random number is less than a pre-obtained conversion probability, wherein the conversion probability is related to the number of the individuals in the sparrow population;

[0127] A fifth position updating unit updates the positions of the joiners and scouts in the sparrow population again according to a particle swarm algorithm if the conversion random number is greater than or equal to the conversion probability.

[0128] Preferably, in the control device as described above, the initialization population submodule comprises:

[0129] The Tent chaotic mapping function is used to generate the initial positions of the sparrow population uniformly distributed in the entire solution space.

[0130] Preferably, the control device as described above further comprises:

[0131] A storage module, used to store the first query SQL statement and the first execution scheme and / or the first query result corresponding to the first query SQL statement;

[0132] The third processing module is used to output the first query result corresponding to the first query SQL statement if the first query SQL statement is received again, or to execute the first execution plan corresponding to the first query SQL statement and output a second query result after execution.

[0133] The control device embodiment of the distributed database query based on the sparrow search algorithm of the present application is a device corresponding to the embodiment of the distributed database query method based on the sparrow search algorithm, and all the implementation means in the above method embodiment are applicable to the embodiment of the device, and can also achieve the same technical effect. The above control device provided in the embodiment of the present application can implement all the method steps implemented in the above method embodiment, and can achieve the same technical effect, and the parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be specifically repeated here.

[0134] Another embodiment of the present application further provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the distributed database query method based on the sparrow search algorithm as described above are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0135] Another embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the distributed database query method based on the sparrow search algorithm as described above are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0136] Another embodiment of the present application further provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of the distributed database query method based on the sparrow search algorithm as described above, and can achieve the same technical effect. To avoid repetition, they are not repeated here.

[0137] In addition, the present application may repeat reference numerals and / or letters in different examples. This repetition is for the purpose of simplicity and clarity, and does not in itself indicate the relationship between the various embodiments and / or settings discussed.

[0138] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusions.

[0139] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A distributed database query method based on a sparrow search algorithm, characterized in that: include: Acquire the received first query SQL statement, and parse the first query SQL statement to obtain multiple fragment statements; Through a query optimization model based on a sparrow search algorithm, the execution schemes of the plurality of fragmented statements are queried to obtain a first execution scheme that meets a preset optimization goal, wherein the optimization goal at least includes: a minimum query cost, and the first execution scheme is a connection scheme of service nodes corresponding to each fragmented statement; Execute the first execution scheme to obtain a first query result and output it.

2. The method according to claim 1, characterized in that The method further comprises: performing an execution plan query on the plurality of fragmented statements through a query optimization model based on a sparrow search algorithm to obtain a first execution plan that meets a preset optimization goal; Initializing algorithm parameters of the query optimization model; Randomly generate a first position of an initial sparrow population according to the multiple fragmented statements, each individual in the sparrow population represents a possible execution scheme, and the position of the individual represents a code corresponding to the execution scheme; Obtaining a first fitness value associated with each of the individuals and the corresponding first position; Based on the first fitness value and a preset position update algorithm, obtaining a second position corresponding to each of the individuals; Obtaining a second fitness value corresponding to each of the individuals and the second position; If the second fitness value corresponding to the same individual is less than the first fitness value, the first position corresponding to the individual is updated to the second position; otherwise, the first position remains unchanged; Under the condition that at least one preset condition is met, the individual with the largest first fitness value is determined as the first execution scheme, wherein the preset condition includes: the number of iterations corresponding to the current iteration reaches a first preset number, and the number of iterations in which all the individuals maintain the first position unchanged reaches a second preset number.

3. The method according to claim 2, characterized in that The acquiring the second position corresponding to each of the individuals based on the first fitness value and a preset position updating algorithm includes: Determine the second position corresponding to the discoverer in the sparrow population based on a preset discoverer position update algorithm; Determine the second position corresponding to the joiner in the sparrow population based on a preset joiner position update algorithm; Based on a preset scout position update algorithm, the second position corresponding to the scout is determined.

4. The method according to claim 3, characterized in that The acquiring the second position corresponding to each of the individuals based on the first fitness value and a preset position updating algorithm further includes: Generate a conversion random number; If the conversion random number is less than the conversion probability obtained in advance, the positions of all the individuals in the sparrow population are updated again according to the firefly algorithm, and the conversion probability is related to the number of the individuals in the sparrow population; If the conversion random number is greater than or equal to the conversion probability, the positions of the joiners and scouts in the sparrow population are updated again according to the particle swarm algorithm.

5. The method according to claim 2, characterized in that: The randomly generating the position of the initial sparrow population according to the multiple fragment statements includes: The Tent chaotic mapping function is used to generate the initial positions of the sparrow population uniformly distributed in the entire solution space.

6. The method according to claim 1, characterized in that After obtaining the first query SQL statement, the following is also included: storing the first query SQL statement and the first execution scheme and / or the first query result corresponding to the first query SQL statement; If the first query SQL statement is received again, the first query result corresponding to the first query SQL statement is output, or the first execution plan corresponding to the first query SQL statement is executed, and a second query result after execution is output.

7. A control device for distributed database query based on sparrow search algorithm, characterized in that: include: A preprocessing module, used to obtain the received first query SQL statement, and parse the first query SQL statement to obtain multiple fragment statements; A first processing module, configured to query the execution schemes of the plurality of fragmented statements through a query optimization model based on a sparrow search algorithm, and obtain a first execution scheme that meets a preset optimization goal, wherein the optimization goal at least includes: a minimum query cost, and the execution scheme is a connection scheme of service nodes corresponding to each fragmented statement; The second processing module is used to execute the first execution scheme, obtain the first query result, and output it.

8. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the method for distributed database query based on the sparrow search algorithm as described in any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the distributed database query method based on the sparrow search algorithm as described in any one of claims 1 to 6 are implemented.

10. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the distributed database query method based on the sparrow search algorithm as described in any one of claims 1 to 6.