Index table creation and data query
By creating index tables in data tables and combining row and column storage, the problem of difficulty in implementing efficient OLAP and OLTP queries at the same time in the existing technology is solved, and the database performance is comprehensively improved and HTAP application support is achieved.
Patent Information
- Application Number
- PCT/CN2024/128191
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-11-20
- Filing Date
- 2024-10-29
- Publication Date
- 2025-05-30
AI Technical Summary
The prior art is difficult to implement efficient query of online analysis processing (OLAP) and online transaction processing (OLTP) on the same data table at the same time, resulting in insufficient performance of the database under mixed business requirements.
By creating an index table in a data table, the index table includes index columns and redundant columns, which are stored in rows and redundant columns, which are used to speed up the data query process.
It achieves the same improvement of the OLAP and OLTP performance of the database, supports hybrid transaction/analysis processing (HTAP) application scenarios, and improves the efficiency of data query.
Smart Images

Figure CN2024128191_30052025_PF_FP_ABST
Abstract
Description
Index table creation and data query Technical Field
[0001] One or more embodiments of the present specification relate to the field of database technology, and in particular, to an index table creation method, a data query method, and a device. Background Art
[0002] In data processing systems, as the amount of data increases significantly, the same data table may simultaneously meet the business needs of Online Analytical Processing (OLAP) and Online Transaction Processing (OLTP).
[0003] Because OLAP and OLTP have distinct characteristics, it's difficult for related technologies to achieve both good OLAP and OLTP performance in a data table. Specifically, OLAP typically queries a single column or columns of data in a table, while OLTP typically queries a single row of data in a table. Therefore, related technologies struggle to achieve optimal query efficiency for both.
[0004] Summary of the Invention
[0005] In view of this, one or more embodiments of this specification provide an index table creation method, a data query method, and an apparatus.
[0006] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions.
[0007] According to a first aspect of one or more embodiments of the present specification, a method for creating an index table is proposed, comprising: determining in a data table an index column for creating an index and a redundant column associated with the index column; creating an index table, the index table comprising an index column and a redundant column, the index column being an index key of the index table, the data in the index column being stored in a row-wise manner, the data in the redundant column being stored in a column-wise manner, and the redundant columns in the index table being used to accelerate the data query process for the data table.
[0008] According to a second aspect of one or more embodiments of the present specification, a data query method is proposed, including: obtaining a data query instruction, the data query instruction being used to query target data that meets the query conditions in a target column of a data table; in a case where a redundant column of an index table includes at least part of the target column, querying a first target row that meets the query conditions in the target column included in the redundant column, and obtaining a first target row offset; wherein the index table includes an index column and a redundant column, the index column is an index key of the index table, and the data in the index column is stored in a row-wise storage manner; the data in the redundant column is stored in a column-wise storage manner; and based on the first target row offset, querying the target data that meets the query conditions.
[0009] According to the third aspect of one or more embodiments of the present specification, an index table creation device is proposed, including: a determination module for determining an index column for creating an index and a redundant column associated with the index column in a data table; a creation module for creating an index table, the index table including an index column and a redundant column, the index column being the index key of the index table, the data in the index column being stored in a row-wise storage manner, the data in the redundant column being stored in a column-wise storage manner, and the redundant columns in the index table being used to accelerate the data query process for the data table.
[0010] According to a fourth aspect of one or more embodiments of the present specification, a data query device is proposed, including: an acquisition module for acquiring a data query instruction, the data query instruction being used to query target data that meets the query conditions in a target column of a data table; a first query module for querying a first target row that meets the query conditions in the target column included in the redundant column when the redundant column of the index table includes at least part of the target column, and obtaining a first target row offset; wherein the index table includes an index column and a redundant column, the index column is an index key of the index table, and the data in the index column is stored in a row-wise storage manner; the data in the redundant column is stored in a column-wise storage manner; and a second query module for querying the target data that meets the query conditions based on the first target row offset.
[0011] According to the fifth aspect of one or more embodiments of this specification, an electronic device is proposed, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements the method of the first aspect and / or the method of the second aspect by running the executable instructions.
[0012] According to the sixth aspect of one or more embodiments of this specification, a computer-readable storage medium is proposed, on which computer instructions are stored. When the instructions are executed by a processor, the steps of the first aspect method and / or the steps of the second aspect method are implemented.
[0013] The method provided in this specification can create an index table that includes index columns and redundant columns. The data in the index columns is stored in a row-based format, while the data in the redundant columns is stored in a column-based format. This allows the index table provided in this specification to simultaneously improve the OLAP and OLTP performance of the database, enabling the database to support hybrid transaction / analytical processing (HTAP) application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] FIG1 is a flow chart of a method for creating an index table provided by an exemplary embodiment.
[0015] FIG2 is a schematic diagram of a row storage method provided by an exemplary embodiment.
[0016] FIG3 is a schematic diagram of a column storage method provided by an exemplary embodiment.
[0017] FIG4 is a flow chart of a data query method provided by an exemplary embodiment.
[0018] FIG5 is a schematic structural diagram of a device provided by an exemplary embodiment.
[0019] FIG6 is a schematic structural diagram of an index table creation device provided by an exemplary embodiment.
[0020] FIG7 is a schematic structural diagram of a data query device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0021] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments are not intended to represent all implementations consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of one or more embodiments of this specification, as detailed in the appended claims.
[0022] It should be noted that in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than those described in this specification. In addition, a single step described in this specification may be broken down into multiple steps for description in other embodiments, and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0023] In data processing systems, as data volumes grow significantly, the same data table may be used for both OLAP and online transaction processing (OLTP). OLAP and OLTP systems have different characteristics. Row-based storage in databases is more OLTP-friendly, while column-based storage is more OLAP-friendly.
[0024] In order to enable a data table to support both OLAP and OLTP, related technologies store the same data table twice, in row storage and column storage, which significantly increases storage costs.
[0025] In view of this, this specification provides a method for creating an index table, which can improve the OLAP performance and OLTP performance of a data table by creating an index table corresponding to the data table.
[0026] Specifically, this specification first provides an index table creation method that can determine, in a data table, an index column for creating an index and a redundant column associated with the index column. Subsequently, an index table is created that includes the index column and the redundant column. The index column is the index key of the index table, the data in the index column is stored in row format, and the data in the redundant column is stored in column format.
[0027] It's important to note that an index table is a special table in a database that stores index information. Index tables improve database retrieval efficiency by pre-sorting and organizing data, enabling the database system to locate and access required data more quickly. When executing a query, the database first looks up the index key value in the index table and then uses the index pointer to quickly locate the corresponding data row, without having to scan the entire table row by row.
[0028] The embodiments of this specification improve the structure of the index table so that the index table provided by the examples of this specification can simultaneously improve the OLAP performance and OLTP performance of the data table.
[0029] In addition, an embodiment of this specification also provides a data query method, including: obtaining a data query instruction, the data query instruction is used to query target data that meets the query conditions in the target column of the data table; when the redundant column of the index table includes at least part of the target column, querying the first target row that meets the query conditions in the target column included in the redundant column to obtain the first target row offset; based on the first target row offset, querying the target data that meets the query conditions. Among them, the index table includes an index column and a redundant column, the index column is the index key of the index table, the data in the index column is stored in row storage mode, and the data in the redundant column is stored in column storage mode. This data query method can call the index table created in this specification when performing data query, thereby improving query efficiency.
[0030] Next, exemplary embodiments of the present specification will be described in detail.
[0031] First, an embodiment of this specification provides a method for creating an index table, which can be executed by any electronic device.
[0032] FIG1 is a flow chart of a method for creating an index table provided by an exemplary embodiment. As shown in FIG1 , the method for creating an index table provided by an embodiment of this specification includes the following steps.
[0033] S101: Determine in a data table an index column for creating an index and redundant columns associated with the index column.
[0034] It should be noted that a data table can be any table in a database. For example, the index column and the redundant column can be different fields in the same data table or different fields in different data tables. In addition, the number of index columns and redundant columns can be one or more, which is not limited in the embodiments of this specification.
[0035] In some embodiments, an index column can be a frequently queried field in a data table. Since an index column is a field used to create an index, creating an index on the index column can improve the database's query speed for that index column. Specifically, an index column can be a field frequently used as a query condition during a query. Creating an index on this field can improve the database's efficiency in filtering data in the index column, for example, through methods such as binary search.
[0036] Accordingly, the redundant columns associated with the index column can be fields that are frequently queried together with the index column, or fields that are frequently queried in OLAP-type queries. For example, for a student performance table containing four fields: "Major", "Grade", "Name", and "Score", "Major" can be used as an index column to quickly filter the scores of students in each major. Since "Score" is usually used as a query condition together with "Major", for example, to query students with scores above 90 in a certain major, "Score" can be used as a redundant column. In addition, since "Score" may be called and queried separately, for example, to count the pass rate of all students. Using "Score" as a redundant column for columnar storage can speed up the above queries.
[0037] S102, create an index table, the index table includes index columns and redundant columns, the index columns are index keys of the index table, the data in the index columns are stored in row storage, and the data in the redundant columns are stored in column storage. The redundant columns in the index table are used to speed up the data query process for the data table.
[0038] It should be noted that since the index column is the index key of the index table, the rows of data in the index table will be sorted according to the index column. Redundant columns, however, do not participate in the sorting because they do not have index key constraints and can be considered regular fields in the table.
[0039] For example, there can be only one index column, reducing the resource overhead of sorting the index keys during index table creation and updates. Other frequently queried fields can be used as redundant columns. Because redundant columns are stored in a columnar format, they can also provide a certain degree of query acceleration when data in redundant columns needs to be queried separately.
[0040] It should be noted that row-based storage stores all values in the same data row together. When inserting or updating a data row, the data row can be written directly to the data block at once, which has certain advantages in scenarios with frequent writes.
[0041] Figure 2 is a schematic diagram of a row-based storage method provided by an exemplary embodiment. Figure 2 illustrates a row-based storage data storage structure through a data table containing four fields: "student number", "name", "gender" and "age".
[0042] As shown in Figure 2, each row of data in the table is written sequentially into data blocks, resulting in the final data storage structure of "1|Xiaoming|Male|10, 2|Xiaohong|Female|11, 3|Xiaogang|Male|11." When querying data, because row-based storage is stored in rows, even querying only one or a few columns requires reading the entire data stored on disk.
[0043] It should be noted that columnar storage stores all values of the same data column together. When a data row is inserted or updated, the values of each data column in the row are also stored in different locations.
[0044] Figure 3 is a schematic diagram of a column storage method provided by an exemplary embodiment. Similarly, Figure 3 shows a row-based storage data storage structure through a data table containing four fields: "student number", "name", "gender" and "age".
[0045] As shown in Figure 3, each column of data in the table is written sequentially into the data blocks, resulting in a final data storage structure of "1|2|3, Xiaoming|Xiaohong|Xiaogang, Male|Female|Male, 10|11|11." When querying data, since column-based storage is stored in columns, queries involving only one or more columns in the table require only reading the corresponding column data.
[0046] Therefore, by adding redundant columns to the index table and storing the redundant columns in a columnar storage manner, the index table can be used to accelerate the execution of OLAP requests in the database.
[0047] Specifically, since OLAP-type queries may need to access millions or even billions of data rows, and such queries often only care about a few data columns, by storing data in redundant columns in a columnar manner, OLAP-type queries can be accelerated through redundant columns.
[0048] For example, in an e-commerce sales statistics table, each data row corresponds to the sales information of a single product. Due to the wide variety of products, there may be a large number of data rows. In this case, if a user wishes to query the top 20 products with the highest sales in a particular year, this query is essentially only relevant to three data columns: "Time," "Product Name," and "Sales Volume." Other data columns in the e-commerce sales statistics table, such as "Product Link," "Product Description," and "Product Store," are irrelevant to this query.
[0049] To speed up this query, we can pre-set "time," "product name," and "sales volume" as redundant columns in the index table for columnar storage. When executing this query, the query can be completed by simply reading the corresponding columns for time, product name, and sales volume from the redundant columns in the index table. This significantly improves query efficiency in OLAP scenarios with large data volumes.
[0050] In some embodiments, there are multiple redundant columns, and these columns can be stored in a column-based format as column groups (CGs). This means that the values in multiple redundant columns are stored in the same data block. When the redundant columns used for a query belong to the same column group, data from multiple redundant columns can be read at once, reducing the number of data reads during the query and alleviating disk read pressure.
[0051] In some embodiments, the index table also includes the primary key in the data table, and the primary key and the index column are stored together in a row-based storage format. By adding the primary key of the data table to the index table, when the data query range includes a column that does not exist in the index table, after the index table is hit, the table query can be performed using the primary key. For example, the index column in the index table may be the same column as the primary key in the data table, but this embodiment of the present specification does not limit this.
[0052] Based on the solution provided in the embodiments of this specification, when the index table includes enough redundant columns, the situation where the columns to be queried do not exist in the index table can be reduced, thereby reducing the occurrence of table return queries and further improving query efficiency.
[0053] It is understood that in this specification, row-based data and column-based data are located in different data blocks. Since index columns are still stored independently in row-based storage and can still support queries such as binary search, the OLTP capabilities of the index table are not affected and the OLTP query process can still be accelerated.
[0054] In other words, the index table constructed by this specification can support HTAP acceleration and effectively improve database performance.
[0055] Based on the same inventive concept, the embodiments of this specification also provide a data query method, such as the following embodiment. Since the principles of the data query method embodiment are similar to those of the above-mentioned index table creation method embodiment, the implementation of the data query method embodiment can refer to the implementation of the above-mentioned index table creation method embodiment, and the repeated parts will not be repeated.
[0056] Figure 4 is a flow chart of a data query method provided by an exemplary embodiment, which can be executed by any electronic device. As shown in Figure 4, the data query method provided by the embodiment of this specification includes the following steps.
[0057] S401: Obtain a data query instruction, where the data query instruction is used to query target data that meets the query conditions in a target column of a data table.
[0058] It should be noted that the target column can be understood as the column in the data table used as the query condition. For example, a student score table contains four fields: "Major", "Grade", "Name", and "Score". If the data query instruction is to find the names of students with scores greater than 80, the target column is "Score".
[0059] For example, the number of target columns may be one or more, and the query conditions may be specified by the user according to actual needs, which is not limited in the embodiments of this specification.
[0060] S402: When the redundant columns of the index table include at least part of the target columns, search for a first target row that meets the query condition in the target columns included in the redundant columns to obtain an offset of the first target row.
[0061] The index table includes index columns and redundant columns. The index columns are index keys of the index table. The data in the index columns are stored in row format; the data in the redundant columns are stored in column format.
[0062] It should be noted that the structure and effects of the index table can be referred to the description of the previous embodiment. In the embodiment of this specification, since the redundant column includes at least a portion of the target column, during the execution of the data query instruction, the redundant column in the index table can be used to accelerate the query of the target column. It is understood that when the redundant column includes multiple target columns, it means that the index table includes multiple redundant columns, and different redundant columns correspond to different target columns in the multiple target columns.
[0063] It should be noted that the first target row offset is the row offset of the first target row. In an index table, although the values of each row of data are distributed across different columns, and the storage methods of different columns may vary, the row offsets of each column in each row of data are the same. Therefore, the row offsets can be used to determine the values of different columns in a row of data.
[0064] In some embodiments, when the redundant column includes multiple target columns, each target column included in the redundant column can be searched for candidate rows that meet the query criteria to obtain a set of row offsets for the candidate rows in each target column. The first target row offset can be obtained by calculating the intersection of the row offset sets corresponding to each target column in the redundant column.
[0065] Because data in redundant columns is stored in row-wise order, queries on each column only require reading the data for that column, allowing for faster query completion. By calculating the intersection of the row offset sets corresponding to each target column, we can obtain the row offsets of rows that meet the query criteria for each target column.
[0066] S403: Query target data that meets the query condition based on the first target row offset.
[0067] In some embodiments, still using the aforementioned student score table as an example, assume that the data query instruction is for the names of students with scores greater than 80, and the target column is "score." After determining the first target row offset for rows with scores greater than 80 using the redundant column, if the index column or redundant column in the index table includes student names, the student names corresponding to rows with scores greater than 80 can be directly determined using the first target row offset in the column in the index table that includes student names.
[0068] For example, the index table may also include the primary key in the data table, and the primary key and index column are stored together in row-wise storage. If there is no column containing student names in the index table, the primary key value corresponding to the row with a score greater than 80 can be determined using the first target row offset, and the primary key value can be mapped to the student name in the data table to complete the query.
[0069] In some embodiments, when the redundant column includes a portion of the target column and the index column includes another portion of the target column, the target column included in the index column can be filtered out based on the first target row offset to select the row indicated by the first target row offset. A second target row that meets the query criteria is then searched for in the filtered rows to obtain a second target row offset. Based on the second target row offset, target data that meets the query criteria can be found.
[0070] Exemplarily, the redundant column includes a portion of the target column, and the index column includes another portion of the target column. This can be understood as the redundant column combined with the index column encompassing all target columns, i.e., the index table encompasses all target columns. In this case, the method for querying target data that meets the query criteria using the second target row offset can be similar to the method for querying using the first target row offset described above, and this embodiment is not further described in this specification.
[0071] Exemplarily, the redundant column includes a portion of the target column, and the index column includes another portion of the target column. Alternatively, it can be understood that the redundant column combined with the index column cannot cover all of the target columns, meaning that the index table only includes a portion of the target columns. In this case, based on the second target row offset, the primary key value corresponding to the second target row offset can be determined in the primary key of the index table. Subsequently, based on the primary key value corresponding to the second target row offset, the data table is searched for target data that meets the query criteria.
[0072] In some embodiments, the redundant columns may only include part of the target column, while the index columns may not include the target column. This also means that the index table only includes part of the target column. Similarly, in this case, based on the aforementioned first target row offset, the primary key value corresponding to the first target row offset can be determined in the primary key of the index table. Subsequently, based on the primary key value corresponding to the first target row offset, the target data that meets the query criteria is searched in the data table.
[0073] That is, when the index table only includes some target columns, the index table can be used to speed up the query of target columns that can be covered in the index table, and the target columns not covered in the index table can be queried through the back table.
[0074] It can be seen that no matter what kind of query is performed, when the redundant columns include at least part of the target columns, the index table created by the embodiments of this specification can accelerate the query.
[0075] FIG5 is a schematic diagram of the structure of a device provided by an exemplary embodiment. Referring to FIG5 , at the hardware level, the device includes a processor 502, an internal bus 504, a network interface 506, a memory 508, and a non-volatile memory 510, and may also include hardware required for other functions. One or more embodiments of this specification can be implemented based on software, such as the processor 502 reading the corresponding computer program from the non-volatile memory 510 into the memory 508 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0076] Please refer to Figure 6, which provides an index table creation device 600 that can be applied to the device shown in Figure 5 to implement the technical solution of this specification. Exemplarily, the index table creation device 600 may include: a determination module 601, configured to determine, in a data table, an index column for creating an index and a redundant column associated with the index column; and a creation module 602, configured to create an index table, wherein the index table includes an index column and a redundant column, wherein the index column is an index key for the index table, the data in the index column is stored in a row-based storage manner, and the data in the redundant column is stored in a column-based storage manner. The redundant column in the index table is used to accelerate the data query process for the data table.
[0077] In some embodiments, the index table further includes the primary key in the data table, and the primary key and the index column are stored together in a row-wise manner.
[0078] Please refer to Figure 7, which provides a data query device 700 that can be applied to the device shown in Figure 5 to implement the technical solution of this specification. Exemplarily, the data query device 700 may include: an acquisition module 701, which is used to acquire a data query instruction, and the data query instruction is used to query the target data that meets the query conditions in the target column of the data table; a first query module 702, which is used to query the first target row that meets the query conditions in the target column included in the redundant column when the redundant column of the index table includes at least part of the target column, and obtain the first target row offset; wherein the index table includes an index column and a redundant column, the index column is the index key of the index table, and the data in the index column is stored in a row-wise storage manner; the data in the redundant column is stored in a column-wise storage manner; and a second query module 703, which is used to query the target data that meets the query conditions based on the first target row offset.
[0079] In some embodiments, the first query module 702 is used to, when the redundant column includes multiple target columns, query candidate rows that meet the query conditions in each target column included in the redundant column, and obtain a set of row offsets for the candidate rows in each target column; calculate the intersection of the row offset sets corresponding to each target column in the redundant column to obtain a first target row offset.
[0080] In some embodiments, the second query module 703 is used to, when the redundant column includes a portion of the target column and the index column includes another portion of the target column, filter out the row shown by the first target row offset from the target column included in the index column based on the first target row offset; query the second target row that meets the query conditions in the filtered rows to obtain the second target row offset; and query the target data that meets the query conditions based on the second target row offset.
[0081] In some embodiments, the index table also includes a primary key in the data table, and the primary key and the index column are stored together in row-wise storage. The second query module 703 is configured to, if the index table includes some target columns, determine the primary key value corresponding to the first target row offset in the primary key of the index table based on the first target row offset; and search the data table for target data that meets the query criteria based on the primary key value corresponding to the first target row offset.
[0082] In some embodiments, the index table also includes a primary key in the data table, and the primary key and the index column are stored together in row-wise storage. The second query module 703 is configured to, if the index table includes a partial target column, determine the primary key value corresponding to the second target row offset in the primary key of the index table based on the second target row offset; and based on the primary key value corresponding to the second target row offset, query the data table for target data that meets the query criteria.
[0083] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email transceiver, game console, tablet computer, wearable device, or any combination of these devices.
[0084] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0085] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0086] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0087] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0088] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0089] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "an," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0090] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when..." or "when..." or "in response to determining."
[0091] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of this specification shall be included in the scope of protection of one or more embodiments of this specification.
Claims
1. A method for creating an index table, comprising: Determine the index columns used to create the index and the redundant columns associated with the index columns in the data table; An index table is created, wherein the index table includes an index column and a redundant column. The index column is an index key of the index table. The data in the index column is stored in a row-based storage manner, and the data in the redundant column is stored in a column-based storage manner. The redundant column in the index table is used to accelerate the data query process for the data table.
2. According to the method of claim 1, the index table further includes a primary key in the data table, and the primary key and the index column are stored together in a row storage manner.
3. A data query method, comprising: Obtaining a data query instruction, wherein the data query instruction is used to query target data that meets the query condition in the target column of the data table; In the case where the redundant column of the index table includes at least part of the target column, a first target row that meets the query condition is searched in the target column included in the redundant column to obtain the first target row offset; wherein the index table includes an index column and a redundant column, the index column is an index key of the index table, and the data in the index column is stored in a row storage manner; the data in the redundant column is stored in a column storage manner; Based on the first target row offset, target data that meets the query condition is queried.
4. The method according to claim 3, wherein searching the target column included in the redundant column for a first target row that meets the query condition and obtaining the first target row offset comprises: In the case that the redundant column includes a plurality of target columns, querying candidate rows meeting the query condition in each target column included in the redundant column respectively, and obtaining a row offset set of the candidate rows in each target column; The intersection of the row offset sets corresponding to the target columns in the redundant columns is calculated to obtain a first target row offset.
5. The method according to claim 3, wherein querying target data that meets the query condition based on the first target row offset comprises: In a case where the redundant column includes a part of the target column and the index column includes another part of the target column, based on the first target row offset, the row indicated by the first target row offset is filtered out from the target column included in the index column; Searching for a second target row that meets the query condition in the filtered rows, and obtaining an offset of the second target row; Based on the second target row offset, target data that meets the query condition is queried.
6. The method according to claim 3 or 4, wherein the index table further comprises a primary key in the data table, and the primary key and the index column are stored together in a row storage manner; The querying of target data meeting a query condition based on the first target row offset includes: In a case where the index table includes a partial target column, based on the first target row offset, determining a primary key value corresponding to the first target row offset in a primary key of the index table; Based on the primary key value corresponding to the first target row offset, the data table is searched for target data that meets the query condition.
7. The method according to claim 5, wherein the index table further comprises a primary key in the data table, and the primary key and the index column are stored together in a row storage manner; The querying of target data meeting the query condition based on the second target row offset includes: In a case where the index table includes a partial target column, based on the second target row offset, determining a primary key value corresponding to the second target row offset in a primary key of the index table; Based on the primary key value corresponding to the second target row offset, the data table is searched for target data that meets the query condition.
8. An index table creation device, comprising: A determination module, used for determining, in a data table, an index column for creating an index and a redundant column associated with the index column; A creation module is used to create an index table, the index table includes an index column and a redundant column, the index column is the index key of the index table, the data in the index column is stored in a row storage manner, the data in the redundant column is stored in a column storage manner, and the redundant column in the index table is used to accelerate the data query process for the data table.
9. A data query device, comprising: An acquisition module, used for acquiring a data query instruction, wherein the data query instruction is used for searching a target column of a data table for target data that meets a query condition; A first query module is used for, when a redundant column of an index table includes at least part of a target column, querying a first target row that meets a query condition in the target column included in the redundant column to obtain a first target row offset; wherein the index table includes an index column and a redundant column, the index column is an index key of the index table, and the data in the index column is stored in a row-based storage manner; the data in the redundant column is stored in a column-based storage manner; The second query module is used to query target data that meets the query condition based on the first target row offset.
10. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to claim 1 or 2 and / or the method according to any one of claims 3 to 7 by running the executable instructions.
11. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to claim 1 or 2 and / or the steps of any one of the methods according to claims 3 to 7.
Citation Information
Patent Citations
Multidimensional interval querying method and system thereof
CN101866358A
Line and column hybrid storage method of database system
CN103440245A
DOT in-fragment secondary index method and DOT in-fragment secondary index system
CN104133867A
Dynamic data storage method and device
CN104516912A
Method for injecting time series data, method for querying time series data and database system
CN113868267A