Database optimization method and apparatus, server, and storage medium

By segmenting and optimizing accessed data with composite indexes, the problem of low service efficiency of traditional databases when handling massive data requests is solved, and the database response speed is accelerated without increasing the number of server clusters.

CN116719844BActive Publication Date: 2026-06-23CHINA UNITED NETWORK COMM GRP CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA UNITED NETWORK COMM GRP CO LTD
Filing Date
2023-07-26
Publication Date
2026-06-23

Smart Images

  • Figure CN116719844B_ABST
    Figure CN116719844B_ABST
Patent Text Reader

Abstract

The application provides a database optimization method and device, a server and a storage medium. The method comprises the following steps: acquiring access data, and segmenting the access data to obtain segmented query fields. If the number of the query fields is multiple, all query field combinations are obtained according to all the query fields. Each query field combination is searched, and if a unique response value is obtained, the search time of each query field combination is recorded. The search times of each query field combination are sorted from small to large, and a joint index is respectively created for the query field combinations corresponding to the search times in the front preset number, thereby obtaining multiple joint indexes. The reference times of the multiple joint indexes are recorded, and the multiple joint indexes are sorted from large to small according to the reference times. Each joint index after sorting is stored, so as to complete the optimization of the database. The method of the application accelerates the feedback speed of the database without increasing the number of the database server cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a database optimization method, apparatus, server, and storage medium. Background Technology

[0002] With the widespread adoption of cloud computing technology across various professional fields, higher demands are being placed on processing massive amounts of data. While traditional databases can guarantee the permanent storage of data, the rigor of practical operations and the read / write speed of storage devices lead to inefficiencies when faced with massive data requests. Therefore, optimization of traditional databases is necessary.

[0003] In existing technologies, the performance of a database server cluster under a preset load is usually predicted based on a performance model. Database servers that need to be reconfigured are grouped together, and a configuration plan is formulated based on the throughput and cost conditions of the database server cluster.

[0004] However, improving database service efficiency by configuring the number of database clusters requires ensuring a certain number of database server clusters, which is not suitable for databases with a small number of database server clusters, meaning it cannot fundamentally speed up the database's response time. Summary of the Invention

[0005] This application provides a database optimization method, apparatus, server, and storage medium to solve the technical problem of accelerating database response speed.

[0006] Firstly, this application provides a database optimization method, including:

[0007] Retrieve the accessed data and segment it to obtain the segmented query fields.

[0008] Determine the number of query fields after segmentation.

[0009] If there are multiple query fields, then all combinations of query fields will be obtained based on all query fields.

[0010] The search is performed based on each combination of query fields. If a unique response value is obtained, the search time for each combination of query fields is recorded.

[0011] Sort the retrieval times of each query field combination from smallest to largest, and create composite indexes for the query field combinations corresponding to the first preset number of retrieval times, resulting in multiple composite indexes.

[0012] Record the reference counts of multiple composite indexes and sort them in descending order of reference count.

[0013] The sorted composite indexes are stored to complete the database optimization.

[0014] Optionally, in the method described above, determining the number of query fields after segmentation includes: retrieving response data based on a single index field, where the single index field is pre-defined based on a created single-column index; and iterating and matching the segmented query fields with the response data. If no other identical query fields are matched, the number of query fields is 1. If other identical query fields are matched, the number of query fields is 1+n, where n is the number of other identical query fields matched, and n is a positive integer.

[0015] Optionally, in the method described above, the step of retrieving based on each query field combination, and recording the retrieval time for each query field combination if a unique response value is obtained, includes: retrieving based on each query field combination; obtaining the physical address of the unique response value if a unique response value is obtained; accessing the response data based on the physical address; and recording the time from the start of the retrieval to accessing the response data for each query field combination to obtain the retrieval time for each query field combination.

[0016] Optionally, in the method described above, recording the reference counts of multiple composite indexes includes: obtaining access data, segmenting the access data to obtain segmented query data. If the segmented query data matches a field of any composite index, the reference count of that composite index is incremented by one to obtain the reference count of that composite index. The reference count of any composite index is recorded to obtain the reference counts of multiple composite indexes.

[0017] Optionally, in the method described above, before obtaining the accessed data, the method further includes: obtaining the amount of data to be stored. If the amount of data is less than a preset storage value or if there are duplicate data to be stored exceeding a preset percentage, then no index needs to be created, and the data is stored directly. If the amount of data is not less than the preset storage value, then a single-column index is created and the data is stored.

[0018] Secondly, this application provides a database optimization apparatus, comprising:

[0019] The data segmentation module is used to obtain accessed data, segment the accessed data, and obtain the segmented query fields.

[0020] The field count determination module is used to determine the number of query fields after segmentation.

[0021] The query field combination retrieval module is used to obtain all query field combinations based on all query fields if there are multiple query fields.

[0022] The retrieval time calculation module is used to perform retrieval based on each combination of query fields. If a unique response value is obtained, the retrieval time for each combination of query fields is recorded.

[0023] The composite index creation module is used to sort the retrieval times of each query field combination from smallest to largest, and create composite indexes for the query field combinations corresponding to the first preset number of retrieval times, resulting in multiple composite indexes.

[0024] The reference count sorting module records the reference counts of multiple composite indexes and sorts them in descending order of reference count.

[0025] The composite index storage module is used to store the sorted composite indexes to optimize the database.

[0026] Thirdly, this application provides a server, including: at least one processor and a memory.

[0027] The memory stores the instructions that the computer executes.

[0028] At least one processor executes computer execution instructions stored in memory, causing at least one processor to perform the database optimization method as described in the first aspect.

[0029] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the database optimization method as described in the first aspect.

[0030] The database optimization method, apparatus, server, and storage medium provided in this application segment various types of access data, match candidate fields of the composite index based on the query fields after segmentation, and then select the optimized composite index based on the retrieval time of different indexes and the number of references of different indexes. Without increasing the number of database server clusters, this reduces the amount of subsequent access data to be retrieved, thereby speeding up the database response. Attached Figure Description

[0031] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0032] Figure 1 This is a schematic diagram illustrating an application scenario of the database optimization method provided in the embodiments of this application;

[0033] Figure 2 This is a schematic diagram of a database optimization method provided in one embodiment of this application;

[0034] Figure 3This is a schematic diagram of the structure of a database optimization apparatus provided in one embodiment of this application;

[0035] Figure 4 This is a schematic diagram of the hardware structure of a server provided in one embodiment of this application.

[0036] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0037] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0038] With the widespread penetration of cloud computing technology into various professional fields, higher demands are being placed on the processing of massive amounts of data. While traditional databases can guarantee permanent data storage, the rigor of practical operations and the read / write speeds of storage devices lead to inefficiencies when faced with massive data requests, necessitating optimization. Current technologies characterize database load features based on the quantity of various data access operations, use Markov chain models to predict the workload of data access operations at the next time step based on these load features, construct a performance model of the database cluster under preset load conditions based on historical training data, predict the performance of the database server cluster under preset load using the performance model, group database servers requiring reconfiguration, and formulate configuration plans based on the throughput and cost of the database server cluster. However, improving database service efficiency by increasing the number of database clusters requires ensuring a sufficient number of database server clusters, which is unsuitable for databases with a small number of database server clusters.

[0039] To address the aforementioned technical issues, this application proposes the following technical approach: by segmenting various types of accessed data, matching candidate indexes of the composite index based on the query fields of the segments, selecting the candidate index with the shortest retrieval time as the composite index, further reducing the retrieval volume of subsequent accessed data, and accelerating the feedback speed of accessed data. By sorting the reference counts of each composite index, the self-updating of the composite index is achieved, thereby accelerating the database's response speed when handling massive data requests.

[0040] The database optimization method provided in this application aims to solve the above-mentioned technical problems in the prior art.

[0041] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0042] Figure 1 This is a schematic diagram illustrating an application scenario of the database optimization method provided in this application embodiment. For example... Figure 1 As shown, it includes: terminal 101 and database server 102.

[0043] Terminal 101 sends user-input access data to database server 102 and displays the search results after the database server 102 processes the data. Database server 102 generates composite indexes to optimize the database. Database server 102 includes an index database 103 and a storage database 104. Index database 103 stores composite indexes and single-column indexes, while the storage database stores the data to be stored.

[0044] Figure 2 This is a schematic diagram of a database optimization method provided in one embodiment of this application. The execution entity of this embodiment can be... Figure 1 The database server in the illustrated embodiment can also be other service devices with similar functions; this embodiment does not impose any particular limitations here. Figure 2 As shown, the method includes:

[0045] S201: Obtain the access data, segment the access data, and obtain the segmented query fields.

[0046] In this embodiment, obtaining access data can be achieved by receiving access data sent by terminal 101. The access data from terminal 101 can be generated in response to user input.

[0047] Specifically, based on big data analytics, the access data is segmented, and the query fields are extracted. First, raw access data of various types is acquired. The collected clickstream data is preprocessed using a MapReduce program, such as cleaning, formatting, and filtering out dirty data. The preprocessed data is then imported into the corresponding databases and tables in the Hive repository. ETL (Extract-Transform-Load) analysis statements are developed according to requirements to obtain various statistical results. The segmented query fields can be obtained by visualizing the analyzed data.

[0048] One method to obtain various types of raw access data is to capture user access behavior by embedding JavaScript code in the page and sending it to the backend of the web service to record logs. Then, the clickstream logs generated on each server are aggregated into HDFS (Hadoop Distributed File System) in real time or in batches.

[0049] S202: Determine the number of query fields after segmentation.

[0050] Specifically, step S202 includes Sa~Sd:

[0051] Sa: Retrieve response data based on a single index field, where the single index field is pre-defined based on a created single-column index.

[0052] Specifically, the process begins with a retrieval based on a single index field. The database server then retrieves the response value based on this single index field and uses it to query the database to obtain the response data.

[0053] Among them, a single-index field is a field set when the database creates a single-column index.

[0054] Sb: Iterates and matches the segmented query fields with the response data.

[0055] Specifically, the segmented query fields are traversed and matched with the fields in the response data.

[0056] For example, if the single indexed field in the accessed data is "Name" "Li Si", according to "name" The search for "Li Si" yielded response data, with the segmented query fields including "grade". 'Third grade' and subjects "Mathematics" will be the grade level. "Third Grade", Subject "Mathematics" and Name The query "Li Si" is performed in conjunction with the response data in sequence.

[0057] Sc: If no other matching query fields are found, the number of query fields is 1.

[0058] For example, if no other fields are matched in the response data, the number of fields queried is determined to be 1.

[0059] Sd: If other matching queries are found, the number of query fields is 1. n, where n is the number of other matches with the same query field, and n is a positive integer.

[0060] For example, if the response data matches "name" 'Li Si' and grade If the query data is "Grade 3", then the query field in the accessed data is "Name". 'Li Si' and grade "3rd grade", at this time, the number of query fields is 2.

[0061] S203: If there are multiple query fields, then all combinations of query fields are obtained based on all query fields.

[0062] Specifically, if the number of query fields is greater than 1, then all combinations of query fields are arranged according to all query fields.

[0063] For example, if the query fields are A, B, C, then all the possible combinations of query fields are as follows: {A}, {B}, {C}, {A, B}, {A, C}, {B, C}, and {A, B, C}.

[0064] S204: Perform a retrieval based on each combination of query fields. If a unique response value is obtained, record the retrieval time for each combination of query fields.

[0065] Specifically, step S204 includes Se~Sh:

[0066] Se: Retrieves results based on combinations of query fields.

[0067] For example, a retrieval is performed based on all the query field combinations: {A}, {B}, {C}, {A,B}, {A,C}, {B,C}, and {A,B,C}, to obtain the response value for each query field combination.

[0068] Sf: If a unique response value is obtained, then obtain the physical address of that unique response value.

[0069] Specifically, if the response value obtained by searching based on the combination of query fields is unique, then the physical address of the unique response value can be obtained.

[0070] For example, if the response value retrieved based on the query field combinations {A,B}, {B,C}, and {A,B,C} is unique, then the physical address in the response value retrieved based on the query field combinations {A,B}, {B,C}, and {A,B,C} is obtained.

[0071] Sg: Access the response data based on the physical address.

[0072] For example, response data in the storage database can be accessed based on the physical address in the response value retrieved from the query field combinations {A,B}, {B,C}, and {A,B,C}.

[0073] Sh: Records the time from the start of retrieval to accessing the response data for each combination of query fields, in order to obtain the retrieval time for each combination of query fields.

[0074] Specifically, the time from the start of the retrieval to the access to the response data for each combination of query fields that yields a unique response value is recorded to obtain the retrieval time for each combination of query fields.

[0075] S205: Sort the retrieval times of each query field combination from smallest to largest, and create a composite index for each query field combination corresponding to the first preset number of retrieval times, resulting in multiple composite indexes.

[0076] Among them, the query field combination corresponding to the pre-set number of retrieval times refers to the combination of multiple query fields with the shortest retrieval time.

[0077] For example, the retrieval times for the query field combinations {A,B}, {B,C}, and {A,B,C} are T1, T2, and T3, respectively, where T3>T1>T2. A composite index is created using the first two query field combinations, which means creating two composite indexes for the database for the query field combinations {A,B,C} and {A,B}.

[0078] S206: Record the reference counts of multiple composite indexes and sort the composite indexes in descending order of reference count.

[0079] Specifically, step S206 records the reference counts of multiple composite indexes, including Si~Sk:

[0080] Si: Obtain access data, segment the access data, and obtain segmented query data.

[0081] Specifically, when new access data is requested, the access data is segmented based on big data analysis to obtain segmented query data.

[0082] Sj: If the segmented query data is consistent with any field of a composite index, then the reference count of any composite index is incremented by one to obtain the reference count of any composite index.

[0083] Specifically, if the segmented query data is one of multiple composite indexes, and the response data can be quickly accessed based on the composite index, then the reference count of the composite index is incremented by one to obtain the new reference count of the composite index.

[0084] Sk: Records the reference count of any composite index, and provides the reference count of multiple composite indexes.

[0085] Specifically, the query data is retrieved based on the segmented query data from multiple accessed data, resulting in the reference counts of multiple composite indexes.

[0086] After obtaining the reference counts of multiple composite indexes, the composite indexes are re-sorted from largest to smallest based on their current reference counts.

[0087] For example, if the database creates composite indexes {A,B,C} and {A,B}, and when there is a data access request, the query field after accessing the segmented data is {A,B} and can be quickly retrieved, meaning it matches the second composite index {A,B}, the second composite index is referenced, and its reference count is incremented by 1. Based on the reference count, the two composite indexes are sorted in descending order of reference count.

[0088] S207: Store the sorted composite indexes to complete database optimization.

[0089] Specifically, the sorted composite indexes are stored in the index database, thus completing the database optimization.

[0090] In summary, by segmenting data of different types and matching candidate fields for the composite index based on the segmented query fields, and selecting the optimized composite index based on the retrieval time and reference count of different indexes, the retrieval volume of subsequent access data can be reduced. This achieves the technical effect of accelerating the database response speed without increasing the number of database server clusters.

[0091] In one embodiment of this application, based on the above embodiments, before step S201 obtains the access data, a process of determining whether an index needs to be created is further included, specifically including:

[0092] S301: Get the amount of data to be stored.

[0093] S302: If the amount of data is less than the preset storage value or if there are duplicate data to be stored that exceed the preset percentage, then there is no need to create an index and the data can be stored directly.

[0094] Specifically, if the amount of data to be stored is less than the preset storage value, there is no need to create a single-column index, and the data to be stored is directly stored in the storage database. If there are duplicate data to be stored that exceed a preset percentage in the data to be stored, there is also no need to create a single-column index, and the data to be stored is directly stored in the storage database.

[0095] S303: If the data volume is not less than the preset storage value, then create a single-column index and store it.

[0096] Specifically, if the amount of data to be stored is not less than the preset storage value, a single-column index is created, the data to be stored is stored in the storage database, and the created single-column index is stored in the index database.

[0097] For example, if the amount of data to be stored is less than 300, there is no need to create a single-column index; the data to be stored is directly stored in the storage database. If the amount of data to be stored exceeds 300, a single-column index is created for the data to be stored, stored in the index database, and the data to be stored is stored in the storage database. If more than 60% of the data to be stored is duplicate data, all the data to be stored is directly stored in the storage database.

[0098] In summary, by creating a single-column index for data to be stored that exceeds the preset storage value, the amount of data retrieval can be reduced, thereby speeding up the data access response.

[0099] Figure 3 This is a schematic diagram of the structure of a database optimization apparatus provided in one embodiment of this application. Figure 3 As shown, the database optimization device includes: a data segmentation module 301, a field count judgment module 302, a query field combination acquisition module 303, a retrieval time calculation module 304, a composite index creation module 305, a reference count sorting module 306, and a composite index storage module 307.

[0100] The access data segmentation module 301 is used to obtain access data and segment the access data to obtain the segmented query fields.

[0101] The field count determination module 302 is used to determine the number of query fields after segmentation.

[0102] The query field combination acquisition module 303 is used to obtain all query field combinations based on all query fields if there are multiple query fields.

[0103] The retrieval time calculation module 304 is used to perform retrieval based on each combination of query fields. If a unique response value is obtained, the retrieval time of each combination of query fields is recorded.

[0104] The composite index creation module 305 is used to sort the retrieval times of each combination of query fields from smallest to largest, and create composite indexes for the query field combinations corresponding to the first preset number of retrieval times, resulting in multiple composite indexes.

[0105] The reference count sorting module 306 is used to record the reference count of multiple composite indexes and sort the multiple composite indexes in descending order of reference count.

[0106] The composite index storage module 307 is used to store the sorted composite indexes to optimize the database.

[0107] Optionally, as described above, the field count determination module 302 is specifically used to retrieve response data based on a single index field, where the single index field is pre-defined based on a created single-column index. The segmented query fields are traversed and matched against the response data. If no other matching query fields are found, the number of query fields is 1. If other matching query fields are found, the number of query fields is 1 + n, where n is the number of other matching query fields, and n is a positive integer.

[0108] Optionally, as described above, the retrieval time calculation module 304 is specifically used to perform retrieval based on each combination of query fields. If a unique response value is obtained, the physical address of the unique response value is acquired. The response data is accessed based on the physical address. The time from the start of retrieval to accessing the response data for each combination of query fields is recorded to obtain the retrieval time for each combination of query fields.

[0109] Optionally, as described above, the reference count sorting module 306 is specifically used to obtain access data, segment the access data, and obtain segmented query data. If the segmented query data is consistent with a field of any composite index, the reference count of any composite index is incremented by one, obtaining the reference count of any composite index. The reference count of any composite index is recorded, resulting in the reference counts of multiple composite indexes. The multiple composite indexes are then sorted in descending order of reference count.

[0110] Optionally, in the method described above, the database optimization device further includes: a single-column index creation module; this single-column index creation module is specifically used to obtain the data volume of the data to be stored. If the data volume is less than a preset storage value or if there are duplicate data to be stored exceeding a preset proportion in the data to be stored, then no index needs to be created, and the data is stored directly. If the data volume is not less than the preset storage value, then a single-column index is created and stored.

[0111] The apparatus provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effects are similar, and will not be described again here.

[0112] Figure 4 This is a schematic diagram of the hardware structure of a server provided in one embodiment of this application. Figure 4 As shown, the server in this embodiment includes: at least one processor 401 and a memory 402; the memory stores computer-executable instructions; the at least one processor executes the computer-executable instructions stored in the memory, causing the at least one processor to execute the database optimization method described above.

[0113] Alternatively, the memory 402 can be either standalone or integrated with the processor 401.

[0114] When the memory 402 is set up independently, the service device also includes a bus 403 for connecting the memory 402 and the processor 401.

[0115] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the database optimization method described above.

[0116] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the database optimization method described above.

[0117] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0118] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0119] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0120] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0121] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0122] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0123] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.

[0124] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0125] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A database optimization method, characterized in that, Applied to database servers, including: Obtain access data and segment the access data to obtain the segmented query fields; The response data is obtained by retrieving based on a single index field, wherein the single index field is pre-defined based on a created single-column index; the segmented query fields are then traversed and matched with the response data; If no other matching query fields are found, the number of query fields is 1; if other matching query fields are found, the number of query fields is [number missing]. n is the number of other matches with the same query field, and n is a positive integer; If the number of query fields is greater than 1, then all combinations of query fields are obtained based on all query fields; The search is performed based on each combination of query fields. If a unique response value is obtained, the search time for each combination of query fields is recorded. The retrieval times of each query field combination are sorted from smallest to largest, and a composite index is created for each of the first preset number of query field combinations corresponding to the retrieval times, resulting in multiple composite indexes. Record the reference counts of the multiple composite indexes, and sort the multiple composite indexes in descending order of reference count; The sorted composite indexes are stored to complete the database optimization.

2. The method according to claim 1, characterized in that, The process involves retrieving data based on each combination of query fields. If a unique response value is obtained, the retrieval time for each combination of query fields is recorded, including: Search based on combinations of query fields; If a unique response value is obtained, then the physical address of that unique response value is obtained; Access the response data based on the physical address; Record the time from the start of retrieval to access of the response data for each combination of query fields to obtain the retrieval time for each combination of query fields.

3. The method according to claim 1, characterized in that, The record of reference counts for the multiple composite indexes includes: Obtain the access data, segment the access data according to the access data, and obtain segmented query data; If the segmented query data is consistent with any field of a composite index, then the reference count of any composite index is incremented by one to obtain the reference count of any composite index. Record the reference count of any one of the composite indexes to obtain the reference count of the multiple composite indexes.

4. The method according to any one of claims 1 to 3, characterized in that, Before obtaining the access data, the process also includes: Get the amount of data to be stored; If the amount of data is less than the preset storage value or if there are duplicate data to be stored in the data to be stored that exceed the preset percentage, then there is no need to create an index and the data can be stored directly. If the amount of data is not less than the preset storage value, then a single-column index is created and stored.

5. A database optimization device, characterized in that, include: The access data segmentation module is used to acquire access data and segment the access data to obtain the segmented query fields; The field count determination module is used to retrieve response data based on a single index field, wherein the single index field is pre-defined based on a created single-column index; it iterates and matches the segmented query fields with the response data; if no other matching query fields are found, the number of query fields is 1; if other matching query fields are found, the number of query fields is [not specified]. n is the number of other identical query fields matched, and n is a positive integer used to determine the number of query fields after segmentation; The query field combination acquisition module is used to obtain all query field combinations based on all query fields if the number of query fields is greater than 1. The retrieval time calculation module is used to perform retrieval based on each combination of query fields. If a unique response value is obtained, the retrieval time for each combination of query fields is recorded. The composite index creation module is used to sort the retrieval times of each combination of query fields from smallest to largest, and create composite indexes for the query field combinations corresponding to the first preset number of retrieval times, resulting in multiple composite indexes. The reference count sorting module is used to record the reference counts of the multiple composite indexes and sort the multiple composite indexes in descending order of reference count; The composite index storage module is used to store the sorted composite indexes to optimize the database.

6. The apparatus according to claim 5, characterized in that, The retrieval time calculation module is specifically used for: The search is performed based on the combination of each query field; if a unique response value is obtained, the physical address of the unique response value is obtained; the response data is accessed based on the physical address; the time from the start of the search to the access of the response data for each query field combination is recorded to obtain the search time for each query field combination.

7. A server, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the database optimization method as described in any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the database optimization method as described in any one of claims 1 to 4.