CN115391363A - Database index updating method, storage medium and computer equipment - Google Patents

Database index updating method, storage medium and computer equipment Download PDF

Info

Publication number
CN115391363A
CN115391363A CN202211034771.3A CN202211034771A CN115391363A CN 115391363 A CN115391363 A CN 115391363A CN 202211034771 A CN202211034771 A CN 202211034771A CN 115391363 A CN115391363 A CN 115391363A
Authority
CN
China
Prior art keywords
index
data
aggregation
updating
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211034771.3A
Other languages
Chinese (zh)
Inventor
范国腾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingbase Information Technologies Co Ltd
Original Assignee
Beijing Kingbase Information Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingbase Information Technologies Co Ltd filed Critical Beijing Kingbase Information Technologies Co Ltd
Priority to CN202211034771.3A priority Critical patent/CN115391363A/en
Publication of CN115391363A publication Critical patent/CN115391363A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2462Approximate or statistical queries

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a database index updating method, a storage medium and computer equipment. Wherein the method comprises the following steps: acquiring data operation on a database; judging whether a corresponding aggregation index is pre-established in a target data table of data operation; if so, after data modification is carried out on the target data table according to data operation, the node position of the modified data in the aggregation index is searched; and updating the nodes of the aggregation index according to data operation. According to the scheme of the invention, the aggregation index is updated in time along with the data updating, so that the statistical data provided by the aggregation index is more accurate and timely.

Description

Database index updating method, storage medium and computer equipment
Technical Field
The present invention relates to database technologies, and in particular, to a database index updating method, a storage medium, and a computer device.
Background
There are typically a large number of statistical query statements present in analytical database applications. The processing of these statements is time consuming and requires a significant amount of hardware resources. A number of aggregation operations are used in these statements to generate statistical information such as grouping, deduplication, summing, counting, and the like.
In order to improve the processing efficiency of the statistical queries, some solutions proposed in the existing database technologies, such as materialized views, column storage, and calculation of approximate values by using sampled statistical information, etc., but the technologies all have certain limitations. For example, column storage is inefficient in that all data for a column needs to be imported in order to obtain a column statistic. And the sampling statistics can only obtain approximate values, which is not accurate enough.
The materialized view cannot reflect data updating in real time, data change needs to be reflected through refreshing, and a large amount of resources are consumed by frequent refreshing. Considering that the data in the database is in a dynamic process, once the data is updated, the related statistical data will also change, which also brings great difficulty to the processing of the statistical query statement.
Disclosure of Invention
It is an object of the present invention to have the aggregate index updated accordingly as the corresponding data is operated on.
It is a further object of this invention to improve the efficiency of the update process of the aggregated index.
In particular, the invention provides a method for updating a database index, which comprises the following steps:
acquiring data operation on a database;
judging whether a target data table of the data operation is pre-established with a corresponding aggregation index;
if so, after data modification is carried out on the target data table according to data operation, the node position of the modified data in the aggregation index is searched;
and updating the nodes of the aggregation index according to data operation.
Optionally, the data operation includes an operation of inserting data, and the step of updating the node of the aggregated index for the operation of inserting data includes:
judging whether the key value of the inserted data exists in the node of the aggregation index or not;
if not, a new key value is allocated to the inserted data in the aggregation index.
Optionally, if it is determined that the key value of the inserted data already exists in the node of the aggregated index, obtaining a deduplication setting for the aggregated index;
if the deduplication value is set as non-deduplication, allocating space on a linked list of key values of the aggregation index to record the position of the inserted data;
if the unset is set to the deduplication effect, the nodes of the aggregation index are maintained unchanged.
Optionally, the data operation comprises an operation of deleting data; and for the operation of deleting data, the step of updating the node of the aggregation index comprises:
the record corresponding to the deleted data is deleted in the aggregation index.
Optionally, after the step of deleting the record corresponding to the deleted data in the aggregated index, the method further includes:
judging whether a linked list of the nodes of the deleted data in the aggregation index is empty or not;
and if so, deleting the key value and the node of the deleted data in the aggregation index.
Optionally, the step of determining whether the target data table of the data operation is pre-established with the corresponding aggregation index includes:
inquiring whether an aggregation index record of a target data table exists in a system table of a database;
if yes, judging that the target data table is pre-established with a corresponding aggregation index;
if not, the target data table is judged not to establish the corresponding aggregation index.
Optionally, the system table of the database also holds statistical formulas of the aggregation index.
Optionally, after the step of updating the node of the aggregated index according to the data operation, the method further includes:
carrying out statistical calculation on the modified target data table again according to a statistical formula to obtain updated statistical information;
and modifying the aggregation data of the aggregation index by using the updated statistical information.
According to another aspect of the present invention, there is also provided a machine-readable storage medium having stored thereon a machine-executable program which, when executed by a processor, implements the method of updating a database index of any of the above.
According to yet another aspect of the present invention, there is also provided a computer device comprising a memory, a processor and a machine-executable program stored on the memory and running on the processor, and the processor, when executing the machine-executable program, implements the database index updating method of any of the above.
The updating method of the database index of the invention, under the condition that the target data table of the data operation is pre-established with the corresponding aggregation index, after the data modification is carried out on the target data table according to the data operation, the node position of the modified data in the aggregation index is searched; and updating the nodes of the aggregation index according to the data operation. Therefore, the aggregation index is updated in time along with the data updating, and the statistical data provided by the aggregation index is more accurate and timely.
Furthermore, the updating method of the database index provided by the invention respectively updates the database index in a targeted manner aiming at the operations of data insertion, deletion, updating and the like, the updating process is efficient and timely, and the data can be conveniently and quickly provided during subsequent statistical query.
Furthermore, the updating process of the database index is carried out according to the setting of the aggregation index, so that the efficiency of the updating process is further improved. The index key value of the aggregation index can be selected whether to remove the duplicate according to needs.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings.
Drawings
Some specific embodiments of the invention will be described in detail hereinafter, by way of illustration and not limitation, with reference to the accompanying drawings. The same reference numbers in the drawings identify the same or similar elements or components. Those skilled in the art will appreciate that the drawings are not necessarily drawn to scale. In the drawings:
FIG. 1 is a diagram illustrating a data structure of an aggregate index for which a database index update method is provided, according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of data of a node in an aggregate index for which a database index update method according to an embodiment of the present invention is applied;
FIG. 3 is a diagram of a method for updating a database index according to one embodiment of the invention;
FIG. 4 is a flow chart illustrating the use of the aggregated index in the method for updating the database index according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a machine-readable storage medium according to one embodiment of the invention; and
FIG. 6 is a schematic diagram of a computer device according to one embodiment of the invention.
Detailed Description
The updating method of the database index of the embodiment is directed to a novel index, and the index is named as an aggregation index. The purpose of aggregating the index is to store the statistical information of the data in the form of the index, so that the problem that the processing consumes time and resources and the processing consumes a lot of resources because the statistical information is generated by using an aggregation operation when the statistical query is processed in the prior art is solved.
The aggregation index utilizes the orderliness of BTREE index or other index technology in the database to accelerate the retrieval of information, and guarantees the real-time performance of statistical information by means of the characteristic that the index is updated along with the updated data. The aggregated index can also ensure the visibility of data by using the index data update to be submitted when the transaction is submitted, and can even realize the acceleration of the access speed of the statistical information by using the partition of the index.
Fig. 1 is a schematic diagram of a data structure of an aggregated index for which an update method of a database index according to an embodiment of the present invention is applied, and fig. 2 is a schematic diagram of data of a node in the aggregated index for which the update method of the database index according to an embodiment of the present invention is applied.
Referring to Btree structure as an example in fig. 1, the index portion 110 of the aggregated index is constructed according to index key values, where 4, 32, 64, and the like are all example index key values, which may be data id, and a non-leaf node has a pointer of a next-layer node. The data portion 120 of the aggregate index stores the position of the data corresponding to the index key value, i.e., the pointer of the data.
The data portion 120 is provided with a statistical information value in addition to the data position, as shown in fig. 2, the aggregate index is subjected to deduplication processing, three data correspond to the same index key 44, and the statistical information value of the data is also stored.
The data structure of the aggregation index is improved on the basis of an index structure (such as a Btree structure) of a database, so that the data structure of the aggregation index has the structure of the existing index on one hand, and new characteristics are added on the other hand.
The aggregation index targeted by the method of the embodiment is added with a list field for storing statistical information in the data structure of the index. This statistical information is also recalculated each time the data is updated, based on updating the data pointers specified by the index.
The length and content of the statistics field are defined when creating the index. For example, if the statistical information for the id column is selected id, sum (val) from t group by id, every time data of id =1 is updated, the sum (val) value corresponding to id =1 is recalculated and then updated into the index file.
The data stored in the aggregate index may be selected to be a value after deduplication by setting, that is, in the aggregate index, each data line may have an index node, or all data lines with the same index key value may share an index node.
For the aggregation operation to be saved being a grouping or deduplication operation, only the data from which the duplicate value is removed may be retained in the aggregation index. For example, under the condition that the values of the id columns inserted into two rows of data in the table (id int) are both 1, only one key value may be reserved in the aggregation index, the pointer pointing to the data corresponding to the key value is an array, and the pointers pointing to the two rows of data are reserved in the array. The data equivalent to the original BTREE is saved in the form of two indexes: (key =1,value = (1)), (key =1,value = (1)). The data is stored in the aggregate index in the form of (key =1, value = ((1), (1)), aggval = ()). Where aggval = () the value in parentheses is the statistical information value that needs to be calculated. In this way, the time for the grouping and deduplication operations can be saved during data query.
As can be seen from the above description, the aggregation index further increases the position of the corresponding data (generally, the data row position corresponding to the index key value) and the statistical information value on the basis of the index data structure. I.e. two linked lists are newly added: and storing the linked list of all data row positions corresponding to the index key value and the linked list of all statistical values corresponding to the index key value.
The generation process of the aggregation index for which the update method of the database index is directed in the embodiment includes: acquiring a creation statement of a database index; performing semantic analysis on the created sentences to obtain indexed relations and statistical formulas; creating an aggregation index; counting the indexed relation according to a statistical formula to obtain statistical information; and saving the statistical information as aggregation data in an aggregation index.
Where the create statement may specify the index type of the index and the index data structure (e.g., btree or hash structure). An alternative syntax for creating a statement is:
CREATE[UNIQUE]INDEX[CONCURRENTLY]name ON table[USING method]
wherein CREATE is a CREATE command; UNIQUE indicates that each index key value of the index corresponds to a UNIQUE data record, and is an optional setting item; [ CONCURRENTLY ] is an optional setting item indicating that DML (delete, modify, insert) operations are not blocked during the creation of the index; [ USING method ] is an index type. The type of the generated aggregation index of this embodiment may be defined as AGGREGATE.
For example for create statement 1: CREATE INDEX idx1 ON t using AGGREGEGEGATE (select id, max (score) from t group by id). The function is to establish an aggregation index on the id column of the table t, and the max (score) value corresponding to the id is stored in the aggregation index.
Another example is for create statement 2: CREATE INDEX idx1 ON t using AGGREGGREGATE (select count, provide, sum (num), max (score) from t group by count, provide). The method has the function of establishing an aggregation index on a county and a provice in a table t, and saving sum (num) and max (score) values corresponding to the county and the provice in the aggregation index.
The indexed relation obtained by creating the statement through semantic analysis may be a single table of the database, or a sub-query in which the database is associated with multiple tables, that is, the aggregate index may be created on the single table of the database, or on one sub-query in which multiple tables are associated. This is also an important difference from existing indexes.
For example, for the above creation statement 1, the indexed relationship is the id column of table t, and the statistical formula (statistical function) is max (score); for the above-mentioned creation statement 2, the indexed relationship is the counter and province columns of table t, and the statistical formula (statistical function) has two values: sum (num) and max (score).
When the database parser analyzes syntax and semantics of the creating statement, if the index type is determined to be aggregate, an aggregate index creating flow is called, and creation of an aggregate index is started. For example, a statement of CREATE INDEX idx1 ON t using AGGREGATE (select id, max (score) from t group by id) is obtained ON an id column of a table t during parsing, an aggregation (AGGREGATE) INDEX is created, and aggregation information stored in a key value of the INDEX is max (score).
The step of creating an aggregation index may comprise: creating an index data table, wherein the index data table can adopt an ordered index structure such as a BTree data structure; and recording the corresponding relation between the statistical formula and the indexed data table and the indexed relation in a system table of the database. That is to say, in the process of creating the aggregated index, a data table t _ index is created first, then the corresponding relationship between the data table t (indexed relationship) and the index data table t _ index is recorded in the database system table, and other information of the index, such as type aggregate, corresponding key value id, corresponding statistical information calculation formula, etc., is also recorded in the system table.
The step of recording the statistical formula in the system table of the database may include: saving the statistical formula in the form of a created statement; or compiling the statistical formula to obtain an executable code corresponding to the statistical formula, and storing the executable code corresponding to the statistical formula. That is, when the statistical formula is saved, the SQL form of the calculation formula, such as max (score), sum (num), etc., may be saved, and the statistical formula may also be compiled into executable code by some compiling techniques (such as JIT, etc.) to speed up the compiling when modifying the index.
Whether the statistical formula defines a corresponding conversion rule can be judged before the step of recording the statistical formula in a system table of the database; if yes, converting the statistics according to the corresponding conversion rule; and the step of recording the statistical formula in the system table of the database includes: and recording the converted statistical formula in a system table of the database.
The conversion requirements for different statistical formulas are different. Some statistical formulas do not need to be converted, and some statistical formulas need to be converted according to a defined rule, so that the problem that the whole table needs to be scanned again for recalculation each time data is updated is avoided. For example, for creating statement 1, when max (score) is counted, max (score) is only saved, so that when the value of the data inserted into the data table t is larger than the current value, the update is needed, and when the deleted value is the maximum value, the statistic information of the key value needs to be counted again. Also for example, if it is statistically calculated as average avg (score), information of sum (score) and count aggregation function needs to be stored because average avg = total/number = sum/count.
Considering that the value of the statistics is a collection of some integer or floating point numbers, the length and footprint of the list of statistics in defining the aggregation index may already be determined. Then the step of creating an index data table may further include, after the step of creating an index data table: determining the data length of the statistical information; and allocating space for the index data table according to the data length.
For example, the constraint conditions for defining the index are select id, sum (val), max (score) from t group by id. If val is int type and score is float type, then for the aggregate index listed as id, the extra space size to be allocated to each key value should be sizeof (int) + sizeof (float), i.e. the size of int type and the size of float type.
The statistical process of counting the indexed relationship according to the statistical formula may be performed after reading the corresponding column of the indexed relationship (data table t) according to the statistical formula.
The statistical information is stored as aggregated data in the aggregated index, that is, stored in a linked list corresponding to the key value of the aggregated index and used for storing the statistical information, and the stored statistical information is referred to as aggregated data of the aggregated index.
According to the method, after the creation sentences of the database index are obtained, the aggregation index is created, the aggregation index is used for counting in advance and storing the results of subsequent common statistical queries, and the data can be conveniently and quickly provided during the subsequent statistical queries. On one hand, the processing efficiency of statistical query is improved by means of the orderliness of indexes; on the other hand, the aggregation index is updated correspondingly along with the change of the data, and the real-time performance of the data is guaranteed. The aggregated data of the aggregated index is obtained by counting all relevant data of the indexed relation (which can be a single table or a result table of sub-query), so that the accuracy of the statistical data is ensured.
The statistical information is stored in a data structure of the aggregation index. That is, for each index key, additional space is allocated in the data structure of the aggregate index to hold the statistics.
The aggregation index has the following characteristics: the index key values are not repeated, the aggregation index contains flexibly defined statistical information, the index is a sorting index, and the data are updated in real time when changed.
Alternatively, the statistical information may be saved in another file to form a new data file. In the index file, only the position of the corresponding statistical information in the file is saved. Assume that the key value a of an index file corresponds to data at the position B in the data file. The traditional index file stores the corresponding relation (A- > B) between A and B. The method of this embodiment may add a statistics file C. The aggregate index file stores (A- > (B, C)). Wherein a change in data file B causes a modification of index file a and also a modification of statistics file C. Except for the above trigger condition, the statistical file C is not actively updated.
FIG. 3 is a diagram of a database index update method according to one embodiment of the invention, which may generally include:
step S302, acquiring data operation on a database;
step S304, judging whether a target data table of the data operation is pre-established with a corresponding aggregation index;
step S306, if yes, after data modification is carried out on the target data table according to data operation, the node position of the modified data in the aggregation index is searched;
and step S308, updating the nodes of the aggregation index according to the data operation.
In the case where a corresponding aggregation index is not established in advance, the data operation of the database may be directly performed. The method can lead the aggregation index to be updated in time along with the data updating, thereby leading the statistical data provided by the aggregation index to be more accurate and timely.
The step of determining whether the target data table of the data operation is pre-established with the corresponding aggregation index may include: inquiring whether an aggregation index record of a target data table exists in a system table of a database; if yes, judging that the target data table is pre-established with a corresponding aggregation index; if not, judging that the corresponding aggregation index is not established in the target data table.
The data operation comprises the following steps: the operations of inserting data and deleting data, that is, when a data table associated with the aggregation index is subjected to a DML (INSERT, UPDATE, DELETE) operation, UPDATE of the aggregation index is triggered at the same time.
For the aggregate index of the BTREE structure, firstly, the query of index key values is carried out according to the BTREE index mode, and then the operation of updating the index is carried out.
For the operation of inserting data, the step of updating the node of the aggregation index comprises the following steps: judging whether the key value of the inserted data exists in the node of the aggregation index or not; if not, a new key value is allocated to the inserted data in the aggregation index. If the key value of the inserted data is judged to exist in the node of the aggregation index, the de-duplication setting of the aggregation index is obtained; if the de-reset is not de-reset, distributing space on a linked list of key values of the aggregation index to record the position of the inserted data; if the unset is set to the deduplication effect, the nodes of the aggregation index are maintained unchanged. Through the above process, the method of this embodiment may efficiently update the aggregation index according to the insertion data.
For delete data operations, the step of updating the nodes of the aggregated index comprises: the record corresponding to the deleted data is deleted in the aggregation index. The method further comprises the following steps after the step of deleting the record corresponding to the deleted data in the aggregation index: judging whether a linked list of the nodes of the deleted data in the aggregation index is empty or not; and if so, deleting the key value and the node of the deleted data in the aggregation index. Through the above flow, the method of this embodiment can efficiently update the aggregation index according to the deletion data.
The step of updating the nodes of the aggregation index according to the data operation may further include: carrying out statistical calculation on the modified target data table again according to a statistical formula to obtain updated statistical information; and modifying the aggregation data of the aggregation index by using the updated statistical information.
When modifying the aggregated data, all the statistical formulas defined on the aggregated index are first read from the database system table. Then, traversing the set of the statistical formula, and respectively carrying out statistical calculation on each value. During the statistical calculation, whether the statistical data needs to be recalculated or not is judged according to different statistical formulas. For some specific statistical formulas, such as max (maximum), min (minimum), count, etc., only the data value of the current line and the stored original aggregated data need to be operated. For other statistical formulas, all data rows corresponding to the index key value can be traversed, all data corresponding to the index value are sequentially taken, and the aggregated data is recalculated.
In the database mechanism, when data is updated, the index information is also updated. When the index information is updated, the statistical information in the index information is also updated.
For example: for the aggregation index: CREATE INDEX idx1 ON t using AGGREGEGEGATE (select id, max (score) from t group by id). When data operation of update t set score =100where id =1and val & lt 10 is performed, the update operation of the aggregation index at this time is: finding all data lines satisfying id =1 by an id =1 index; judging that val is less than 10 for each row of records, and executing data updating for the records meeting the conditions; record calculate max (score) per line; the final max (score) result is updated into the aggregated data of the aggregation index.
Fig. 4 is a schematic flow chart illustrating the usage of the aggregated index in the method for updating the database index according to an embodiment of the present invention. The using process comprises the following steps:
step S402, obtaining and analyzing statistical query;
step S404, judging whether the column of the statistical query has an aggregation index;
step S406, the database optimizer directly makes an execution plan
Step S410, generating an execution plan by utilizing the aggregation index;
step S412, searching on the aggregation index;
in step S414, the search result is calculated twice.
When the statistical query is executed by using the aggregation index, the SQL statement is subjected to three stages of analysis, optimization and execution, and finally a query result is returned. Step S602 is an analysis process, and the optimizer completes step S404, step S410, and the executor completes step S412 and step S414.
In the optimizer stage, it is determined that if some of the queries of the statistical queries satisfy the query conditions of the aggregate index, an execution plan of the aggregate index is generated for the sub-queries.
For example for a query statement: select from a, (select id, sum (score) from b group by id) xwhere x.id = a.id.
The prior art plans to execute the query statement as follows:
NestLoop Join(a.id=b.id)
SeqScan on a
HashAggregate(b.id)
SeqScan on b
that is, in the prior art implementation plan, one scan and aggregate statistical calculation is performed for each record in table a and for table b. This lookup operation can be very time consuming when the data of table b is very large.
When the aggregation index implemented by this embodiment is applied, a create statement is used: CREATE INDEX idx1 ON b using AGGREGEGEGEGEGGATE (select id, sum (score) from b group by id) CREATEs an aggregation INDEX.
When the optimizer generates an execution plan by using the aggregation index, it is determined that the aggregation index exists in the column id in the table b, and further, an operation of querying all aggregation queries exists in aggregation data formed in advance by the aggregation index, so that a query plan based on the aggregation index is generated for the table b. The execution plan may be:
NestLoop Join(a.id=b.id)
SeqScan on a
AggIndexScan on b(b.id)
i.e. one index scan is performed for each record of table a and for table b. And because the result of the statistical query is stored in the aggregated data of the aggregated index, the result of the aggregated data can be directly returned.
It can be seen from the above description that, by applying the method of this embodiment, the processing efficiency of the aggregated query can be greatly improved.
The embodiment also provides a machine-readable storage medium and a computer device. Fig. 5 is a schematic diagram of a machine-readable storage medium 50 according to one embodiment of the invention, and fig. 6 is a schematic diagram of a computer device 60 according to one embodiment of the invention.
The machine-readable storage medium 50 has stored thereon the machine-executable program 51, and when the machine-executable program 51 is executed by the processor 610, the method for updating the database index according to any of the embodiments described above is implemented.
The computer device 60 may include a memory 620, a processor 610, and a machine-executable program 51 stored on the memory 620 and running on the processor 610, and the updating method of the database index of any of the above embodiments is implemented when the processor 610 executes the machine-executable program 51.
It should be noted that the logic and/or steps represented in the flowcharts or otherwise described herein, such as an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any machine-readable storage medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
For the purposes of this description, a machine-readable storage medium 50 can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the machine-readable storage medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the machine-readable storage medium 50 may even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted, or otherwise processed in a suitable manner, if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system.
The computer device 60 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smartphone. In some examples, computer device 60 may be a cloud computing node. Computer device 60 may be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. Computer device 60 may be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.
Computer device 60 may include a processor 610 adapted to execute stored instructions, a memory 620 that provides temporary storage for the operation of the instructions during operation. Processor 610 may be a single core processor, a multi-core processor, a computing cluster, or any number of other configurations. Memory 620 may include Random Access Memory (RAM), read only memory, flash memory, or any other suitable storage system.
The processor 610 may be connected via a system interconnect (e.g., PCI-Express, etc.) to an I/O interface (input/output interface) suitable for connecting the computer device 60 to one or more I/O devices (input/output devices). The I/O devices may include, for example, a keyboard and a pointing device, wherein the pointing device may include a touchpad or a touchscreen, among others. The I/O devices may be built-in components of the computing device 60 or may be devices that are externally connected to the computing device.
The processor 610 may also be linked through a system interconnect to a display interface adapted to connect the computer device 60 to a display device. The display device may include a display screen as a built-in component of the computer device 60. The display device may also include a computer monitor, television, or projector, etc. externally connected to the computer device 60. In addition, a Network Interface Controller (NIC) may be adapted to connect computer device 60 to a network via a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as an internet small computer system interface, etc.) to transfer data. The network may be a cellular network, a radio network, a Wide Area Network (WAN)), a Local Area Network (LAN), the internet, or the like. The remote device may be connected to the computing device through a network.
The flowcharts provided by this embodiment are not intended to indicate that the operations of the method are to be performed in any particular order, or that all the operations of the method are included in each case. Further, the method may include additional operations. Additional variations on the above-described method are possible within the scope of the technical ideas provided by the method of this embodiment.
Thus, it should be appreciated by those skilled in the art that while a number of exemplary embodiments of the invention have been illustrated and described in detail herein, many other variations or modifications consistent with the principles of the invention may be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Accordingly, the scope of the invention should be understood and interpreted to cover all such other variations or modifications.

Claims (10)

1. A method for updating a database index comprises the following steps:
acquiring data operation on the database;
judging whether a corresponding aggregation index is pre-established in a target data table of the data operation;
if yes, after data modification is carried out on the target data table according to the data operation, the node position of the modified data in the aggregation index is searched;
and updating the nodes of the aggregation index according to the data operation.
2. The method for updating the database index according to claim 1, wherein
The data operation comprises an operation of inserting data, and the step of updating the node of the aggregation index for the operation of inserting data comprises:
judging whether the key value of the inserted data exists in the node of the aggregation index;
if not, a new key value is distributed to the inserted data in the aggregation index.
3. The method for updating the database index according to claim 2, wherein
If the key value of the inserted data is judged to exist in the node of the aggregation index, the de-duplication setting of the aggregation index is obtained;
if the deduplication value is set as no deduplication, allocating space on the linked list of the key values of the aggregation index to record the position of the inserted data;
if the unset is set to a deduplication effectiveness, the nodes of the aggregated index are maintained unchanged.
4. The method for updating the database index according to claim 1, wherein
The data operation comprises an operation of deleting data; and for the operation of deleting data, the step of updating the node of the aggregated index comprises:
deleting the record corresponding to the deleted data in the aggregation index.
5. The method for updating the database index according to claim 4, wherein the step of deleting the record corresponding to the deleted data in the aggregated index further comprises:
judging whether a linked list of the nodes of the deleted data in the aggregation index is empty or not;
and if so, deleting the key value and the node of the deleted data in the aggregation index.
6. The method for updating the database index according to claim 1, wherein the step of determining whether the target data table of the data operation is pre-established with the corresponding aggregation index comprises:
inquiring whether an aggregation index record of the target data table exists in a system table of the database;
if yes, judging that the target data table is pre-established with a corresponding aggregation index;
if not, judging that the corresponding aggregation index is not established in the target data table.
7. The method for updating a database index according to claim 6,
the system table of the database also stores the statistical formula of the aggregation index.
8. The method for updating the database index according to claim 7, wherein after the step of updating the nodes of the aggregated index according to the data operation, further comprising:
carrying out statistical calculation on the modified target data table again according to the statistical formula to obtain updated statistical information;
modifying the aggregated data of the aggregated index using the updated statistical information.
9. A machine readable storage medium having stored thereon a machine executable program which when executed by a processor implements a method of updating a database index according to any of claims 1 to 8.
10. A computer device comprising a memory, a processor and a machine-executable program stored on the memory and running on the processor, and the processor when executing the machine-executable program implements the method of updating a database index according to any of claims 1 to 8.
CN202211034771.3A 2022-08-26 2022-08-26 Database index updating method, storage medium and computer equipment Pending CN115391363A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211034771.3A CN115391363A (en) 2022-08-26 2022-08-26 Database index updating method, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211034771.3A CN115391363A (en) 2022-08-26 2022-08-26 Database index updating method, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN115391363A true CN115391363A (en) 2022-11-25

Family

ID=84122602

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211034771.3A Pending CN115391363A (en) 2022-08-26 2022-08-26 Database index updating method, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN115391363A (en)

Similar Documents

Publication Publication Date Title
US10606834B2 (en) Methods and apparatus of shared expression evaluation across RDBMS and storage layer
US8332389B2 (en) Join order for a database query
US6850925B2 (en) Query optimization by sub-plan memoization
US11663213B2 (en) Distinct value estimation for query planning
US8396852B2 (en) Evaluating execution plan changes after a wakeup threshold time
EP2605158B1 (en) Mixed join of row and column database tables in native orientation
US8924373B2 (en) Query plans with parameter markers in place of object identifiers
US6681218B1 (en) System for managing RDBM fragmentations
US9141666B2 (en) Incremental maintenance of range-partitioned statistics for query optimization
US10783142B2 (en) Efficient data retrieval in staged use of in-memory cursor duration temporary tables
US9218394B2 (en) Reading rows from memory prior to reading rows from secondary storage
CN104765731A (en) Database query optimization method and equipment
EP3365803A1 (en) Parallel execution of queries with a recursive clause
US20230315727A1 (en) Cost-based query optimization for untyped fields in database systems
US20210357373A1 (en) Efficient indexing for querying arrays in databases
CN111078705A (en) Spark platform based data index establishing method and data query method
CN115374121A (en) Database index generation method, machine-readable storage medium and computer equipment
CN115391346A (en) Database aggregation index generation method, storage medium and computer equipment
CN115391424A (en) Database query processing method, storage medium and computer equipment
US8832157B1 (en) System, method, and computer-readable medium that facilitates efficient processing of distinct counts on several columns in a parallel processing system
CN110321388B (en) Quick sequencing query method and system based on Greenplus
CN115757479A (en) Database query optimization method, machine-readable storage medium and computer device
CN115391363A (en) Database index updating method, storage medium and computer equipment
CN115470220A (en) Database index updating method, storage medium and computer equipment
CN112818010B (en) Database query method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination