Index information creating method, device and equipment and readable storage medium
By creating and testing index information in the database's mirror database, determining its usage, and creating index information in the target database when specific conditions are met, the problem of how to effectively create index information in the database to improve data access efficiency is solved. Efficient index information management is achieved.
Patent Information
- Application Number
- CN202310901425.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2025-01-21
AI Technical Summary
Creating effective index information in a database to improve data access efficiency is an urgent problem. It is difficult for the prior art to create index information effectively to avoid increasing database load.
Create a mirror database by mirroring the target database, and create index information in the mirror database. Obtain access logs by sending access requests, determine the usage information of the index information, and create index information in the target database after meeting specific conditions.
This method avoids blindly adding index information in the target database, thereby reducing database load, improving data access efficiency, and ensuring that the index information added in the target database is effective.
Smart Images

Figure CN119336748A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of database technology, and in particular to a method, device, equipment and readable storage medium for creating index information. Background Art
[0002] With the development of database technology, the types and quantities of data stored in databases are increasing, which affects the efficiency of data access. Generally, index information can be created in the database, and the storage area where the data is located can be determined by querying the index information, and the data in the storage area can be accessed, thereby improving the efficiency of data access. Based on this, how to create index information in the database has become an urgent problem to be solved. Summary of the invention
[0003] The present application provides a method, device, equipment and readable storage medium for creating index information, which can add valid index information to a target database. The technical solution includes the following contents.
[0004] In one aspect, a method for creating index information is provided, the method comprising:
[0005] Mirror the target database to obtain a mirror database;
[0006] Creating first index information in the mirror database;
[0007] Sending multiple first access requests to the mirror database to obtain access logs of the first access requests, wherein the access log of any first access request is used to record that the mirror database queries reference index information based on any first access request to access the data in the mirror database;
[0008] In a case where the reference index information includes the first index information, determining usage information of the first index information according to the access logs of the respective first access requests;
[0009] Based on the usage information of the first index information satisfying a usage condition, the first index information is created in the target database.
[0010] In another aspect, a device for creating index information is provided, the device comprising:
[0011] A mirror processing module is used to perform mirror processing on the target database to obtain a mirror database;
[0012] A creation module, used to create first index information in the mirror database;
[0013] a sending and obtaining module, configured to send a plurality of first access requests to the mirror database, and obtain access logs of the respective first access requests, wherein the access log of any first access request is used to record that the mirror database queries reference index information based on any first access request, and accesses the data in the mirror database;
[0014] a determination module, configured to determine usage information of the first index information according to the access logs of the respective first access requests when the reference index information includes the first index information;
[0015] The creation module is further configured to create the first index information in the target database based on the usage information of the first index information satisfying a usage condition.
[0016] In a possible implementation, the sending and obtaining module is used to obtain data access information of the target database, where the data access information is used to describe the type and number of target access requests sent to the target database; according to the type and number of the target access requests, multiple first access requests are sent to the mirror database to obtain access logs of each first access request.
[0017] In a possible implementation, the mirror processing module is used to perform backup processing on each original file included in the target database to obtain each backup file; and perform backup and recovery processing based on the each backup file to obtain the mirror database.
[0018] In a possible implementation, the creation module is used to obtain a creation script file, where the creation script file is used to define a creation function for creating the first index information in the mirror database; and the first index information is created in the mirror database by running the creation script file.
[0019] In a possible implementation manner, the usage information of the first index information includes a byte length used by the first index information;
[0020] The creation module is used to calculate the ratio between the byte length used by the first index information and the total byte length of the first index information; based on the ratio being greater than a ratio threshold, the first index information is created in the target database, and the usage information of the first index information satisfies the usage condition including that the ratio is greater than the ratio threshold.
[0021] In a possible implementation manner, the device further includes:
[0022] The deleting module is configured to delete the first index information in the mirror database based on the usage information of the first index information not satisfying the usage condition.
[0023] In a possible implementation manner, the device further includes:
[0024] an acquisition module, configured to acquire an adjustment script file based on the fact that the usage information of the first index information does not satisfy the usage condition, wherein the adjustment script file is used to define an adjustment function for adjusting the first index information in the mirror database;
[0025] An adjustment module, configured to adjust the first index information in the mirror database by running the adjustment script file to obtain second index information;
[0026] The sending and obtaining module is further used to send multiple second access requests to the mirror database to obtain access logs of each second access request, wherein the access log of any second access request is used to record that the mirror database queries the target index information based on any second access request to access the data in the mirror database;
[0027] The determination module is further configured to determine usage information of the second index information according to the access logs of the respective second access requests when the target index information includes the second index information;
[0028] The creation module is further configured to create the second index information in the target database based on the usage information of the second index information satisfying the usage condition.
[0029] On the other hand, an electronic device is provided, comprising a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor so that the electronic device implements any of the above-mentioned methods for creating index information.
[0030] On the other hand, a computer-readable storage medium is provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor so that an electronic device can implement any of the above-mentioned methods for creating index information.
[0031] On the other hand, a computer program is also provided. The computer program is at least one, and the at least one computer program is loaded and executed by a processor to enable an electronic device to implement any of the above-mentioned index information creation methods.
[0032] On the other hand, a computer program product is also provided, wherein at least one computer program is stored in the computer program product, and the at least one computer program is loaded and executed by a processor to enable an electronic device to implement any of the above-mentioned methods for creating index information.
[0033] The technical solution provided by this application brings at least the following beneficial effects:
[0034] In the technical solution provided by the present application, first index information is created in a mirror database of a target database, multiple first access requests are sent to the mirror database to obtain access logs of each first access request, and usage information of the first index information is determined according to the access logs of each first access request, so that the first index information is tested in the mirror database to obtain usage information of the first index information, thereby avoiding increasing the load of the target database due to blindly adding the first index information in the target database and affecting the data access efficiency of the target database. Since the mirror database is obtained by mirroring the target database, the mirror database is similar to the target database, and the usage information of the first index information obtained by testing the first index information in the mirror database can reflect the usage of the first index information by the target database. When the usage information of the first index information meets the usage condition, the first index information is created in the target database, so that valid index information is added in the target database, so that the target database can improve data access efficiency based on the valid index information. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 It is a schematic diagram of an implementation environment of a method for creating index information provided in an embodiment of the present application;
[0037] Figure 2 is a flowchart of a method for creating index information provided by an embodiment of the present application;
[0038] Figure 3 This is a schematic diagram of resource changes during the creation of a mirror database provided by an embodiment of the present application;
[0039] Figure 4 This is a schematic diagram of resource changes during the index information creation process provided by an embodiment of the present application;
[0040] Figure 5This is a schematic diagram of a change in request information provided by an embodiment of the present application;
[0041] Figure 6 It is a schematic diagram of a framework of a method for creating index information provided in an embodiment of the present application;
[0042] Figure 7 This is a schematic diagram of a search interface provided in an embodiment of the present application;
[0043] Figure 8 This is another schematic diagram of a search interface provided in an embodiment of the present application;
[0044] Fig. 9 It is a structural schematic diagram of a device for creating index information provided in an embodiment of the present application;
[0045] Fig.10 is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application;
[0046] Fig.11 It is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0048] Figure 1 is a schematic diagram of an implementation environment of a method for creating index information provided in an embodiment of the present application, such as Figure 1 As shown, the implementation environment includes a terminal device 101 and a server 102. The index information creation method in the embodiment of the present application can be executed by the terminal device 101, or by the server 102, or by the terminal device 101 and the server 102 together.
[0049] The terminal device 101 can be a smart phone, a game console, a desktop computer, a tablet computer, a laptop computer, a smart TV, a smart car device, an intelligent voice interaction device, a smart home appliance, etc. The server 102 can be a single server, or a server cluster consisting of multiple servers, or any one of a cloud computing platform and a virtualization center, which is not limited in the embodiments of the present application. The server 102 can be connected to the terminal device 101 through a wired network or a wireless network. The server 102 can have functions such as data processing, data storage, and data transmission and reception, which are not limited in the embodiments of the present application. The number of terminal devices 101 and servers 102 is not limited and can be one or more.
[0050] In the field of database technology, index information can be created in a database, and the storage area where the data is located can be determined by querying the index information, and the data in the storage area can be accessed, thereby improving the efficiency of accessing the data. Based on this, how to create index information in a database has become an urgent problem to be solved.
[0051] The present application embodiment provides a method for creating index information, which can be applied to the above implementation environment and can add valid index information to the target database. Figure 2 Taking the flowchart of a method for creating index information provided by an embodiment of the present application as an example, for ease of description, the terminal device 101 or the server 102 that executes the method for creating index information in the embodiment of the present application is referred to as an electronic device, and the method can be executed by an electronic device. Figure 2 As shown, the method includes the following steps.
[0052] Step 201, mirroring is performed on the target database to obtain a mirror database.
[0053] In the embodiment of the present application, the target database is any database having data storage function and data access function. Exemplarily, the target database is a relational database such as My Structured Query Language (MySQL), or the target database is a non-relational database such as Not Only Structured Query Language (NoSQL), or the target database is a database between a relational database and a non-relational database such as Mongo Database (MongoDB).
[0054] The target database can be mirrored by physical backup or logical backup to obtain a mirror database, which is described below. Since the mirror database is obtained by mirroring the target database, the type, size, quantity, storage location, etc. of the data in the mirror database are the same as those in the target database.
[0055] In a possible implementation, the target database is mirrored by physical backup to obtain a mirror database. In this method, step 201 includes steps 2011 to 2012 (not shown in the figure).
[0056] Step 2011, backing up each original file included in the target database to obtain each backup file.
[0057] In the embodiment of the present application, the target database includes multiple original files, any of which can be any physical file such as a data file, a control file, a log file, an executable file, etc., and a physical file is a file that stores data. Among them, a data file is a file that transfers data from an outward copy operation to an inward copy operation, a control file is used to record information such as the name of the database and the location of the data file, a log file is used to record the operation behavior of the database, and an executable file is a binary file that can be directly loaded and executed by a device.
[0058] By performing a backup process on any original file, a backup file corresponding to the original file is obtained, and the backup file can be stored in a storage device such as a disk or a tape. In an embodiment of the present application, performing a backup process on the original file to obtain a backup file includes: performing a compression process on the original file to obtain a compressed file, and the compressed file is the backup file. In this way, the backup process is performed on each original file to obtain a backup file corresponding to each original file.
[0059] Step 2012: Perform backup and recovery processing based on each backup file to obtain a mirror database.
[0060] In the embodiment of the present application, any backup file is a compressed file obtained by compressing an original file, and the compressed file can be decompressed to obtain a decompressed file. Generally, the content of the decompressed file is the same as the content of the original file, and the storage directory of the decompressed file in the mirror database is the same as the storage directory of the original file in the target database. Based on this, performing backup and recovery processing on any backup file is equivalent to decompressing the backup file to obtain a decompressed file whose storage directory in the mirror database is the same as the storage directory of the original file corresponding to the backup file in the target database. In this way, each backup file is backed up and recovered to obtain each decompressed file whose storage directory in the mirror database is the same as the storage directory of the corresponding original file in the target database, thereby obtaining a mirror database, so that the storage path, storage method, etc. of the data in the mirror database are consistent with the storage path, storage method, etc. of the data in the target database.
[0061] In another possible implementation, the target database is mirrored by means of logical backup to obtain a mirror database. In this method, step 201 includes: backing up each original operation log included in the target database to obtain each backup operation log; and performing backup recovery based on each backup operation log to obtain a mirror database.
[0062] The original operation log is used to describe operations such as adding, deleting, and changing data in the target database. You can use a backup tool (such as the mongodump tool) to back up each original operation log in the target database, obtain a backup operation log corresponding to each original operation log, and store each backup operation log in a storage device such as a disk or a tape. Then, use a recovery tool (such as the mongorestore tool) to replay each backup operation log to restore the data in the target database, thereby obtaining a mirror database.
[0063] From the above content, we can know that physical backup and logical backup are two different backup methods, and different backup methods have different advantages and disadvantages. The following table 1 briefly introduces the physical backup method and logical backup method and their respective advantages and disadvantages.
[0064] Table 1
[0065]
[0066] Since physical backup has the characteristics of fast backup speed and fast recovery speed, the embodiment of the present application can use physical backup to quickly create a mirror database according to steps 2011 to 2012. According to the test, if the data volume of the target database is about 7 terabytes (TB), it takes about 1 hour to create a mirror database based on the target database by using the physical backup method, and it takes about 2 days to create a mirror database based on the target database by using the logical backup method.
[0067] Please refer to Table 2 below. Table 2 briefly introduces the resource consumption of traditional backup methods, logical backup methods, and physical backup methods, the time required for database recovery, the time required for testing index information, and the total cost. Among them, the traditional backup method is to prepare two databases of the same size, one database as the target database and the other database as the backup database. Every time the target database processes a data access request, the backup database also processes the data access request accordingly. Therefore, the traditional backup method requires twice the resource consumption. The logical backup method is to back up the operation log of the target database. During backup and recovery, a large amount of computing resources are required to run the operation log, which is equivalent to double the resource consumption. The physical backup method is to back up the original files of the target database. During backup and recovery, fewer computing resources are required, so the resource consumption is lower.
[0068] Table 2
[0069]
[0070] As can be seen from Table 2, compared with the traditional backup method and the logical backup method, the physical backup method has obvious advantages in terms of time cost and resource consumption. By backing up the original files in the target database through physical backup to obtain backup files, and performing backup and recovery based on the backup files to obtain the mirror database, the efficiency of creating the mirror database can be improved and the cost can be reduced.
[0071] It is understandable that while backing up the target database, operations such as data addition, data deletion, and data modification may occur in the target database, which can be called incremental operations. When creating a mirror database by physical backup, it is not necessary to synchronize incremental operations, but when creating a mirror database by physical backup, it may be necessary to synchronize incremental operations. When using logical backup to synchronize incremental operations on a 7TB target database, it takes at least 0.5 days. Therefore, the embodiment of the present application creates a mirror database by physical backup, which can improve the generation efficiency of the mirror database. Compared with the logical backup method, the generation speed of the mirror database is increased by about 2000%.
[0072] Please attend Figure 3 , Figure 3 This is a schematic diagram of resource changes during the creation of a mirror database provided in an embodiment of the present application. Resources include central processing unit (CPU) resources, memory resources, disk resources, network resources, etc., wherein, for CPU resources, the maximum utilization rate 1 of CPU resources (corresponding to database 1), the maximum utilization rate 2 of CPU resources (corresponding to database 2), the average utilization rate 1 of CPU resources (corresponding to database 1), and the average utilization rate 2 of CPU resources (corresponding to database 2) can be obtained. For memory resources, the maximum utilization rate 1 of memory resources (corresponding to database 1), the maximum utilization rate 2 of memory resources (corresponding to database 2), the average utilization rate 1 of memory resources (corresponding to database 1), and the average utilization rate 2 of memory resources (corresponding to database 2) can be obtained. For disk resources, the utilization rate of disk resources can be obtained. For network resources, the number of connections of network resources, the connection percentage of network resources, the inbound flow of network resources (in bytes), and the outbound flow of network resources (in bytes) can be obtained. Based on the above information, the following is obtained: Figure 3 Schematic diagram of resource changes shown.
[0073] It should be noted that Figure 3 The resource change diagram shown is only for reference; the interface style, format, layout, data, etc. can be flexibly changed according to actual application conditions.
[0074] After testing, when backing up the target database using physical backup, the start time is about 17:12, the computing resources and network resources are allocated at about 17:45, and the time to create the mirror database is about 18:17, which takes about 1 hour in total. It can be seen that creating a mirror database of the target database through physical backup can improve the efficiency of database creation.
[0075] Step 202: Create first index information in the mirror database.
[0076] In an embodiment of the present application, the first index information can be created in the mirror database in the form of a script file or a command line, which are described below. The mirror database includes multiple data tables, and the first index information is a storage structure that sorts the values of at least one column in one or more data tables. The first index information includes the value of at least one column in the data table and a pointer to these values in the data table. The mirror database can use the first index information to determine a specific value (i.e., the value of one or more columns in the data table), and determine the row including the specific value through a pointer to the specific value, thereby accessing the data in the mirror database. In simple terms, the first index information is equivalent to the directory of a book, and the required content can be quickly found according to the page number in the directory.
[0077] In a possible implementation, the first index information is created in the mirror database by using a script file. In this case, step 202 includes steps 2021 to 2022 (not shown in the figure).
[0078] Step 2021: Obtain a creation script file, where the creation script file is used to define a creation function for creating first index information in a mirror database.
[0079] The embodiment of the present application does not limit the way in which the electronic device obtains the creation script file. For example, the electronic device can obtain the input creation script file, or the electronic device can receive the creation script file sent by other devices through the network, or the electronic device can read the creation script file from a storage device.
[0080] In the embodiment of the present application, the creation script file is used to define the creation function, and the creation function includes a statement for determining the mirror database and a statement for creating the first index information for the data table included in the mirror database, and the first index information is created in the mirror database through these statements. Optionally, the creation function may also include other statements, for example, the creation function also includes a statement for obtaining the start time of creating the first index information, a statement for obtaining the end time of creating the first index information, and a statement for obtaining the total time spent on creating the first index information.
[0081] Exemplarily, the script file is created as follows.
[0082]
[0083]
[0084] It should be noted that the creation function may include a statement for specifying a data type. By using the statement for specifying the data type, the statement for determining the mirror database, and the statement for creating the first index information for the data table included in the mirror database, it is possible to create the first index information for the data of the specified data type in the mirror database.
[0085] For example, assume that the mirror database includes a data table named orders, which includes multiple types of order data. For example, the type of an order data can be any of the completed state, canceled state, and favorited state. If you need to create a first index information based on the customer ID (i.e., customerId) field for order data of the completed state (i.e., completed), the creation function can be as follows:
[0086]
[0087] In the above example, a first index information of the customerId field is created for the order data of type completed in the orders data table, so that when a customer needs to query the order data of the completed state, he can quickly query the order data of each completed state corresponding to the customer's customer number based on the first index information. By specifying the data type in the creation function, you can save storage space, improve index efficiency, and improve query performance.
[0088] Step 2022: Create first index information in the mirror database by running a creation script file.
[0089] In the embodiment of the present application, by running the creation script file, the creation function is executed, thereby realizing the creation of the first index information in the mirror database through the creation function.
[0090] Taking the creation script file shown in step 2021 as an example, the creation script file defines a creation function named createIndex. By running the creation script file, the main function is called to execute the createIndex function, thereby achieving: first print Start creating index... to indicate the start of creating the first index information. Next, get the current time and output the current time, and use this time to indicate the start time of creating the first index information. After that, use db.getSiblingDB("db_name") to determine the mirror database named db_name, and use indexDb.table_name.createIndex({"indexName":1}) to create the first index information on the data table "table_name" of the mirror database, and the field of the first index information is indexName. After the first index information is created, get the current time again and output the current time, and use this time to indicate the end time of creating the first index information. After that, subtract the start time from the end time to get the total time spent on creating the first index information.
[0091] Optionally, the electronic device can obtain a run command for running a creation script file, and run the creation script file by executing the run command. The embodiment of the present application does not limit the content of the run command. Exemplarily, the run command includes relevant characters of the mirror database and relevant characters of the creation script file, and these characters are used to indicate that the creation script file is run in the mirror database. Optionally, the run command also includes other characters. For example, the run command also includes relevant characters of a tool that supports running the creation script file through the run command, characters of the user name, characters of the password, and characters for generating a run log. A possible run command is shown below.
[0092] nohup mongo
[0093] 'mongodb: / / xx.xx.xx.xx:xxxx / admin? authSource=admin&authMechanism=SCRAM-SHA-1&readPreference=secondaryPreferred'-u$user-p$passwd. / createIndex.js2>&1>>. / createIndex.log&
[0094] Among them, nohup mongo is the name of the tool that supports running the creation script file by running the command. 'mongodb: / / xx.xx.xx.xx:xxxx / admin? authSource=admin&authMechanism=SCRAM-SHA-1&readPreference=secondaryPreferred' is the relevant character of the mirror database, which represents the command and parameter when accessing data for the mirror database. u$user-p$passwd represents the user name and password, and the mirror database is accessed by entering the user name and password. createIndex.js is the relevant character of the creation script file, which represents the name of the creation script file. createIndex.log is the character of generating the operation log, which represents the generation of the operation log in the process of creating the first index information.
[0095] See also Figure 4 , Figure 4 1 is a schematic diagram of resource changes during an index information creation process provided by an embodiment of the present application, wherein the index information creation process is a process of creating first index information in a mirror database using a script file. Figure 4 It can be seen that in the process of creating the first index information in the mirror database, the mirror database can receive a maximum of 10640 requests per second, an average of 8973 requests per second, and the average value of the maximum utilization rate of CPU resources is less than 30%, and the average value of the average utilization rate of CPU resources is less than 10%. It can be seen that using the script file to create the first index information can reduce the situation of blocking database operations and improve the performance of the database.
[0096] In another possible implementation, the first index information is created in the mirror database by using a command line. In this case, step 202 includes: obtaining a creation command line, where the creation command line is an instruction for creating the first index information in the mirror database; and creating the first index information in the mirror database by running the creation command line.
[0097] The present application embodiment does not limit the creation command line. Exemplarily, the creation command line includes characters for indicating the mirror database and characters for indicating the first index information, and these characters are used to represent the creation of the first index information in the mirror database. The electronic device includes a tool that supports the creation command line operation, and the creation command line is run through the tool (such as mongo) to achieve the creation of the first index information in the mirror database.
[0098] From the above content, we can see that the script file method and the command line method are two different methods, and different methods have different advantages and disadvantages. The following table 3 briefly introduces the script file method and the command line method, their respective advantages and disadvantages, and applicable scenarios.
[0099] Table 3
[0100]
[0101] As shown in Table 3, creating index information using script files supports the creation of complex index information and supports storing script files in the version control system, which is convenient for version control and code maintenance, and has advantages in scenarios where index information needs to be frequently modified and maintained. Creating index information using the command line is relatively simple and easy to use, and is suitable for quickly creating and testing index information.
[0102] Generally speaking, since the creation time of index information is often very long, using the command line to create index information may be limited by factors such as network environment jitter, Secure Shell (SSH) link timeout and disconnection, resulting in the interruption of the index information creation task. In addition, using the command line to create index information is not convenient for version control and maintenance.
[0103] In an embodiment of the present application, an operation of creating the first index information in a mirror database is defined by creating a script file. In the process of running the creation script file, the mirror database can be set to a state where the table is not locked. Generally speaking, if the mirror database is in a state where the table is locked when performing a certain operation, the mirror database cannot perform other operations in the process of performing the operation; conversely, if the mirror database is in a state where the table is not locked when performing a certain operation, the mirror database can perform other operations in the process of performing the operation. By setting the mirror database to a state where the table is not locked, it is achieved that the mirror database can also perform other operations in the process of creating the first index information, which is equivalent to asynchronously running the creation script file in the background, thereby achieving the goal of creating the first index information in the mirror database while avoiding blocking the database operation and improving the performance of the database.
[0104] Optionally, if the version of the mirror database is a version before MongoDB 4.2, the parameter background may be set to 1. The parameter background is a parameter indicating whether the mirror database is in a table lock state. If background=1, the mirror database is in a table unlock state.
[0105] Step 203, multiple first access requests are sent to the mirror database to obtain access logs of the first access requests. The access log of any first access request is used to record the mirror database's access to data in the mirror database based on any first access request querying reference index information.
[0106] In the embodiment of the present application, the triggering process of the data access request is simulated by the target program to generate and send the data access request. The embodiment of the present application does not limit the target program. For example, the target program is a program written in a programming language that can generate and send data access requests. The programming language can be an object-oriented language such as Java, C++, or Go language, C language, etc. Alternatively, the target program is a traffic playback tool configured on an electronic device. The electronic device can obtain the data access request sent by the user to the target database. The traffic playback tool can replay the data access request of the target database and send the replayed data access request (i.e., the first access request) to the mirror database. By replaying the data access request of the target database through the traffic recovery tool, the load of the target database can be accurately simulated, the situation of the mirror database using the first index information can be effectively evaluated, and the accuracy of the usage information of the first index information can be improved, so that it can more accurately determine whether to create the first index information in the target database, and avoid blindly increasing the load of the target database.
[0107] It should be noted that the first access request in step 203 is a data access request sent to the mirror database. Based on this, multiple first access requests can be generated by the target program, and each first access request can be sent to the mirror database.
[0108] Generally, the target database includes multiple created index information. For ease of description, the index information in the target database may be referred to as original index information. In the process of mirroring the target database to obtain the mirror database, each original index information may be backed up and restored so that the mirror database includes mirror index information of each original index information. After the first index information is created in the mirror database, the mirror database includes the mirror index information and the first index information.
[0109] After the mirror database receives any first access request, the mirror database can query the mirror index information and the first index information based on the first access request. Then, the reference index information is determined from the mirror index information and the first index information. The reference index information is used to indicate the storage location of the data requested to be accessed by the first access request in the mirror database. For the convenience of description, the storage location of the data requested to be accessed by the first access request in the mirror database is referred to as the first storage location. By querying the reference index information, the data in the first storage location included in the mirror database is accessed, thereby obtaining the data requested to be accessed by the first access request. In this process, the mirror database generates an access log of the first access request, and the access log records the process of the mirror database accessing the data in the first storage location based on the first access request.
[0110] The mirror database can generate an access log for each first access request in the above manner, and send the access log for each first access request to the electronic device, so that the electronic device can obtain the access log for each first access request after sending multiple first access requests to the mirror database.
[0111] In a possible implementation, step 203 includes steps 2031 and 2032 (not shown in the figure).
[0112] Step 2031: Acquire data access information of the target database, where the data access information is used to describe the type and quantity of target access requests sent to the target database.
[0113] In the embodiment of the present application, the target database can continuously receive data access requests sent by users. For the convenience of description, the data access requests received by the target database are referred to as target access requests. For each target access request, the target database can determine the type of the target access request, the time when the target access request is received, the amount of data requested by the target access request, etc. The target database obtains data access information by counting each target access request, and sends the data access information to the electronic device so that the electronic device obtains the data access information.
[0114] Exemplarily, there is at least one type of target access request, and the data access information includes the query rate per second (QPS) and the ratio of the number of each type of target access request, so as to describe at least one type of target access request and the number of target access requests corresponding to each type. For example, the types of target access requests include insert requests, read requests, update requests, etc., then the data access information includes the query rate per second, and includes the ratio of the number of insert requests, the number of read requests, and the number of update requests. For example, the query rate per second is 16000, and the number of insert requests: the number of read requests: the number of update requests is 2:5:2.
[0115] It is understandable that the query rate per second changes in real time, so the query rate per second included in the data access information may be the highest query rate per second in the specified time period. By selecting the highest query rate per second in the specified time period, rather than the average query rate per second or the lowest query rate per second in the specified time period, when the first access request is subsequently sent based on the data access information, it can be ensured that the number of first access requests is sufficient, the randomness of different types of data access requests is ensured, and the use information of the first index information is avoided from being inaccurate due to the data access request concentrating on accessing one or several data tables in the mirror database. In other words, ensuring the randomness of different types of data access requests can make the use of the first index information in the mirror database similar to the use of the first index information in the target database, which is conducive to adding valid index information to the target database and improving the data access efficiency of the target database.
[0116] It is understandable that the data access information may also include other information besides the type and quantity. For example, the data access information may also include the data volume of the data accessed by each type of target access request.
[0117] See also Figure 5 , Figure 5 is a schematic diagram of a change in request information provided by an embodiment of the present application, wherein the request information is data access information of a target access request. Figure 5 It can be seen that the target access request includes multiple types of requests such as insert request, read request (i.e., read request), update request, delete request, count request, etc., and the number of insert request, read request, and update request is much greater than the number of other types of requests such as delete request, count request, etc. Therefore, the maximum total request amount, i.e., 15866 (which can be approximately 16000), can be used as the query rate per second included in the data access information, and the maximum insert request amount: the maximum read request amount: the maximum update request amount, i.e., 3453:8751:3652 (which can be approximately 2:5:2) can be used as the number ratio of various target access requests included in the data access information.
[0118] Step 2032: Send multiple first access requests to the mirror database according to the type and quantity of the target access request, and obtain access logs of each first access request.
[0119] In an embodiment of the present application, the target program may send multiple first access requests to the mirror database according to the data access information. If the data access information includes at least one type of target access request and the number of target access requests corresponding to each type, the target program may send multiple first access requests that conform to each type and the corresponding number to the mirror database according to the at least one type and the corresponding number of each type.
[0120] For example, the data access information includes: the query rate per second is 16,000, and the number of insert requests: the number of read requests: the number of update requests is 2:5:2. Then the target program can simulate the query rate per second and the number ratio of various target access requests, and send 16,000 first access requests to the mirror database per second. These 16,000 first access requests include insert requests, read requests, and update requests, and the number of insert requests: the number of read requests: the number of update requests is 2:5:2.
[0121] If the data access information also includes the data volume of the data accessed by each type of target access request, the target program can send multiple first access requests that match the data volume corresponding to each type to the mirror database. It can be understood that for any two first access requests of the same type, the data volumes of the two first access requests can be the same or different. The average data volume of the data requested to be accessed by each first access request of the same type is the data volume of the data accessed by the target access request of the type included in the data access information.
[0122] For example, the data access information includes that the amount of data requested for access by the insert request is M, then the target program can send first access requests 1 to 3 to the mirror database, the amount of data requested for access by the first access request 1 is N1, the amount of data requested for access by the first access request 2 is N2, and the amount of data requested for access by the first access request 3 is N3, N1 is not equal to M, is not equal to N2 and is not equal to N3, N2 is not equal to M and is not equal to N3, N3 is not equal to M, but the average value of N1, N2, and N3 is equal to M.
[0123] As mentioned above, after receiving each first access request, the mirror database may generate an access log for each first access request and send the access log for each first access request to the electronic device, so that the electronic device can obtain the access log for each first access request.
[0124] Step 204: Determine usage information of the first index information according to the access log of each first access request.
[0125] In an embodiment of the present application, the electronic device can obtain a specified command for performing an execution efficiency analysis on the first access request, and analyze the access logs of each first access request through the specified command to obtain usage information of the first index information. Optionally, the specified command is an explain command, which is a command in the MongoDB database and is used to check whether the index information is effectively used.
[0126] Optionally, by specifying a command, at least one piece of information such as whether the first index information is used, the byte length of the first index information used, etc. can be obtained, and the usage information of the first index information includes at least one of the aforementioned information.
[0127] Step 205: Create the first index information in the target database based on the usage information of the first index information satisfying the usage condition.
[0128] As mentioned above, the usage information of the first index information includes information on whether the first index information is used and / or the byte length of the first index information used, etc. It is understandable that the usage information of the first index information includes different information, and the content of the usage condition satisfied by the usage information of the first index information is also different.
[0129] In a possible implementation, the usage information of the first index information includes the byte length used by the first index information. In this case, step 205 includes steps 2051 to 2052 (not shown in the figure).
[0130] Step 2051: Calculate the ratio between the used byte length of the first index information and the total byte length of the first index information.
[0131] In the embodiment of the present application, the total byte length of the first index information can be obtained by specifying a command. The used byte length of the first index information is divided by the total byte length of the first index information to obtain the ratio between the used byte length of the first index information and the total byte length of the first index information.
[0132] Step 2052: based on the ratio being greater than the ratio threshold, first index information is created in the target database, and usage information of the first index information satisfies a usage condition including that the ratio is greater than the ratio threshold.
[0133] The embodiments of the present application do not limit the method for determining the ratio threshold. Exemplarily, the ratio threshold is a value set based on manual experience, or a value range is set based on manual experience, a value is randomly generated within the value range, and the randomly generated value is used as the ratio threshold.
[0134] If the ratio between the used byte length of the first index information and the total byte length of the first index information is greater than the ratio threshold, it means that the usage information of the first index information meets the usage condition. In this case, the first index information is created in the target database. Optionally, the first index information can be created in the target database according to the implementation principle of step 202.
[0135] That is to say, based on the information of the target database, the creation script file is adjusted to obtain an adjusted creation script file, and the adjusted creation script file is used to define a creation function for creating the first index information in the target database. By running the adjusted creation script file, the first index information is created in the target database. The implementation method of this part of the content can be seen in the description of step 2021 to step 2022. The implementation principles of the two are similar and will not be repeated here.
[0136] Alternatively, based on the information of the target database, the creation command line is adjusted to obtain an adjusted creation command line, and the adjusted creation command line is used to create the first index information in the target database; by running the adjusted creation command line, the first index information is created in the target database. This part can be seen in the description of using the command line to create the first index information in the mirror database. The implementation principles of the two are similar and will not be repeated here.
[0137] Optionally, the mirror database generates a running log in the process of creating the first index information. For ease of description, the running log is referred to as the creation log of the first index information, and the creation log is used to describe the creation process of the first index information. In the embodiment of the present application, the electronic device can read the creation log of the first index information from the mirror database and send the creation log of the first index information to the target database. The target database creates the first index information in the target database by replaying the creation log of the first index information.
[0138] Since the mirror database is obtained by mirroring the target database, any data in the mirror database exists in the target database, and the storage path and storage method of the data in the mirror database are consistent with those in the target database. Based on this, the target database can quickly create the first index information in the target database through the creation log of the mirror database, thereby improving the efficiency of creating the first index information.
[0139] Optionally, the usage information of the first index information includes information on whether the first index information is used. If the first index information is used, it means that the usage information of the first index information meets the usage condition. Alternatively, the usage information of the first index information includes information on whether the first index information is used and the byte length of the first index information used. If the first index information is used, and the ratio between the byte length of the first index information used and the total byte length of the first index information is greater than a ratio threshold, it means that the usage information of the first index information meets the usage condition. In this case, the first index information is created in the target database.
[0140] In a possible implementation, the method of the embodiment of the present application further includes step 206 (not shown in the figure). Step 206 is performed after step 204.
[0141] Step 206: based on the usage information of the first index information not satisfying the usage condition, the first index information in the mirror database is deleted.
[0142] In an embodiment of the present application, if the usage information of the first index information includes information on whether the first index information is used, then when the first index information is not used, the usage information of the first index information does not meet the usage condition. If the usage information of the first index information includes the byte length of the first index information used, then when the ratio between the byte length of the first index information used and the total byte length of the first index information is not greater than a ratio threshold, the usage information of the first index information does not meet the usage condition. If the usage information of the first index information includes information on whether the first index information is used and the byte length of the first index information used, then when the first index information is not used, and / or the ratio between the byte length of the first index information used and the total byte length of the first index information is not greater than a ratio threshold, the usage information of the first index information does not meet the usage condition.
[0143] When the usage information of the first index information does not meet the usage condition, the first index information in the mirror database can be deleted using a script file or a command line. It can be understood that the deletion method of the first index information is similar to the creation method of the first index information, which can be seen in the description of step 202 and will not be repeated here.
[0144] Taking deleting the first index information in the mirror database by means of a script file as an example, a deletion script file can be obtained, and the deletion script file is used to define a deletion function for deleting the first index information in the mirror database. By running the deletion script file, the first index information in the mirror database is deleted. The implementation method of this part of the content can be seen in the description of step 2021 to step 2022, which will not be repeated here.
[0145] Since the usage information of the first index information does not meet the usage condition, the first index information is equivalent to invalid index information. By deleting the first index information in the mirror database, the invalid index information is deleted, the storage space of the mirror database is released, and the performance of the mirror database is optimized.
[0146] In a possible implementation, the method of the embodiment of the present application further includes steps 207 to 211 (not shown in the figure). Steps 207 to 211 are performed after step 204.
[0147] Step 207 : Based on the fact that the usage information of the first index information does not satisfy the usage condition, an adjustment script file is obtained, where the adjustment script file is used to define an adjustment function for adjusting the first index information in the mirror database.
[0148] In an embodiment of the present application, if the usage information of the first index information does not meet the usage conditions, the electronic device can obtain an input adjustment script file, or receive an adjustment script file sent by other devices through a network, or read an adjustment script file from a storage device. The adjustment script file is used to define an adjustment function, and the adjustment function includes a statement for determining a mirror database and a statement for adjusting the first index information, and these statements are used to adjust the first index information in the mirror database. Optionally, the adjustment function may also include other statements, for example, the adjustment function also includes a statement for obtaining the start time of adjusting the first index information, a statement for obtaining the end time of adjusting the first index information, and a statement for obtaining the total time spent on adjusting the first index information.
[0149] It is understandable that adjusting the script file is similar to creating the script text, as can be seen in the description of step 2021, which will not be repeated here.
[0150] Step 208: Adjust the first index information in the mirror database by running the adjustment script file to obtain second index information.
[0151] The electronic device can obtain a running command for running the adjustment script file, and run the adjustment script file by executing the running command. It can be understood that the running command for running the adjustment script file is similar to the running command for running the creation script file, which can be seen in the description of step 2022 and will not be repeated here.
[0152] By running the adjustment script file, the adjustment function is run, thereby adjusting the first index information in the mirror database through the adjustment function.
[0153] Step 209, multiple second access requests are sent to the mirror database to obtain access logs of the respective second access requests, wherein the access log of any second access request is used to record the mirror database's access to data in the mirror database by querying target index information based on any second access request.
[0154] In the embodiment of the present application, multiple second access requests can be sent to the mirror database according to the data access information through the target program. After receiving each second access request, the mirror database can generate an access log of each second access request and send the access log of each second access request to the electronic device, so that the electronic device can obtain the access log of each second access request. Among them, the implementation method of step 209 is similar to the implementation method of step 203, which can be seen in the description of step 203 and will not be repeated here.
[0155] Step 210: When the target index information includes the second index information, determine usage information of the second index information according to the access log of each second access request.
[0156] In the embodiment of the present application, the access log of each second access request can be analyzed by specifying a command to obtain the usage information of the second index information, and the usage information of the second index information includes at least one item of information such as whether the second index information is used and the byte length of the second index information used. The implementation of step 210 is similar to the implementation of step 204, and the description of step 204 can be seen, which will not be repeated here.
[0157] Step 211: Create second index information in the target database based on that the usage information of the second index information meets the usage condition.
[0158] In an embodiment of the present application, if the usage information of the second index information includes information on whether the second index information is used, then when the second index information is used, the usage information of the second index information satisfies the usage condition. If the usage information of the second index information includes the byte length of the second index information used, then when the ratio between the byte length of the second index information used and the total byte length of the second index information is greater than a ratio threshold, the usage information of the second index information satisfies the usage condition. If the usage information of the second index information includes information on whether the second index information is used and the byte length of the second index information used, then when the second index information is used and the ratio between the byte length of the second index information used and the total byte length of the second index information is greater than a ratio threshold, the usage information of the second index information satisfies the usage condition.
[0159] If the usage information of the second index information meets the usage condition, the second index information is created in the target database. If the usage information of the second index information does not meet the usage condition, the second index information in the mirror database is deleted in the manner of step 206, or the second index information in the mirror database is adjusted in the manner of steps 207 to 211 until the usage information of the adjusted second index information meets the usage condition, and the adjusted second index information is created in the target database.
[0160] By creating index information in the target database whose usage information meets the usage conditions, it is achieved to create effective index information in the target database and improve the data access efficiency of the target database.
[0161] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant regions. For example, the script files, commands, etc. involved in this application are all obtained with full authorization.
[0162] In the above method, first index information is created in a mirror database of a target database, multiple first access requests are sent to the mirror database to obtain access logs of each first access request, and usage information of the first index information is determined according to the access logs of each first access request, so that the first index information is tested in the mirror database to obtain usage information of the first index information, thereby avoiding increasing the load of the target database due to blindly adding the first index information in the target database and affecting the data access efficiency of the target database. Since the mirror database is obtained by mirroring the target database, the mirror database is similar to the target database, and the usage information of the first index information obtained by testing the first index information in the mirror database can reflect the usage of the first index information by the target database. When the usage information of the first index information meets the usage condition, the first index information is created in the target database, so that valid index information is added in the target database, so that the target database can improve data access efficiency based on the valid index information.
[0163] The above describes the method for creating index information in the embodiment of the present application from the perspective of method steps. The following is a systematic and comprehensive description. Figure 6 , Figure 6 This is a schematic diagram of a framework of a method for creating index information provided by an embodiment of the present application, and the schematic diagram shows four parts: a target database, a database backup system, a mirror database, and a target program. These four parts are introduced below.
[0164] Target database: a database used to process various business data.
[0165] Database backup system: It is used to back up and process each original file in the target database through physical backup to obtain each backup file. It uses physical backup and recovery to back up and restore each backup file to obtain a mirror database.
[0166] Mirror database: The target database is mirrored by the database backup system to obtain a mirror database of the target database. By creating the first index information in the mirror database and testing the first index information, the use of the first index information in the mirror database is evaluated, thereby determining whether the first index information is valid index information.
[0167] Target program: can be written in Go language. The query rate per second of sending target access requests to the target database and the ratio of the number of various target access requests can be obtained through the target program, and the first access request is sent to the mirror database according to the query rate per second and the ratio of the number of various target access requests. By simulating the load of the target database, it is helpful to accurately evaluate the use of the first index information in the mirror database and improve the test effect of the first index information.
[0168] Among them, the target database, database backup system and mirror database can be deployed on cloud devices, and the physical backup function and backup recovery function of the database backup system can be supported by the services provided by the cloud devices. Based on the above four parts, steps 1 to 8 as shown below can be performed (not shown in the figure).
[0169] Step 1: Physically back up each original file in the target database through the database backup system every day to obtain each backup file.
[0170] Step 2: Use the backup files of the current day or the previous day to perform backup and recovery through the database backup system to obtain a mirror database.
[0171] Step 3: Add index information to the mirror database.
[0172] Step 4: Communicate with the target database through the target program to obtain data access information of sending a target access request to the target database, where the data access information includes a query rate per second of the target access request and a ratio of the number of each type of target access request.
[0173] Step 5: Send a first access request to the mirror database according to the data access information through the target program, wherein the difference between the query rate per second of the first access request and the query rate per second of the target access request is less than a threshold, and the difference between the number ratio of each type of first access request and the number ratio of each type of target access request is less than another threshold, so as to simulate the load of the target database in the mirror database.
[0174] Step 6: Obtain access logs of each first access request, and determine usage information of the index information according to the access logs of each first access request.
[0175] Step 7: If the usage information of the index information meets the usage condition, create the index information in the target database.
[0176] Step 8: If the usage information of the index information does not meet the usage conditions, or the index information is created in the target database, the mirror database is released, that is, all data including the index information in the mirror database is cleared to reduce the occupation of computing resources, storage resources, etc.
[0177] The index information creation method provided in the embodiment of the present application can be applied in multiple fields, such as the instant messaging field. When an instant messaging application adds a new function, it may be necessary to add index information to the instant messaging database so that the instant messaging database can quickly implement the function based on the newly added index information.
[0178] For example, an instant messaging application adds a group chat name search function. In this case, index information about the group chat name can be added to the instant messaging database. When any user enters a group chat name and clicks search, the instant messaging database can quickly retrieve group chat information that matches the group chat name entered by the user based on the index information about the group chat name, and display the retrieved group chat information through the display interface of the terminal device.
[0179] See also Figure 7 , Figure 7 1 is a schematic diagram of a search interface provided by an embodiment of the present application. When a user enters "work group" and confirms the search, the instant messaging database quickly retrieves three group chat information matching the "work group" based on the index information of the group chat name, and displays the three group chat information through the display interface. Among them, a group chat information includes the group chat name "work group", the name of the group owner, the group members, and whether the user has joined the group chat.
[0180] See also Figure 8 , Figure 8This is another search interface diagram provided by an embodiment of the present application. When the user enters "XX game group" and confirms the search, the instant messaging database quickly retrieves 241 group chat information matching "XX game group" based on the index information of the group chat name, and displays 5 group chat information among the 241 group chat information through the display interface. Among them, one group chat information includes the group chat name "work group", the name of the group owner, the group members, and whether the user has joined the group chat.
[0181] It is understandable that the instant messaging function can be located in other applications besides the instant messaging application, for example, a game application can have an instant messaging function built in. By creating valid index information in a database corresponding to the application through the method of the embodiment of the present application, the stability of the application function can be ensured and the user experience can be improved.
[0182] Fig. 9 FIG. 1 is a schematic diagram of a structure of a device for creating index information provided in an embodiment of the present application. Fig. 9 As shown, the device comprises:
[0183] The mirror processing module 901 is used to perform mirror processing on the target database to obtain a mirror database;
[0184] A creation module 902, configured to create first index information in a mirror database;
[0185] The sending and obtaining module 903 is used to send multiple first access requests to the mirror database, and obtain access logs of each first access request, wherein the access log of any first access request is used to record that the mirror database queries the reference index information based on any first access request and accesses the data in the mirror database;
[0186] A determination module 904, configured to determine usage information of the first index information according to the access log of each first access request when the reference index information includes the first index information;
[0187] The creation module 902 is further configured to create the first index information in the target database based on the usage information of the first index information satisfying the usage condition.
[0188] In a possible implementation, a sending and obtaining module 903 is used to obtain data access information of a target database, where the data access information is used to describe the type and quantity of target access requests sent to the target database; according to the type and quantity of the target access requests, multiple first access requests are sent to the mirror database to obtain access logs of each first access request.
[0189] In a possible implementation, the mirror processing module 901 is used to perform backup processing on each original file included in the target database to obtain each backup file; and perform backup and recovery processing based on each backup file to obtain a mirror database.
[0190] In a possible implementation, the creation module 902 is used to obtain a creation script file, where the creation script file is used to define a creation function for creating the first index information in the mirror database; and the first index information is created in the mirror database by running the creation script file.
[0191] In a possible implementation manner, the usage information of the first index information includes a byte length used by the first index information;
[0192] A creation module 902 is used to calculate the ratio between the byte length used by the first index information and the total byte length of the first index information; based on the ratio being greater than a ratio threshold, the first index information is created in the target database, and the usage information of the first index information satisfies the usage condition including the ratio being greater than the ratio threshold.
[0193] In a possible implementation, the device further includes:
[0194] The deleting module is used to delete the first index information in the mirror database based on the usage information of the first index information not satisfying the usage condition.
[0195] In a possible implementation, the device further includes:
[0196] An acquisition module, configured to acquire an adjustment script file based on the usage information of the first index information not satisfying the usage condition, wherein the adjustment script file is used to define an adjustment function for adjusting the first index information in the mirror database;
[0197] An adjustment module, used to adjust the first index information in the mirror database by running an adjustment script file to obtain second index information;
[0198] The sending and obtaining module 903 is further used to send multiple second access requests to the mirror database, and obtain access logs of each second access request, wherein the access log of any second access request is used to record that the mirror database queries the target index information based on any second access request and accesses the data in the mirror database;
[0199] The determination module 904 is further configured to determine usage information of the second index information according to the access log of each second access request when the target index information includes the second index information;
[0200] The creation module 902 is further configured to create the second index information in the target database based on the usage information of the second index information satisfying the usage condition.
[0201] In the above device, first index information is created in the mirror database of the target database, multiple first access requests are sent to the mirror database to obtain access logs of each first access request, and usage information of the first index information is determined according to the access logs of each first access request, so that the first index information is tested in the mirror database to obtain usage information of the first index information, thereby avoiding increasing the load of the target database due to blindly adding the first index information in the target database and affecting the data access efficiency of the target database. Since the mirror database is obtained by mirroring the target database, the mirror database is similar to the target database, and the usage information of the first index information obtained by testing the first index information in the mirror database can reflect the usage of the first index information by the target database. When the usage information of the first index information meets the usage condition, the first index information is created in the target database, so that valid index information is added in the target database, so that the target database can improve data access efficiency based on the valid index information.
[0202] It should be understood that the above Fig. 9 When the device provided above realizes its functions, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0203] Fig.10 The structure block diagram of a terminal device 1000 provided by an exemplary embodiment of the present application is shown. The terminal device 1000 includes: a processor 1001 and a memory 1002 .
[0204] The processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0205] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one computer program, which is executed by the processor 1001 to implement the method for creating index information provided in the method embodiment of the present application.
[0206] In some embodiments, the terminal device 1000 may further optionally include: a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002 and the peripheral device interface 1003 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1003 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006, an audio circuit 1007 and a power supply 1008.
[0207] The peripheral device interface 1003 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0208] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1004 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0209] The display screen 1005 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to collect touch signals on the surface or above the surface of the display screen 1005. The touch signal can be input to the processor 1001 as a control signal for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1005 can be one, arranged on the front panel of the terminal device 1000; in other embodiments, the display screen 1005 can be at least two, respectively arranged on different surfaces of the terminal device 1000 or in a folding design; in other embodiments, the display screen 1005 can be a flexible display screen, arranged on a curved surface or a folding surface of the terminal device 1000. Even, the display screen 1005 can also be arranged as a non-rectangular irregular figure, that is, a special-shaped screen. The display screen 1005 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0210] The camera assembly 1006 is used to capture images or videos. Optionally, the camera assembly 1006 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1006 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0211] The audio circuit 1007 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 1001 for processing, or input them into the radio frequency circuit 1004 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal device 1000. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1007 may also include a headphone jack.
[0212] The power supply 1008 is used to power various components in the terminal device 1000. The power supply 1008 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1008 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery charged through a wired line, and a wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0213] In some embodiments, the terminal device 1000 further includes one or more sensors 1009 . The one or more sensors 1009 include, but are not limited to: an acceleration sensor 1011 , a gyroscope sensor 1012 , a pressure sensor 1013 , an optical sensor 1014 , and a proximity sensor 1015 .
[0214] The acceleration sensor 1011 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal device 1000. For example, the acceleration sensor 1011 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1001 can control the display screen 1005 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1011. The acceleration sensor 1011 can also be used to collect game or user motion data.
[0215] The gyro sensor 1012 can detect the body direction and rotation angle of the terminal device 1000, and the gyro sensor 1012 can cooperate with the acceleration sensor 1011 to collect the user's 3D actions on the terminal device 1000. The processor 1001 can implement the following functions based on the data collected by the gyro sensor 1012: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0216] The pressure sensor 1013 can be set on the side frame of the terminal device 1000 and / or the lower layer of the display screen 1005. When the pressure sensor 1013 is set on the side frame of the terminal device 1000, the user's holding signal of the terminal device 1000 can be detected, and the processor 1001 performs left and right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 1013. When the pressure sensor 1013 is set on the lower layer of the display screen 1005, the processor 1001 controls the operability controls on the UI interface according to the user's pressure operation on the display screen 1005. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0217] The optical sensor 1014 is used to collect the ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the display screen 1005 according to the ambient light intensity collected by the optical sensor 1014. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the display screen 1005 is reduced. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera assembly 1006 according to the ambient light intensity collected by the optical sensor 1014.
[0218] The proximity sensor 1015, also called a distance sensor, is usually arranged on the front panel of the terminal device 1000. The proximity sensor 1015 is used to collect the distance between the user and the front of the terminal device 1000. In one embodiment, when the proximity sensor 1015 detects that the distance between the user and the front of the terminal device 1000 is gradually decreasing, the processor 1001 controls the display screen 1005 to switch from the screen-on state to the screen-off state; when the proximity sensor 1015 detects that the distance between the user and the front of the terminal device 1000 is gradually increasing, the processor 1001 controls the display screen 1005 to switch from the screen-off state to the screen-on state.
[0219] Those skilled in the art will understand that Fig.10 The structure shown in the figure does not constitute a limitation on the terminal device 1000, and may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0220] Fig.11This is a schematic diagram of the structure of the server provided in the embodiment of the present application. The server 1100 may have relatively large differences due to different configurations or performances, and may include one or more processors 1101 and one or more memories 1102, wherein the one or more memories 1102 store at least one computer program, and the at least one computer program is loaded and executed by the one or more processors 1101 to implement the index information creation method provided in the above-mentioned various method embodiments. Exemplarily, the processor 1101 is a CPU. Of course, the server 1100 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server 1100 may also include other components for implementing device functions, which will not be described in detail here.
[0221] In an exemplary embodiment, a computer-readable storage medium is further provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor to enable an electronic device to implement any of the above-mentioned methods for creating index information.
[0222] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0223] In an exemplary embodiment, a computer program is further provided. The computer program is at least one, and the at least one computer program is loaded and executed by a processor to enable an electronic device to implement any of the above-mentioned methods for creating index information.
[0224] In an exemplary embodiment, a computer program product is further provided. The computer program product stores at least one computer program, and the at least one computer program is loaded and executed by a processor to enable an electronic device to implement any of the above-mentioned methods for creating index information.
[0225] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0226] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0227] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for creating index information, characterized in that: The method comprises: Mirror the target database to obtain a mirror database; Creating first index information in the mirror database; Sending multiple first access requests to the mirror database to obtain access logs of the first access requests, wherein the access log of any first access request is used to record that the mirror database queries reference index information based on any first access request to access the data in the mirror database; In a case where the reference index information includes the first index information, determining usage information of the first index information according to the access logs of the respective first access requests; Based on the usage information of the first index information satisfying a usage condition, the first index information is created in the target database.
2. The method according to claim 1, characterized in that The sending of multiple first access requests to the mirror database to obtain access logs of the respective first access requests includes: Acquire data access information of the target database, where the data access information is used to describe the type and quantity of target access requests sent to the target database; According to the type and quantity of the target access request, multiple first access requests are sent to the mirror database to obtain access logs of the respective first access requests.
3. The method according to claim 1, characterized in that The mirroring of the target database to obtain the mirror database includes: Backing up each original file included in the target database to obtain each backup file; Backup and recovery processing is performed based on the respective backup files to obtain the mirror database.
4. The method according to claim 1, characterized in that: The creating first index information in the mirror database includes: Obtain a creation script file, where the creation script file is used to define a creation function for creating the first index information in the mirror database; The first index information is created in the mirror database by running the creation script file.
5. The method according to claim 1, characterized in that The usage information of the first index information includes the byte length used by the first index information; The use information based on the first index information satisfies the use condition, and the first index information is created in the target database, including: Calculating a ratio between a used byte length of the first index information and a total byte length of the first index information; Based on the ratio being greater than a ratio threshold, the first index information is created in the target database, and usage information of the first index information satisfies the usage condition including that the ratio is greater than the ratio threshold.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Based on the usage information of the first index information not satisfying the usage condition, the first index information in the mirror database is deleted.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: acquiring an adjustment script file based on the usage information of the first index information not satisfying the usage condition, wherein the adjustment script file is used to define an adjustment function for adjusting the first index information in the mirror database; By running the adjustment script file, the first index information in the mirror database is adjusted to obtain second index information; Sending multiple second access requests to the mirror database to obtain access logs of the respective second access requests, wherein the access log of any second access request is used to record that the mirror database queries the target index information based on any second access request to access the data in the mirror database; In a case where the target index information includes the second index information, determining usage information of the second index information according to the access log of each second access request; Based on the usage information of the second index information satisfying the usage condition, the second index information is created in the target database.
8. A device for creating index information, characterized in that: The device comprises: A mirror processing module is used to perform mirror processing on the target database to obtain a mirror database; A creation module, used to create first index information in the mirror database; a sending and obtaining module, configured to send a plurality of first access requests to the mirror database, and obtain access logs of the respective first access requests, wherein the access log of any first access request is used to record that the mirror database queries reference index information based on any first access request, and accesses the data in the mirror database; a determination module, configured to determine usage information of the first index information according to the access logs of the respective first access requests when the reference index information includes the first index information; The creation module is further configured to create the first index information in the target database based on the usage information of the first index information satisfying a usage condition.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor so that the electronic device implements the index information creation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by the processor so that the electronic device implements the method for creating index information as described in any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product stores at least one computer program, and the at least one computer program is loaded and executed by a processor so that the electronic device implements the method for creating index information as described in any one of claims 1 to 7.