Data storage method and device
By distinguishing indexed and non-indexed field area storage in the data table, the problems of complex database operations and low query efficiency in the prior art are solved, and simplified operations and efficient query are achieved.
Patent Information
- Application Number
- CN202210422902.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-04-21
AI Technical Summary
In the prior art, the data instantiated by the business model is stored in a wide table, and the fields stored in the same key value position are different in types, and the underlying database index cannot be used for sorting, resulting in complex database operations and low query efficiency. Especially when searching for multiple fields, self-association query is required, which increases complexity and processing time.
Store indexed fields and non-indexed fields in different areas of the same data table. By determining the business model and historical field information of the newly added fields, the storage location is optimized, which avoids synchronous modification of the indexed table, simplifies database operations, and improves data query efficiency.
It reduces the complexity of database operations and improves the execution efficiency of data queries, especially when searching for multiple fields, no self-association queries are required, which improves system performance.
Smart Images

Figure CN114840520B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a data storage method. Background Art
[0002] Currently, data after business model instantiation is stored in wide tables. However, fields in the same key value position have different actual data types for different business objects, and there is no way to sort them using the underlying database indexing capabilities.
[0003] In the prior art, corresponding index tables are added to corresponding fields to achieve the index effect on conventional data tables. However, when new records are added to the data table, similar modifications need to be made to the corresponding index tables. Moreover, when multiple fields need to be retrieved simultaneously, the corresponding index tables need to be used for self-association queries. This is not only complicated to implement, but also reduces processing efficiency as the number of query conditions increases.
[0004] Therefore, how to reduce the complexity of database operations and increase the execution efficiency of data queries is of great significance. Summary of the Invention
[0005] In view of this, embodiments of this specification provide a data storage method. One or more embodiments of this specification also relate to a data storage device, a data query method, a data query device, a computing device, a computer-readable storage medium, and a computer program to address technical deficiencies in the prior art.
[0006] According to a first aspect of an embodiment of this specification, a data storage method is provided, including:
[0007] Determine the business model corresponding to the newly added field based on the field information of the newly added field;
[0008] Acquire field information of a historical field in a target data table corresponding to the business model, wherein the target data table includes an index field area and a non-index field area;
[0009] In the case where it is determined that the newly added field is an index field, the storage location of the newly added field is determined in the index field area according to the field information of the historical field in the target data table.
[0010] According to a second aspect of the embodiments of this specification, there is provided a data storage device, including:
[0011] A model determination module is configured to determine a business model corresponding to the newly added field based on the field information of the newly added field;
[0012] an information acquisition module configured to acquire field information of a historical field in a target data table corresponding to the business model, wherein the target data table includes an index field area and a non-index field area;
[0013] The location determination module is configured to determine the storage location of the new field in the index field area according to the field information of the historical field in the target data table when the new field is determined to be an index field.
[0014] According to a third aspect of the embodiments of this specification, a data query method is provided, including:
[0015] Acquire field information of historical fields in a target data table according to a received data query request, wherein the data query request carries data information of the data to be queried;
[0016] Processing the data query request according to preset processing rules to obtain an initial data query statement;
[0017] If it is determined that a query engine exists and the initial data query statement meets the preset retrieval condition, generating a target data query statement corresponding to the query engine according to the initial data query request;
[0018] The query engine is called to perform data query in the target data table according to the target data query statement and the field information to obtain the target query result of the data to be queried.
[0019] According to a fourth aspect of the embodiments of this specification, a data query device is provided, including:
[0020] A field information acquisition module is configured to acquire field information of a historical field in a target data table according to a received data query request, wherein the data query request carries data information of the data to be queried;
[0021] A query statement acquisition module is configured to process the data query request according to a preset processing rule to obtain an initial data query statement;
[0022] A query statement generating module is configured to generate a target data query statement corresponding to the query engine according to the initial data query request when it is determined that a query engine exists and the initial data query statement meets a preset retrieval condition;
[0023] The query result acquisition module is configured to call the query engine to perform data query in the target data table according to the target data query statement and the field information, and obtain the target query result of the data to be queried.
[0024] According to a fifth aspect of the embodiments of this specification, there is provided a computing device, including:
[0025] memory and processor;
[0026] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above-mentioned data storage method or the steps of the above-mentioned data query method are implemented.
[0027] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions. When the instructions are executed by a processor, the steps of the above-mentioned data storage method or the steps of the above-mentioned data query method are implemented.
[0028] According to a seventh aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute steps of implementing the above-mentioned data storage method or steps of implementing the above-mentioned data query method.
[0029] In an embodiment of the present specification, a business model corresponding to a newly added field is determined based on the field information of the newly added field; field information of a historical field in a target data table corresponding to the business model is obtained, wherein the target data table includes an index field area and a non-index field area; when it is determined that the newly added field is an index field, a storage location of the newly added field is determined in the index field area based on the field information of the historical field in the target data table.
[0030] Specifically, this specification avoids the problem of needing to synchronously modify the corresponding index table when modifying non-index field data by storing index fields and non-index fields in the index field area and non-index field area corresponding to the same data table, thereby reducing the complexity of database operations; and the data storage method provided in this specification can improve the execution efficiency of data queries in subsequent data queries. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is a metadata-driven architecture model diagram provided by the embodiments of this specification;
[0032] Figure 2 This is another metadata-driven architecture model diagram provided in the embodiments of this specification;
[0033] Figure 3 This is a flow chart of a data storage method provided by an embodiment of this specification;
[0034] Figure 4This is a model structure diagram of a data storage method provided in an embodiment of this specification;
[0035] Figure 5 This is a wide table field distribution diagram in a data storage method provided by an embodiment of this specification;
[0036] Figure 6 This is a flowchart of a newly added field in a data storage method provided in an embodiment of this specification;
[0037] Figure 7 This is a flow chart of field changes in a data storage method provided in an embodiment of this specification;
[0038] Figure 8 This is a flow chart of a data query method provided by an embodiment of this specification;
[0039] Figure 9 This is a processing flow chart of a data query method provided in an embodiment of this specification;
[0040] Figure 10 This is a specific processing flow chart of a data query method provided by an embodiment of this specification;
[0041] Figure 11 This is a flow chart of a data storage method in a data table provided by an embodiment of this specification;
[0042] Figure 12 This is a schematic diagram of the structure of a data storage device provided in an embodiment of this specification;
[0043] Figure 13 This is a structural diagram of a data query device provided in an embodiment of this specification;
[0044] Figure 14 This is a structural block diagram of a computing device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0045] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0046] 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," "the," and "the" used in one or more embodiments of this specification and the appended claims are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed services.
[0047] It should be understood that although the terms first, second, 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, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0048] First, the terms involved in one or more embodiments of this specification are explained.
[0049] Metadata-driven architecture: A software design architecture that uses a reasonable abstract storage layer model to solve the problem of supporting dynamic expansion of business models while keeping the underlying storage model unchanged.
[0050] Business model: Also known as the enterprise model, it provides a framework to ensure that the enterprise's application systems are closely aligned with the enterprise's frequently improved business processes. It includes organizational view, data view, functional view, and control view.
[0051] Wide table storage model: an implementation of the underlying storage model of a metadata-driven architecture.
[0052] Objects: Definition and description information of the business model, with one record for each business model.
[0053] Fields (field information table): Model field definitions, including field type, wide table location, and whether an index is required.
[0054] Data: stores the data of each model. The key value of a specific business field is obtained from its position in the Fields table.
[0055] Clob: The large field in the data table is stored in clob, and the record ID in the clob table is stored in data.
[0056] Relationship: Model association relationship.
[0057] UniqueFields: stores the unique index field content of the business model.
[0058] Indexes: Each field in the index table is indexed. The contents of fields marked as indexed in Fields are stored in indexes.
[0059] The metadata model uses an independent layer of abstraction to store business-meaningful information within business objects as object metadata. This metadata describes the fields within business entity objects (Objects), while field metadata (Fields) defines and describes field attributes, including type, name, and encoding. This model abstraction separates business-meaningful metadata from the business object storage model. Applications access business object data through encapsulated metadata services without having to worry about which data table or field a particular field of a business object is stored in. This allows the fields of the business model to be dynamically expanded on demand without affecting the underlying storage model.
[0060] Currently, data after instantiation of the business model (Object, also known as the object table) is stored in the wide Data table. Because the Data wide table sets multiple fields to variable character types, it is very flexible for storing different types of data. However, the same key value position field has different data types corresponding to the stored content for different business objects, and the underlying database index capability cannot be used to sort them. In addition, strings are sorted according to ASCII, which may result in incorrect results, such as "12" < "2".
[0061] Based on this design of wide data table + index table, when there are multiple fields (for example: N), each time a new record is added to the data table, N records need to be added to the index table (modifications are similar). When multiple fields need to be retrieved at the same time, indexes are required to perform self-association queries, which is not only complex to implement but also slows down as the number of query conditions increases. If you want to improve, you need special optimization investment, auxiliary models, high-performance databases, experts, etc., which is very costly and discourages most companies from developing in practice. Therefore, in the existing technology, index tables (Indexes) and unique index tables (Unique-Fields) are added to achieve index effects on regular data tables.
[0062] See also Figure 1 , Figure 1 This is a metadata-driven architecture model diagram provided in an embodiment of this specification, which specifically includes the following contents.
[0063] The model includes an object table (Objects), a field information table (Fields), a data table (Data), a character large object table (Clobs), an index table (Indexes), a unique index field table (UniqueFields), and a relationship table (Relationships). The object table and the field information table are both composed of metadata corresponding to the data table. Among them, the object id, organization id, object name, field id, field name, data type, field number, index identifier, data id, name, key value 0 variable character type, key value 1 variable character type, key value 2 variable character type, key value 29 variable character type, key value 30 numeric type, key value 31 numeric type, key value 59 numeric type, key value 499 variable character type, key value, variable character type key value, numeric type key value, relationship id, target object id all represent different fields in the object table (Objects), field information table (Fields), data table (Data), character large object table (Clobs), index table (Indexes), unique index field table (UniqueFields), and relationship table (Relationships). The corresponding fields and structural relationships in the tables are as follows: Figure 1 shown.
[0064] In one implementation, using Figure 1 , which means that within the data table, the index table / unique index table has a data size ratio of 1:N. This means that each record in the index table corresponds to the value of a column in the data table that needs to be indexed. This approach has the advantage of a simple algorithm for assigning new model fields, which can be done sequentially. In principle, all fields in an object can be indexed. However, this approach requires index table self-join queries when searching multiple index fields. Furthermore, because the index table has N times the data size of the data table, specialized optimization and a high-performance database are required.
[0065] See also Figure 2 , Figure 2 This is another metadata-driven architecture model diagram provided in an embodiment of this specification, which specifically includes the following contents.
[0066] The model includes object table (Objects), field information table (Fields), data table (Data), character large object table (Clobs), index table (Indexes), unique index field table (UniqueFields), and relationship table (Relationships). The object table and field information table are composed of metadata corresponding to the data table. The corresponding fields and structural relationships in the table are as follows: Figure 2 As shown, see Figure 1The description of the fields in Figure 2 The fields contained in each table are described in detail.
[0067] One implementation approach involves horizontally expanding the columns of the index table, with a 1:1 ratio of data table to index table / unique index table data volume. This means the index table's field structure is similar to data, and the index table also provides x columns (x does not exceed the maximum number of database indexes, for example, 60 columns). Each column is pre-indexed. The record data for a business model is stored in data, while the contents of all indexed fields in the model are stored in the index table. This approach offers the advantage that searches involving multiple indexed fields can be performed simultaneously in the index table, eliminating the need for nested self-join queries. Furthermore, the index table's data volume is logically only 1 / N of the first approach (N being the number of indexed fields required for the specific business model). Furthermore, searches involving multiple indexed fields can utilize the database's indexMerge technology, which improves efficiency. However, this approach requires a reasonable number of indexed fields (relational database indexes have an upper limit, such as MySQL, with a limit of <= 64). Furthermore, changes to field types require the development of a supporting index rebuilding service, relying on specialized middleware. Furthermore, fuzzy searches on non-indexed fields or text can result in poor search efficiency.
[0068] To solve the above technical problems, a data storage method is provided in this specification. This specification also involves a data storage device, a data query method, a data query device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0069] See also Figure 3 , Figure 3 A flow chart of a data storage method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0070] Step 302: Determine the business model corresponding to the newly added field based on the field information of the newly added field.
[0071] The field information includes but is not limited to the field type, field source, business model information, etc. of the newly added field.
[0072] The newly added field can be understood as a newly added column in the table; for example, when the data storage method provided in this specification is applied to a scenario where a new order number is added, the newly added field can be "Order ID"; correspondingly, the field information can be the type of data that the column can store, for example, a numeric type, and the corresponding business model can be an order model.
[0073] Specifically, determining the business model corresponding to the newly added field according to the field information of the newly added field can be understood as: determining the business model corresponding to the newly added field according to the business model information in the field information of the newly added field.
[0074] See also Figure 4 , Figure 4 A model structure diagram of a data storage method provided according to an embodiment of this specification is shown.
[0075] The model includes object tables (Objects), field information tables (Fields), data tables (Data), character large object tables (Clobs), index tables (Indexes), unique index field tables (UniqueFields), and relationship tables (Relationships). The object tables and field information tables are composed of metadata, and the metadata corresponds to the data in the data tables. The corresponding fields and structural relationships in the tables are shown in the figure. Figure 1 The description of the fields in Figure 4 The fields contained in each table are described in detail.
[0076] Specifically, instead of creating an index field with key values 0 to 59, all indexes will be combined with the object ID. For example, the object ID and key value 0 form a unique index field, and the object ID and key value 59 form a common index field.
[0077] In addition, based on the fact that building a separate index table or unique index table will increase the complexity of operations and increase optimization costs, in order to optimize the above problems, this manual sets the index table or unique index table as a discarded model.
[0078] Step 304: Acquire field information of historical fields in the target data table corresponding to the business model, wherein the target data table includes an index field area and a non-index field area.
[0079] Continuing with the above example, the field information of the historical fields in the target data table corresponding to the business model can be understood as Figure 4 The loaded fields in the business model belong to other fields field information.
[0080] The field information of the historical field can be understood as the field information of the existing field in the target data table before the new field operation is performed, and the field information of the historical field can be empty.
[0081] The index field area can be understood as an area where the field type of the area field is an index field, which includes a unique index field area (first type index field area), a common index field area (second type index field area), etc.
[0082] Specifically, obtaining the field information of the historical fields in the target data table corresponding to the business model can be understood as: determining the target data table corresponding to the newly added field based on the business model corresponding to the newly added field, and then obtaining the field information of the existing fields in the target data table from the field information table corresponding to the business model.
[0083] See also Figure 5 , Figure 5 A wide table field distribution diagram in a data storage method provided according to an embodiment of this specification is shown.
[0084] In one implementation, the target data table may be a pre-built wide table, and the key values corresponding to the index area and the non-index area in the target data table may be pre-divided during construction. For example, the key value in the target data table is 500 (i.e. Figure 5 500 wide fields value0-value499), the corresponding index area is the key value 0-59 (i.e. Figure 5 60 fields in the index area), and its key values 0-29 use the numeric type, and provide 10 unique index fields (first type index fields), 40 common index fields (second type index fields), its key values 30-59 use the variable character type, provide 10 unique indexes (first type index fields), 20 common indexes (second type index fields), and key values 60-499 are used as common fields (non-index fields). The division of fields in the target data table can be set according to actual applications, and in subsequent use, fields can still be added if there are insufficient fields. This manual does not make any restrictions on this.
[0085] Based on the above Figure 4 and Figure 5 This manual abandons independent index tables, classifies columns of wide tables (i.e., target data tables), and creates indexes and unique indexes in advance. The total number of indexes does not exceed the limit of the database itself.
[0086] In addition, when obtaining field information, it is necessary to obtain the field information of the existing fields in the target data table from the field information table corresponding to the target data table. After adding the new field to the target data table, it is also necessary to record the field information of the new field in the field information table to facilitate subsequent information query. The specific implementation method is as follows:
[0087] The acquiring of field information of historical fields in the target data table corresponding to the business model includes:
[0088] Determine the field information table corresponding to the business model;
[0089] Acquire field information of historical fields in the target data table corresponding to the business model from the field information table;
[0090] Correspondingly, after determining the storage location of the newly added field in the index field area according to the field information of the historical field in the target data table, the method further includes:
[0091] The field information of the newly added field and the storage location of the newly added field are recorded in the field information table.
[0092] The storage location may be understood as the key value location where the newly added field may be added to the target data table.
[0093] Specifically, the corresponding field information table is determined according to the business model, and then the field information of each field in the target data table corresponding to the business model, the corresponding location information of each field, etc. are obtained from the field information table. After the storage location of the newly added field is determined, the determined storage location is recorded in the field information table, making it more convenient and quick to obtain the field information later.
[0094] Step 306: When it is determined that the newly added field is an index field, the storage location of the newly added field is determined in the index field area according to the field information of the historical field in the target data table.
[0095] Following the above example, when it is determined that the newly added field is an index field, the storage location of the newly added field is determined in the index field area according to the field information of the historical field in the target data table, which can be understood as Figure 4 When the newly added field needs to be retrieved, it is allocated in sequence from the free positions of the index fields in the data table.
[0096] The index field can be understood as a field that constructs an index constraint.
[0097] Specifically, when it is determined that the newly added field is an index field, determining the storage position of the newly added field in the index field area according to the field information of the historical field in the target data table can be understood as: determining whether the newly added field needs to be an index field according to the field information of the newly added field; when it is determined that the newly added field is an index field, determining the allocable position of the newly added field according to the field information of the historical field in the target data table; and determining the storage position of the newly added field in the index field area of the allocable position according to the allocable position.
[0098] Furthermore, before determining the storage location of the newly added field in the index field area of the allocatable position, it is necessary to determine whether there is a free index field area in the index field area. If there is a free index field area, the free index field area is allocated in order. If there is no free index field area, a corresponding index field area needs to be added for the newly added field to ensure that the newly added field can be stored in the corresponding position of the target data table. The specific implementation method is as follows.
[0099] The step of determining the storage location of the newly added field in the index field area according to the field information of the historical field in the target data table includes:
[0100] When it is determined that there is an idle storage location in the index field area based on the field information of the historical field in the target data table, the storage location of the newly added field is determined in the idle storage location; or
[0101] When it is determined based on the field information of the historical fields in the target data table that there is no free storage location in the index field area, a corresponding storage location is added in the index field area for the newly added field.
[0102] The free storage location may be understood as an area in the target data table other than the key value location of the historical field.
[0103] In one implementation, when it is determined that there are free storage locations in the index field area of the target data table based on the field information of the historical fields in the target data table, the first free storage location of the free storage location key value can be determined as the storage location of the newly added field, or any free storage location of the free storage location can be determined as the storage location of the newly added field. The determination of the storage location can be set according to the actual application and is not limited here.
[0104] In another implementation, when it is determined that there is no free storage location in the index field area of the target data table based on the field information of the historical field in the target data table, a free index field storage area can be created in the free storage location of the non-index area, and the free index field storage area can be determined as the storage location corresponding to the newly added field, or a new free index field storage area can be added between the index field area and the non-index area of the target data table as the storage location corresponding to the newly added field. The addition of the storage location can be set according to the actual application and is not limited here.
[0105] In addition, when determining the type of a newly added field, it is also necessary to determine whether the newly added field requires a unique constraint to ensure that there is no duplicate data in the field. The specific implementation method is as follows:
[0106] In the case where it is determined that the newly added field is an index field, determining a storage location of the newly added field in the index field area according to field information of the historical field in the target data table includes:
[0107] When it is determined that the newly added field is an index field and the newly added field is a first type index field, determining a storage location of the newly added field in the first type index field area of the index field area according to field information in the target data table; or
[0108] When it is determined that the newly added field is an index field and the newly added field is a second type index field, the storage location of the newly added field is determined in the second type index field area of the index field area according to the field information in the target data table.
[0109] Among them, the first type of index field can be understood as a unique index field, and correspondingly, the first type of index field area can be understood as an area composed of the field position where the first type of index field is located; the second type of index field can be understood as other index fields (i.e., ordinary index fields) other than the unique index field, and correspondingly, the second type of index field area can be understood as an area composed of the field position where the second type of index field is located.
[0110] Specifically, when it is determined that the newly added field is an index field, it is determined whether the newly added field requires a unique constraint. If it is determined that the newly added field requires a unique constraint, the newly added field is determined to be a unique index field (first type index field), and its allocatable index area is a unique index field area. Then, based on the field information of the historical fields in the target data table, the storage location of the newly added field is determined in the free field area of the unique index field area. If it is determined that the newly added field does not require a unique constraint, the newly added field is determined to be an ordinary index field (second type index field), and its allocatable index area is a ordinary index field area. Then, based on the field information of the historical fields in the target data table, the storage location of the newly added field is determined in the free field area of the ordinary index field area.
[0111] It should be noted that the method for determining the storage location of the newly added field and the method for adding the newly added field are the same as the method for determining the newly added field and the method for adding the newly added field in the above embodiment, and will not be described in detail here.
[0112] In addition, if the newly added field is determined to be a non-index field, the storage location of the newly added field is determined in the non-index field area, thereby ensuring that the data can be quickly stored in the target data table. The specific implementation method is as follows:
[0113] After obtaining the field information of the historical fields in the target data table corresponding to the business model, the method further includes:
[0114] In the case where it is determined that the newly added field is a non-index field, the storage location of the newly added field is determined in the non-index field area according to the field information in the target data table.
[0115] Specifically, when it is determined that the newly added field is a non-index field, determining the storage location of the newly added field in the non-index field area based on the field information of the historical field in the target data table can be understood as: judging whether the newly added field requires an index constraint. When it is determined that the newly added field does not require an index constraint, the newly added field is determined to be a non-index field, and its corresponding storage location is the non-index area. Then, based on the field information of the historical field in the target data, the storage location of the newly added field is determined in the non-index field area of the target data table.
[0116] In addition, before determining the storage location of the newly added field in the non-index field area of the allocable position, it is necessary to determine whether there is an idle non-index field area in the non-index field area. If there is an idle non-index field area, the idle non-index field area is allocated in order. If there is no idle non-index field area, it is necessary to add a corresponding non-index field area for the newly added field to ensure that the newly added field can be stored in the corresponding position of the target data table. The specific implementation method is as follows:
[0117] The step of determining the storage location of the newly added field in the non-index field area according to the field information in the target data table includes:
[0118] If it is determined based on the field information in the target data table that there is an idle storage location in the non-index field area, determining the storage location of the newly added field in the idle storage location; or
[0119] When it is determined based on the field information of the historical fields in the target data table that there is no free storage location in the non-index field area, a corresponding storage location is added in the non-index field area for the newly added field.
[0120] In one implementation, when it is determined that there are free storage locations in the non-index field area of the target data table based on the field information of the historical fields in the target data table, the first free storage location of the free storage location key value can be determined as the storage location of the newly added field, or any free storage location of the free storage location can be determined as the storage location of the newly added field. The determination of the storage location can be set according to the actual application and is not limited here.
[0121] In another implementation, when it is determined that there is no free storage location in the non-index field area of the target data table based on the field information of the historical field in the target data table, a free non-index field storage area can be created in the target data table, and the free non-index field storage area can be determined as the storage location corresponding to the newly added field, or a new free non-index field storage area can be added between the index field area and the non-index area of the target data table as the storage location corresponding to the newly added field. The addition of the storage location can be set according to the actual application and is not limited here.
[0122] The following takes the application of the data storage method provided in this specification in a scenario based on the metadata zone architecture wide table mode as an example to further explain the business model corresponding to the newly added fields based on the field information of the newly added fields.
[0123] See also Figure 6 , Figure 6 The following is a flowchart of a newly added field in a data storage method according to an embodiment of this specification. The specific steps are as follows:
[0124] Step 602: Add a new field, that is, respond to the field addition request.
[0125] The newly added field is used by the server to determine the type of data that can be stored in the newly added column in the table.
[0126] Step 604: Copy a business model object information object table, increase the version number by 1, and set the status to draft.
[0127] Specifically, a business model object information object table (ie, Object table) is copied, and the version number of the copied object table is increased by 1, and the status of the copied object table is set to draft. Subsequent operations are performed on the copied object table.
[0128] Step 606: Load the field information of the existing fields in the data table corresponding to the project model to which the field belongs.
[0129] Specifically, the field information of the historical fields in the data table (ie, the data table) corresponding to the business model is obtained.
[0130] Step 608: Whether the field needs to be searched, that is, whether the newly added field is an index field is determined.
[0131] If not, execute step 612; if so, execute step 610.
[0132] Step 610: Whether uniqueness is required, that is, determining whether the newly added field requires a uniqueness constraint.
[0133] If yes, execute step 614 ; if no, execute step 616 .
[0134] Step 612: Allocate in order from the free positions of the common fields of the data table.
[0135] Step 614: Allocate in order from the free positions of the unique index field in the data table.
[0136] Step 616: Allocate in order from the free positions of the index fields of the data table.
[0137] Step 618: Record the field and location information to the field information table.
[0138] Step 620: The object status is changed from draft to effective, and the status of the current effective version is changed to offline.
[0139] Specifically, the state of the copied object table is set from the draft state to the effective state, and the state of the object table in the current effective state is set to offline.
[0140] Step 622: End, that is, the field addition is completed.
[0141] The specific details of the above steps 602-622 can be found in the embodiment of the above data storage method, and will not be repeated here.
[0142] After determining the storage location of the newly added field, the field type may change. Therefore, it is necessary to change the field storage location and field type to reduce the complexity of database operations. The specific implementation method is as follows:
[0143] After determining the storage location of the newly added field in the index field area according to the field information in the target data table, the method further includes:
[0144] receiving a field change request, and determining, when it is determined that the field change request is to change the field to be changed into an index field, a target storage location of the field to be changed in the index field area, wherein the field to be changed is a non-index field;
[0145] If it is determined that the field to be changed already has existing data, copying the existing data from the current storage location of the field to be changed to the target storage location;
[0146] When it is determined that the stock data at the current storage location is consistent with the stock data at the target storage location, the stock data at the current storage location is deleted, and the field information of the field to be changed is updated in the field information table.
[0147] The field change request includes but is not limited to: the field type of the field to be changed, the target database corresponding to the field to be changed, etc.
[0148] Existing data can be understood as the data retained by the field to be changed before a certain time point.
[0149] The following uses the data storage method provided in this manual in a scenario based on the metadata region architecture wide table mode as an example to further explain the corresponding process of model field changes.
[0150] See also Figure 7 , Figure 7 A flowchart of field changes in a data storage method according to an embodiment of this specification is shown. The specific steps are as follows:
[0151] Step 702: Field change, ie, responding to a field change request.
[0152] Step 704: Copy a business model object information table, increase the version number by 1, and set the status to draft.
[0153] Specifically, a business model object information object table (ie, Object table) is copied, and the version number of the copied object table is increased by 1, and the status of the copied object table is set to draft. Subsequent operations are performed on the copied object table.
[0154] Step 706: Whether to change to an index, that is, determining whether the field to be changed needs to be changed to an index field.
[0155] If yes, execute step 708; if no, execute step 710.
[0156] Step 708: Load the field information of the existing fields in the data table corresponding to the business model to which the field belongs.
[0157] Step 710: Update field information to the field information table.
[0158] Step 712: Whether it becomes unique, that is, whether the field to be changed requires a unique index.
[0159] If not, execute step 716; if so, execute step 714.
[0160] Step 714: Check whether the data in the field meets the uniqueness requirement.
[0161] If yes, execute step 716 ; if no, execute step 728 .
[0162] Step 716: Allocate in sequence from the free positions of the unique index field in the data table.
[0163] Step 718: Whether the field already has existing data, that is, determining whether the position of the field to be changed already has existing data.
[0164] If yes, execute step 720; if no, execute step 722.
[0165] Step 720: Copy the data of the field in the object that is not empty in the old position to the new position, and increase the number of copies by 1.
[0166] Step 722: Whether the data at the old and new positions of the field are consistent, that is, whether the data at the old position of the field to be changed is consistent, that is, whether the data at the old position of the field to be changed has been copied to the new position.
[0167] If yes, execute step 724; if no, execute step 726.
[0168] Step 724: Whether the number of replications is less than 2, that is, determining whether the number of replications of the field to be changed is less than 2.
[0169] If yes, execute step 720 ; if no, execute step 728 .
[0170] Step 726: Clear the data in the old position of the field of the object.
[0171] Step 728: Prompt the user that the change failed.
[0172] Specifically, a field change failure notification is sent to the user, and the user can manually change the field through manual intervention.
[0173] Step 730: Update the field information to the field information table.
[0174] Step 732: The object status is changed from draft to effective, and the current effective version status is changed to offline.
[0175] Specifically, the state of the copied object table is set from the draft state to the effective state, and the state of the object table in the current effective state is set to offline.
[0176] Step 734: End, that is, the change of the field to be changed is completed.
[0177] In one implementation, when a field change instruction is received, a business model object information Object table is copied, and the version number of the copied object table is increased by 1. At the same time, the state of the object table is set to draft. It is determined whether the field to be changed requires an index constraint, that is, whether it is changed to an index field. If not, the field information of the field to be changed is updated in the field table (field information table) corresponding to the business model corresponding to the field to be changed. Then, the copied object table is changed from draft status to effective, and the state of the original object table is set to offline to complete the field change. If the field to be changed needs to be changed to an index field, the field information of all existing fields in the business model to which the field to be changed belongs is loaded, and then it is determined whether the field to be changed requires a unique constraint. If no unique constraint is required, it is allocated in sequence from the free position of the index field in the data table (target data table); if a unique constraint is required, the data of the field to be changed satisfies the unique constraint. If not, the user is prompted that the change failed, and a technical staff member intervenes to change the field. If the unique constraint is satisfied, it is allocated in sequence from the free position of the unique index field in the data table; then it is determined whether the field already has If there is no existing data, the data in the old position of the field to be changed will be cleared. If there is existing data, the data in the old position of the field to be changed that is not empty will be copied to the new position (target storage position), and the number of copies of the field to be changed will be increased by 1. Then it is determined whether the data in the new position of the field to be changed is consistent with the data in the old position. If they are consistent, the data in the old position of the field to be changed will be cleared, and the copied object table will be changed from draft status to effective. At the same time, the status of the original object table will be set to offline to complete the field change. If they are inconsistent, it is determined whether the number of copies of the field to be changed is consistent. If it is less than 2, then continue to copy the non-empty data in the old location of the field to be changed to the new location (target storage location), and increase the number of copies of the field to be changed by 1. If the number of copies is greater than or equal to 2, the user is prompted that the change has failed, and a technical staff member intervenes to change the field. After cleaning up the data in the old location of the field to be changed, update the field information of the field to be changed in the field table (field information table) corresponding to the business model of the field to be changed, and then change the copied object table from draft status to effective, and set the status of the original object table to offline to complete the field change.
[0178] Specifically, after receiving a field change request, a copy of the object table (Object table) needs to be made as a draft, so that the field change operation can be performed in the copied object table later, thereby completing the field change operation without affecting the use of the original object table. The specific implementation method is as follows:
[0179] After receiving the field change request, the method further includes:
[0180] Copying the first object table of the business model corresponding to the field to be changed as the initial object table, and setting the state of the initial object table to a draft state;
[0181] Correspondingly, after updating the field information of the field to be changed in the field information table, the method further includes:
[0182] The changed initial object table is used as the target object table, and the state of the target object table is determined to be effective, while the first object table is offline.
[0183] Specifically, the first object table of the business model corresponding to the field to be changed is copied, the copied object table is used as the initial object table, and the version number of the initial object table is increased by 1. At the same time, the status of the initial object table is set to the draft status, so that when performing subsequent field change operations, they can be performed in the initial object table without affecting the use of the first object table; after the change of the changed field is completed, the changed initial object table is used as the target object table, and the first object table is taken offline, and the status of the target object table is set to be effective, replacing the first object table.
[0184] In addition, when the field to be changed is an index field or a non-index field, and the request is to change it to a non-index field, the target storage location of the field to be changed can be directly determined and stored. The specific implementation method is as follows:
[0185] After receiving the field change request, the method further includes:
[0186] When it is determined that the field change request is to change the field to be changed to a non-index field, a target storage location of the field to be changed in the non-index field area is determined, wherein the field to be changed includes an index field or a non-index field.
[0187] Specifically, when it is determined that the field change request is to change the field to be changed (index field or non-index field) to a non-index field, the allocatable area of the field to be changed in the target database is determined to be a non-index area, and the free allocatable area of the field to be changed is determined in the non-index area, and the target storage position of the field to be changed is determined in the free allocatable area.
[0188] When determining the target storage location of the field to be changed in the index field area, it is necessary to determine the change method of the field to be changed based on the field information of the field to be changed. The specific implementation method is as follows:
[0189] Determining the target storage location of the field to be changed in the index field area includes:
[0190] Obtaining, from the field information table corresponding to the business model of the field to be changed, field information of the historical field in the target data table corresponding to the business model of the field to be changed;
[0191] When it is determined that the field change request is to change the field to be changed to a first type index field, and the field to be changed is determined to be a first type index field, determining a target storage location of the field to be changed in the first type index field area of the index field area based on field information of a historical field in the target data table; or
[0192] When it is determined that the field change request is to change the field to be changed to a second type index field, the target storage location of the field to be changed is determined in the second type index field area of the index field area according to the field information of the historical field in the target data table.
[0193] In one implementation, the field information of the historical field in the target data table corresponding to the business model of the field to be changed is obtained from the field information table corresponding to the business model of the field to be changed, and the field change request is parsed. When it is determined that the field to be changed needs to be changed to a unique index field (first type index field) and satisfies the uniqueness constraint, the allocable free area of the field to be changed is determined in the unique index field area of the index field area according to the field information of the historical field in the target data table, and the first key value of the allocable free area is determined as the target storage location of the field to be changed, or any key value of the allocable free area is determined as the target storage location of the field to be changed. The determination of the target storage location can be set according to the actual application and is not specifically limited here.
[0194] In another implementation method, the field information of the historical field in the target data table corresponding to the business model of the field to be changed is obtained from the field information table corresponding to the business model of the field to be changed, and the field change request is parsed. When it is determined that the field to be changed only needs to be changed to an ordinary index field (second type index field), the allocable free area of the field to be changed is determined in the ordinary index field area of the index field area according to the field information of the historical field in the target data table, and the first key value of the allocable free area is determined as the target storage location of the field to be changed, or any key value of the allocable free area is determined as the target storage location of the field to be changed. The determination of the target storage location can be set according to the actual application and is not specifically limited here.
[0195] It should be noted that if the field to be changed does not meet the uniqueness constraint, a message indicating that the field change failed will be sent, and the technical staff will then handle the problem of the change failure.
[0196] After determining the target storage location for the field to be changed, it is also necessary to determine whether there is existing data for the field to be changed when the change is made. In other words, whether new data is stored when the field change operation is performed on the field to be changed. If so, the existing data needs to be changed to the target storage location to ensure that the data is not lost. The specific implementation method is as follows:
[0197] After copying the existing data from the current storage location of the field to be changed to the target storage location, the method further includes:
[0198] When it is determined that the existing data at the current storage location is inconsistent with the existing data at the target storage location and the current number of copies is less than a preset number threshold, continue to execute the step of copying the existing data from the current storage location of the field to be changed to the target storage location.
[0199] In one implementation, when it is determined that there is existing data in the field to be changed, the data that is not empty in the old position (current position) of the field to be changed is copied to the new position (target storage position), and the number of copies of the field to be changed is increased by 1, and it is determined whether the data in the old position and the new position of the field to be changed are consistent. When it is determined that the data in the old position and the new position of the field to be changed are inconsistent, it is determined whether the number of copies of the field to be changed is less than a preset number threshold. If not, the execution is repeated, and the data that is not empty in the old position (current position) of the field to be changed is copied to the new position (target storage position), and the number of copies of the field to be changed is increased by 1. Until it is determined that the data in the old position and the new position of the field to be changed are consistent, the data in the old position of the field to be changed is cleared, and the field information of the changed field to be changed is recorded in the field information table, and then the changed initial object table is used as the target object table, the first object table is offline, and the status of the target object table is set to be effective, replacing the first object table for use, wherein the preset is described.
[0200] In another implementation method, when it is determined that there is existing data in the field to be changed, the data that is not empty in the old position (current position) of the field to be changed is copied to the new position (target storage position), and the number of copies of the field to be changed is increased by 1. It is determined whether the data in the old position and the new position of the field to be changed are consistent. When it is determined that the data in the old position and the new position of the field to be changed are consistent, the data in the old position of the field to be changed is cleared, and the field information of the changed field to be changed is recorded in the field information table. Then, the changed initial object table is used as the target object table, the first object table is taken offline, and the status of the target object table is set to be effective, replacing the first object table for use.
[0201] It should be noted that when the number of replications is greater than or equal to the preset threshold, a message indicating that the field change has failed will be sent, and the technical staff will then handle the issue of the failed change.
[0202] In an embodiment of the present specification, a business model corresponding to a newly added field is determined based on the field information of the newly added field; field information of a historical field in a target data table corresponding to the business model is obtained, wherein the target data table includes an index field area and a non-index field area; when it is determined that the newly added field is an index field, a storage location of the newly added field is determined in the index field area based on the field information of the historical field in the target data table.
[0203] Specifically, this specification stores index fields and non-index fields in the same data table, thereby avoiding the problem of having to synchronously modify the corresponding index table when modifying non-index field data, thereby reducing the complexity of database operations; and the data storage method provided in this specification can improve the execution efficiency of data queries in subsequent data queries.
[0204] When adding or changing fields in the business model, the appropriate storage location is automatically calculated and saved from the target data table based on the business requirements for the field (such as the need to build indexes and unique constraints).
[0205] Furthermore, when business field changes involve changes between columns of different types, we provide the ability to automatically migrate data and compare results (conditions can be set to trigger non-automatic migration based on business circumstances). This leverages the database's inherent mechanisms to establish indexes, reducing the engineering effort required to rebuild indexes compared to independent index table architectures. We also introduce a model versioning mechanism to ensure that changing models do not affect the normal operation of the online version.
[0206] See also Figure 8 , Figure 8 A flow chart of a data query method provided according to an embodiment of this specification is shown, which specifically includes the following steps.
[0207] Step 802: Acquire field information of historical fields in the target data table according to the received data query request, wherein the data query request carries data information of the data to be queried.
[0208] The data query request includes but is not limited to data information of the data to be queried, the time when the data query request is sent, etc.
[0209] Specifically, according to the received data query request, obtaining the field information of the historical fields in the target data table can be understood as: according to the data information of the data to be queried in the received data query request, the database information where the data to be queried is located, determining the target data table corresponding to the data to be queried, and then obtaining the field information of the historical fields in the target data table.
[0210] Step 804: Process the data query request according to a preset processing rule to obtain an initial data query statement.
[0211] The preset processing rule is a rule for processing a data query request into a query statement corresponding to a storage key value of the database.
[0212] The initial data query statement can be understood as a query statement corresponding to the database storage key value generated after being processed by a preset processing rule.
[0213] Specifically, processing the data query request according to the preset processing rules to obtain the initial data query statement can be understood as: converting the corresponding data fields in the data query request into the corresponding key value fields stored in the database according to the preset processing rules, and obtaining the initial data query statement, wherein the preset processing rules can be set according to actual applications and are not limited here; for example, in the case where the data query request is to query the "Order ID" column in the "Order Table" where the target data table is the "Order ID", the key value corresponding to the "Order ID" is obtained as key value 10 according to the preset processing rules, then the data query request is processed as querying the data with key value 10 in the "Order Table".
[0214] In addition, after obtaining the initial data query statement, it is necessary to determine whether to configure the query engine mode, so as to determine the corresponding data query method, to avoid low query efficiency due to different query methods, resulting in a poor user experience. The specific implementation method is as follows:
[0215] After obtaining the initial data query statement, the method further includes:
[0216] If it is determined that the query engine does not exist, generating a target query statement according to the initial data query condition;
[0217] The target query statement is executed in a database according to the target query statement to obtain the target query result.
[0218] The query engine is pre-set to improve the retrieval efficiency of data queries and reduce timeliness in the presence of complex query statements, fuzzy queries, etc.
[0219] Specifically, when it is determined that no query engine exists, a data query statement corresponding to the database, that is, a target query statement, is generated based on the initial data query request, and then the target query statement is executed in the database according to the target query statement, thereby obtaining the target query statement.
[0220] Step 806: When it is determined that a query engine exists and the initial data query statement satisfies a preset retrieval condition, a target data query statement corresponding to the query engine is generated according to the initial data query request.
[0221] The preset search conditions include, but are not limited to, complex query conditions, low requirements on the timeliness of the search content, and other conditions.
[0222] Specifically, when it is determined that a query engine exists and the initial data query statement meets the preset retrieval conditions, the initial data query request is processed according to the preset statement processing rules to generate a target data query statement corresponding to the query engine, wherein the preset statement processing rules can be set according to actual applications, and this specification does not impose any restrictions on this.
[0223] In addition, when a query engine exists but the preset search conditions are not met, the initial data query statement needs to be processed according to different situations, so as to quickly complete the subsequent data query operation. The specific implementation method is as follows:
[0224] Before generating a target data query statement corresponding to the query engine according to the initial data query request, the method further includes:
[0225] When it is determined that a query engine exists, the initial data query statement does not meet the preset retrieval condition, and an engine query instruction exists, a target data query statement corresponding to the query engine is generated according to the initial data query request.
[0226] Among them, the engine query instruction can be understood as an instruction for performing data query through the query engine. In addition, the query engine can improve the efficiency of data query in specific scenarios, wherein the specific scenarios include complex condition query scenarios that do not require high timeliness of the retrieved content. For example, complex query judgments, such as: fuzzy search like, large text field keyword query, etc.; the timeliness of the retrieved content, indicating that it takes a certain amount of time to establish the search engine index data, and old data may be returned during this period. Or meet other custom condition scenarios, such as: special configuration requirements of the business model require query through the query engine.
[0227] Specifically, when it is determined that a query engine exists, but the initial data query request does not meet the preset retrieval conditions and an engine query instruction exists, the initial data query request is processed using the preset statement processing rules to generate a target data query request corresponding to the query engine.
[0228] Step 808: calling the query engine to perform data query according to the target data query statement and the field information to obtain the target query result of the data to be queried.
[0229] Specifically, the query engine is called to perform a data query on the data to be queried based on the target data query statement and the field information of the field to be queried, to obtain the initial query result of the data to be queried, and then the initial query result is processed according to the preset result conversion rules, and the initial query result is converted into the target query result corresponding to the business model.
[0230] In actual applications, the query engine can be understood as a search engine. In the case of a data query method provided in this specification that is applied to a scenario where a query is performed through a search engine mechanism, the field contents of all index types in the data table are synchronized to the search engine, and the search requests that meet certain conditions are completed through the search engine. The search engine is started by default for retrieval requests with complex query conditions, and the start conditions can also be defined according to actual business needs (script extension is supported). Querying through a search engine is an optional design in the architecture, and when a problem occurs or there is no access, it can still be queried through the database. Among them, the search engine mechanism can be understood as a way of applying a query engine to perform data queries in the target database.
[0231] The following takes the application of the data storage method provided in this specification in a scenario based on the metadata zone architecture wide table mode as an example to further explain the business model corresponding to the newly added fields based on the field information of the newly added fields.
[0232] See also Figure 9 , Figure 9 The following is a processing flow chart of a data query method according to an embodiment of this specification. The specific steps are as follows:
[0233] Step 902: Initiate a data query request.
[0234] Step 904: Load the field information of all fields in the business model to be retrieved and the field description information of all fields in the object table from the field information table.
[0235] Step 906: If the field information meets the validity condition, the query condition field is escaped to the actual Value field of the wide table, and the condition is parsed into SQL symbols.
[0236] Step 908: Whether the system is configured with a query engine, that is, determining whether the current system is configured with a search engine.
[0237] If not, execute step 922; if so, execute step 910.
[0238] Step 910: Whether the preset query condition is satisfied, that is, whether the query statement satisfies the preset query condition is determined.
[0239] If yes, execute step 912 ; if no, execute step 920 .
[0240] Step 912: Generate a search engine query statement based on the query field.
[0241] Step 914: Request the search engine to complete the search.
[0242] Step 916: Encapsulate the query results into a business model structure.
[0243] Step 918: Return the result, that is, return the queried data.
[0244] Step 920: Whether there is an engine query instruction, that is, whether the query statement requires the use of a search engine to perform data query.
[0245] If yes, execute step 912 ; if no, execute step 922 .
[0246] Step 922: Generate an SQL statement according to the query field, SQL symbol and business model ID.
[0247] Step 924: Perform a search in the data table through the database.
[0248] In one implementation, based on the business model information corresponding to the data query request, the field information in the business model corresponding to the data query request is obtained from the field information table (field table), the field information in the data query request is converted into the key value (value) corresponding to the corresponding field in the wide table, and parsed into database (SQL) symbols, and then it is determined whether the system is configured with a query engine (search engine). If the query engine is not configured, an SQL statement is generated based on the query field, SQL symbols and business model ID, and then data is queried in the target data table (data table) through the database, and the query result is converted into the field name corresponding to the field name (that is, the query result is encapsulated into a business model structure), and the result is returned to complete the data query; and in the case of configuring the query engine, it is determined whether the query statement meets the preset query conditions, wherein the preset query conditions can be complex query conditions, low requirements on the timeliness of the retrieved content, etc. When it is determined that the query statement meets the preset query conditions, a query reference is generated according to the query field. The query statement corresponding to the engine is generated, requesting the query engine to complete the data query operation, converting the query result into the field name corresponding to the field name (that is, encapsulating the query result into a business model structure), and returning the result to complete the data query; if the preset query conditions are not met, it is determined whether the data query request has the engine query condition, that is, whether the query engine is required to perform data query; if the engine query condition exists, a query statement corresponding to the query engine is generated according to the query field, requesting the query engine to complete the data query operation, converting the query result into the field name corresponding to the field name (that is, encapsulating the query result into a business model structure), and returning the result to complete the data query; if the engine query condition does not exist, a database query language is generated according to the data query request, and a conversion statement is added to the field of the data type, and then data query is performed in the target data table (data table) through the database, and the query result is converted into the field name corresponding to the field name (that is, encapsulating the query result into a business model structure), and returning the result to complete the data query.
[0249] In an embodiment of the present specification, field information of historical fields in a target data table is obtained according to a received data query request, wherein the data query request carries data information of the data to be queried; the data query request is processed according to a preset processing rule to obtain an initial data query statement; when it is determined that a query engine exists and the initial data query statement meets a preset retrieval condition, a target data query statement corresponding to the query engine is generated according to the initial data query request; the query engine is called to perform a data query in the target data table according to the target data query statement and the field information to obtain a target query result of the data to be queried. The data query method in the embodiment of the present specification can improve the search efficiency of data queries under complex query conditions.
[0250] See also Figure 10 , Figure 10 A specific processing flow chart of a data query method provided according to an embodiment of this specification is shown, which specifically includes the following steps.
[0251] Step 1002: Receive a data query request, and obtain field information of historical fields in the field information table corresponding to the data to be queried, and field description information of historical fields in the object table according to the data query request.
[0252] Step 1004: If the data query request meets the validity requirements, the data query request is processed according to a preset processing rule to obtain an initial data query request.
[0253] The fact that the data query request satisfies the validity can be understood as: the data query request satisfies the data query requirement. The data query requirement can be set according to the real-time application, and this specification does not impose any limitation on this.
[0254] Step 1006: When it is determined that a query engine exists, determine whether the initial data query request meets a preset search condition.
[0255] Step 1008: When it is determined that the initial data query request meets the preset search conditions, the initial data query request is processed according to the preset statement processing rules to generate a target data query statement corresponding to the query engine.
[0256] Step 1010: Call the query engine to perform data query according to the target data query statement and the field information to obtain initial query results.
[0257] Step 1012: Process the initial query result according to a preset result processing rule to obtain a target query statement.
[0258] The specific implementation of the above steps 1002-1012 is consistent with the specific implementation of the data query method in the above embodiment, and will not be discussed in detail here. For details, please refer to the data query method in the above embodiment.
[0259] In one implementation, all index fields (normal and unique) can be synchronized to the query engine, and the fields in the data table can be divided into normal fields and unique index fields, while normal index fields can be eliminated. This means that the query engine is an essential part of the architecture implementation.
[0260] The data query method provided in the embodiment of this specification obtains field information of historical fields in the target data table according to a received data query request, wherein the data query request carries data information of the data to be queried; the data query request is processed according to a preset processing rule to obtain an initial data query statement; when it is determined that a query engine exists and the initial data query statement meets the preset retrieval conditions, a target data query statement corresponding to the query engine is generated according to the initial data query request; the query engine is called to perform data query in the target data table according to the target data query statement and the field information to obtain the target query result of the data to be queried. The data query method in the embodiment of this specification can improve the search efficiency of data queries under complex query conditions.
[0261] In addition, this manual adjusts the model architecture to avoid the complex and inefficient implementation of self-association queries in the index table caused by searching for multiple conditions at the same time; and introduces a lightweight index reconstruction service to avoid engineering-based index reconstruction (that is, relying on middleware to monitor binlog and using code to implement the database index reconstruction function); and introduces a search engine mechanism that enterprises can connect to according to actual needs (optional) to improve retrieval efficiency under complex query conditions.
[0262] In addition, this manual simplifies the design of independent index tables in the architecture, avoiding the complexity and inefficiency of the original architecture's need for self-association queries in index tables when searching for multiple conditions simultaneously; it develops a wide table location management service (wide fields are divided into three categories), which fully utilizes the database's native indexing capabilities and index merging capabilities without affecting the original usage of the wide table, eliminating the need for additional index table maintenance and engineering index reconstruction costs; the architecture introduces a search engine mode, which can optionally improve query efficiency through search engines based on business needs, thereby improving the applicability of the architecture.
[0263] It should be noted that the above data storage method and data query method may be for metadata data storage and data query.
[0264] After storing the metadata in the metadata table (i.e., the object table and the field information table) corresponding to the data table (data table) through the data storage method provided in the embodiments of this specification, the data in the data table can also be stored through the constructed data wide table architecture model.
[0265] See also Figure 11 , Figure 11 A flow chart of a data table data storage method provided according to an embodiment of the present specification is shown, which specifically includes the following contents.
[0266] Step 1102: Initiate a data query request.
[0267] Step 1104: Load the field information of all fields in the business model that need to be retrieved and the field description information of all fields in the object table from the field information table.
[0268] Step 1106: Check whether the submitted data is valid.
[0269] If not, execute step 1116; if so, execute step 1108.
[0270] Step 1108: Translate the submitted data into the wide table field value and format according to the field information.
[0271] Step 1110: Save SQL by executing data.
[0272] Step 1112: Whether a search engine is configured, that is, determining whether the system is configured with a search engine.
[0273] If yes, execute step 1114; if no, execute step 1116.
[0274] Step 1114: Synchronize the newly added data to the search engine.
[0275] Step 1116: Return the result, that is, return the data found through the search engine.
[0276] In one implementation, when a data storage request is received, the field information of all fields in the field information table corresponding to the business model and the field description information of all fields in the object table are loaded, and the validity of the data content corresponding to the data storage request is detected (that is, the field type, data length, required items, etc. of the data content. For example, if the field type of the data content is a date type, and the business model only supports numeric types and variable character types, it does not meet the validity and the data storage request is directly returned; if the data length of the data content is 500 and the maximum supported data length in the business model is 200, it is determined that the data content does not meet the validity and the data storage request is directly returned; if the business model is a user model , set the name field in the data table corresponding to the user model as a required item, and the name field is not filled in the data storage request, then it is determined that the data storage request does not meet the validity, and the data storage request is directly returned). When it is determined that the data content in the data storage request meets the validity, the data storage request is escaped according to the loaded field information, and escaped into the key value format corresponding to the wide table field, and the SQL statement is executed through the database to save the storage operation of the data; then it is judged whether the query engine (search engine) is configured. When it is determined that the query engine is configured, the new data is synchronized to the query engine to complete the storage of the data in the data table; when it is determined that the query engine is not configured, the storage of the data in the data table is completed.
[0277] To facilitate understanding, let's take a new order record for Zhang San as an example.
[0278] In one embodiment, a data storage request is received, wherein the data content in the data storage request includes: orderid: 100 (i.e., order id: 100), goodsid: 111 (i.e., goods id: 111), userName: "Zhang San" (i.e., user name: "Zhang San"), amount: 1.00 (i.e., amount: 1.00), memo: "Please pack it well" (i.e., note: "Please pack it well"), and the field description information in the Object table (i.e., object table) corresponding to the data content is loaded as code: order (i.e., code: order), name: order model (i.e., name: order model), objid: 1000001 (i.e., object id: 1000001), and the field information in the corresponding field table (i.e., field information table) is as follows: The position of the data table (i.e., data table) corresponding to orderid (i.e., order id) is key value 0, unique index number type, required field, the position of the data table corresponding to goodsid (i.e., goods id) is key value 20, common index number type, required field, the position of the data table corresponding to userName (i.e., user name) is key value 40, common index variable string type, required field, the position of amount (i.e., amount) corresponding to the data table is key value 60, common string position (i.e., common index field), required field, the position of memo (i.e., notes) corresponding to the data table is key value 61, common field string position, optional field; when it is determined that the above data content meets the validity, the data storage request is escaped as "insert" according to the field information of the order table. "into data{objid,value0,value20,value40,value60,value61}values(1000001,100,111,'1.00','Please pack it well.');" This data storage statement is executed in the database, and then a check is made to see whether a query engine is configured. If the query engine is configured, the new data is synchronized to the search engine to complete the data storage in the data table. If the query engine is not configured, the data is stored in the data table.
[0279] Correspondingly, after completing the storage of the data in the data table, the data can also be queried in the data table. The data query in the data table is similar to the above data query method. For the specific data query method in the data table, please refer to the above data query method.
[0280] To facilitate understanding, the following example uses the query of the order records of Zhang San purchasing products A and B to illustrate.
[0281] In one embodiment, according to the received data query request, which includes {goodsid in {a, b}, userName = "Zhang San"}, the business model corresponding to the data query request is loaded as an order table. The field description information in the Object table (i.e., the object table) corresponding to the order table is code: order (i.e., code: order), name: order model (i.e., name: order model), objid: 1000001 (i.e., object id: 1000001). The field information in the corresponding field table (i.e., the field information table) is that the position of the data table corresponding to orderid (i.e., order id) is key value 0, unique index number type, required field; the position of the data table corresponding to goodsid (i.e., goods id) is key value 20, ordinary index number type, required field; the position of the data table corresponding to userName (i.e., user name) is key value 40, ordinary index variable string type, required field; the position of the data table corresponding to amount (i.e., amount) is key value 60, ordinary string position (i.e., ordinary index field), required field; the position of the data table corresponding to memo (i.e., remarks) is key value 61, ordinary field string position, optional field. The data storage request is escaped as "select id, value0, value20, value40, value60, value61 from data where objid = '1000001' and value20 in {a, b} and value40 = 'Zhang San';". Among them, escaping according to SQL syntax includes but is not limited to: select (result set fields), where (filtering conditions), group by (grouping conditions), order by (sorting conditions), limit / top (paging conditions), etc. When it is determined that the query engine is configured and the data query request meets the preset query conditions, a query statement corresponding to the query engine is generated according to the data query request, and the query engine is called to complete the data retrieval, and the query result is converted into the business model structure corresponding to the order model to complete the query of the data in the data table.
[0282] Corresponding to the above method embodiment, this specification also provides an embodiment of a data storage device. Figure 12 The structural schematic diagram of a data storage device provided by an embodiment of this specification is shown. As Figure 12 shown, the device includes:
[0283] A model determination module 1202, configured to determine the business model corresponding to the new field according to the field information of the new field.
[0284] The information acquisition module 1204 is configured to acquire field information of a historical field in a target data table corresponding to the business model, wherein the target data table includes an index field area and a non-index field area;
[0285] The location determination module 1206 is configured to determine the storage location of the new field in the index field area according to the field information of the historical field in the target data table when the new field is determined to be an index field.
[0286] Optionally, the information acquisition module 1204 is further configured to:
[0287] Determine the field information table corresponding to the business model;
[0288] Acquire field information of historical fields in the target data table corresponding to the business model from the field information table;
[0289] Correspondingly, after determining the storage location of the newly added field in the index field area according to the field information of the historical field in the target data table, the method further includes:
[0290] The field information of the newly added field and the storage location of the newly added field are recorded in the field information table.
[0291] Optionally, the location determination module 1206 is further configured to:
[0292] When it is determined that the newly added field is an index field and the newly added field is a first type index field, determining a storage location of the newly added field in the first type index field area of the index field area according to field information of the historical field in the target data table; or
[0293] When it is determined that the newly added field is an index field and the newly added field is a second type index field, the storage location of the newly added field is determined in the second type index field area of the index field area according to the field information of the historical field in the target data table.
[0294] Optionally, the device further includes:
[0295] The non-index field storage location determination module is configured as follows:
[0296] In the case where it is determined that the newly added field is a non-index field, the storage location of the newly added field is determined in the non-index field area according to the field information of the historical field in the target data table.
[0297] Optionally, the location determination module 1206 is further configured to:
[0298] When it is determined that there is an idle storage location in the index field area based on the field information of the historical field in the target data table, the storage location of the newly added field is determined in the idle storage location; or
[0299] When it is determined based on the field information of the historical fields in the target data table that there is no free storage location in the index field area, a corresponding storage location is added in the index field area for the newly added field.
[0300] Optionally, the location determination module 1206 is further configured to:
[0301] If it is determined based on the field information in the target data table that there is an idle storage location in the non-index field area, determining the storage location of the newly added field in the idle storage location; or
[0302] When it is determined based on the field information of the historical fields in the target data table that there is no free storage location in the non-index field area, a corresponding storage location is added in the non-index field area for the newly added field.
[0303] Optionally, the device further includes:
[0304] The field change module is configured as follows:
[0305] receiving a field change request, and if it is determined that the field change request is to change the field to be changed into an index field, determining a target storage location of the field to be changed in the index field area, wherein the field to be changed is a non-index field;
[0306] If it is determined that the field to be changed already has existing data, copying the existing data from the current storage location of the field to be changed to the target storage location;
[0307] When it is determined that the stock data at the current storage location is consistent with the stock data at the target storage location, the stock data at the current storage location is deleted, and the field information of the field to be changed is updated in the field information table.
[0308] Optionally, the device further includes:
[0309] The object table processing module is configured as follows:
[0310] Copying the first object table of the business model corresponding to the field to be changed as the initial object table, and setting the state of the initial object table to a draft state;
[0311] Correspondingly, after updating the field information of the field to be changed in the field information table, the method further includes:
[0312] The changed initial object table is used as the target object table, and the state of the target object table is determined to be effective, while the first object table is offline.
[0313] Optionally, the device further includes:
[0314] The target storage location determination module is configured to:
[0315] When it is determined that the field change request is to change the field to be changed to a non-index field, a target storage location of the field to be changed in the non-index field area is determined, wherein the field to be changed includes an index field or a non-index field.
[0316] Optionally, the field changing module is further configured to:
[0317] Obtaining, from the field information table corresponding to the business model of the field to be changed, field information of the historical field in the target data table corresponding to the business model of the field to be changed;
[0318] When it is determined that the field change request is to change the field to be changed to a first type index field, and the field to be changed is determined to be a first type index field, determining a target storage location of the field to be changed in the first type index field area of the index field area based on field information of a historical field in the target data table; or
[0319] When it is determined that the field change request is to change the field to be changed to a second type index field, the target storage location of the field to be changed is determined in the second type index field area of the index field area according to the field information of the historical field in the target data table.
[0320] Optionally, the device further includes:
[0321] The judgment module is configured as follows:
[0322] When it is determined that the existing data at the current storage location is inconsistent with the existing data at the target storage location and the current number of copies is less than a preset number threshold, continue to execute the step of copying the existing data from the current storage location of the field to be changed to the target storage location.
[0323] The data storage device provided in the embodiments of this specification determines the business model corresponding to the newly added field based on the field information of the newly added field; obtains the field information of the historical field in the target data table corresponding to the business model, wherein the target data table includes an index field area and a non-index field area; when it is determined that the newly added field is an index field, the storage location of the newly added field is determined in the index field area based on the field information of the historical field in the target data table.
[0324] Specifically, the data storage device provided in the embodiment of this specification avoids the problem of needing to synchronously modify the corresponding index table when modifying non-index field data by storing index fields and non-index fields in the index field area and non-index field area corresponding to the same data table, thereby reducing the complexity of database operations; and the data storage device provided in this specification can improve the execution efficiency of data queries during subsequent data queries.
[0325] The above is a schematic diagram of a data storage device according to this embodiment. It should be noted that the technical solution of the data storage device and the technical solution of the data storage method described above are of the same concept. For details not described in detail in the technical solution of the data storage device, please refer to the description of the technical solution of the data storage method described above.
[0326] Corresponding to the above method embodiment, this specification also provides a data query device embodiment, Figure 13 FIG. 1 shows a schematic diagram of a data query device provided by an embodiment of this specification. Figure 13 As shown, the device includes:
[0327] The first information acquisition module 1302 is configured to acquire field information of a historical field in a target data table according to a received data query request;
[0328] The query statement acquisition module 1304 is configured to process the data query request according to a preset processing rule to obtain an initial data query statement;
[0329] The target query statement generating module 1306 is configured to generate a target data query statement corresponding to the query engine according to the initial data query request if it is determined that a query engine exists and the initial data query statement meets the preset retrieval condition;
[0330] The target query result generating module 1308 is configured to call the query engine to perform data query according to the target data query statement and the field information, and obtain the target query result of the data to be queried.
[0331] Optionally, the device further includes:
[0332] The database query module is configured as follows:
[0333] If it is determined that the query engine does not exist, generating a target query statement according to the initial data query condition;
[0334] The target query statement is executed in a database according to the target query statement to obtain the target query result.
[0335] Optionally, the device further includes:
[0336] The instruction determination module is configured to:
[0337] When it is determined that a query engine exists, the initial data query statement does not meet the preset retrieval condition, and an engine query instruction exists, a target data query statement corresponding to the query engine is generated according to the initial data query request.
[0338] The data query device provided in the embodiment of this specification obtains field information of historical fields in the target data table according to a received data query request, wherein the data query request carries data information of the data to be queried; the data query request is processed according to a preset processing rule to obtain an initial data query statement; when it is determined that a query engine exists and the initial data query statement meets the preset retrieval conditions, a target data query statement corresponding to the query engine is generated according to the initial data query request; the query engine is called to perform data query in the target data table according to the target data query statement and the field information to obtain the target query result of the data to be queried. The data query device in the embodiment of this specification can improve the search efficiency of data queries under complex query conditions.
[0339] The above is a schematic diagram of a data query device according to this embodiment. It should be noted that the technical solution of the data query device and the technical solution of the above-mentioned data storage method are of the same concept. For details not described in detail in the technical solution of the data query device, please refer to the description of the technical solution of the above-mentioned data query method.
[0340] The computing device 1400 also includes an access device 1440 that enables the computing device 1400 to communicate via one or more networks 1460. Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1440 may include one or more of any type of network interface (e.g., a network interface card (NIC)), whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0341] In one embodiment of the present specification, the above components of the computing device 1400 and Figure 14 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 14 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.
[0342] Computing device 1400 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. Computing device 1400 can also be a mobile or stationary server.
[0343] The processor 1420 is configured to execute the following computer-executable instructions, which implement the steps of the above-mentioned data storage method when executed by the processor.
[0344] The above is a schematic diagram of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solutions of the aforementioned data storage method and data query method are based on the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solutions of the aforementioned data storage method and data query method.
[0345] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which implement the steps of the above-mentioned data storage method and data query method when executed by a processor.
[0346] The above is a schematic diagram of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium is based on the same concept as the technical solutions of the aforementioned data storage method and data query method. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solutions of the aforementioned data storage method and data query method.
[0347] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned data storage method and data query method.
[0348] The above is an illustrative solution of a computer program according to this embodiment. It should be noted that the technical solution of this computer program is based on the same concept as the technical solutions of the aforementioned data storage method and data query method. For details not described in detail in the technical solution of the computer program, please refer to the description of the technical solutions of the aforementioned data storage method and data query method.
[0349] 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.
[0350] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0351] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0352] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0353] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A data storage method, comprising: Determining, based on the field information of the newly added field, a business model corresponding to the newly added field, wherein the business model includes at least an object table, a field information table, and a data table, the object table and the field information table being composed of metadata, and the metadata being data corresponding to the data table; Obtaining field information of historical fields in a target data table corresponding to the business model, wherein the target data table includes an index field area and a non-index field area. The target data table is a pre-built wide table, and key values corresponding to the index field area and the non-index field area in the target data table are pre-divided during construction. The index field area includes a unique index field area and a common index field area. Fields in the unique index field area and the common index field area are established based on non-single field key values combined with object IDs in the metadata. In the case where it is determined that the newly added field is an index field, the storage location of the newly added field is determined in the index field area according to the field information of the historical fields in the target data table, wherein the storage location of the newly added field is determined in the index field area according to the field information of the historical fields in the target data table, including: in the case where it is determined that there is no free storage location in the index field area according to the field information of the historical fields in the target data table, a corresponding storage location is added for the newly added field in the index field area.
2. The data storage method according to claim 1, wherein obtaining field information of historical fields in the target data table corresponding to the business model comprises: Determine the field information table corresponding to the business model; Acquire field information of historical fields in the target data table corresponding to the business model from the field information table; Correspondingly, after determining the storage location of the newly added field in the index field area according to the field information of the historical field in the target data table, the method further includes: The field information of the newly added field and the storage location of the newly added field are recorded in the field information table.
3. The data storage method according to claim 1, wherein, when the newly added field is determined to be an index field, determining the storage location of the newly added field in the index field area based on field information of historical fields in the target data table comprises: When it is determined that the newly added field is an index field and the newly added field is a first type index field, determining a storage location of the newly added field in the first type index field area of the index field area according to field information of the historical field in the target data table; or When it is determined that the newly added field is an index field and the newly added field is a second type index field, the storage location of the newly added field is determined in the second type index field area of the index field area according to the field information of the historical field in the target data table.
4. The data storage method according to claim 1, after obtaining the field information of the historical fields in the target data table corresponding to the business model, further comprising: In the case where it is determined that the newly added field is a non-index field, the storage location of the newly added field is determined in the non-index field area according to the field information of the historical field in the target data table.
5. The data storage method according to claim 1, further comprising: When it is determined that there is an idle storage location in the index field area according to the field information of the historical field in the target data table, the storage location of the newly added field is determined in the idle storage location.
6. The data storage method according to claim 4, further comprising: When it is determined based on the field information in the target data table that there is an idle storage location in the non-index field area, determining the storage location of the newly added field in the idle storage location; or When it is determined based on the field information of the historical fields in the target data table that there is no free storage location in the non-index field area, a corresponding storage location is added in the non-index field area for the newly added field.
7. The data storage method according to claim 1, after determining the storage location of the newly added field in the index field area based on the field information in the target data table, further comprising: receiving a field change request, and if it is determined that the field change request is to change the field to be changed into an index field, determining a target storage location of the field to be changed in the index field area, wherein the field to be changed is a non-index field; If it is determined that the field to be changed already has existing data, copying the existing data from the current storage location of the field to be changed to the target storage location; When it is determined that the stock data at the current storage location is consistent with the stock data at the target storage location, the stock data at the current storage location is deleted, and the field information of the field to be changed is updated in the field information table.
8. The data storage method according to claim 7, further comprising: after receiving the field change request; Copying the first object table of the business model corresponding to the field to be changed as the initial object table, and setting the state of the initial object table to a draft state; Correspondingly, after updating the field information of the field to be changed in the field information table, the method further includes: The changed initial object table is used as the target object table, and the state of the target object table is determined to be effective, while the first object table is offline.
9. The data storage method according to claim 7, wherein determining the target storage location of the field to be changed in the index field area comprises: Obtaining, from the field information table corresponding to the business model of the field to be changed, field information of the historical field in the target data table corresponding to the business model of the field to be changed; When it is determined that the field change request is to change the field to be changed to a first type index field, and the field to be changed is determined to be a first type index field, determining a target storage location of the field to be changed in the first type index field area of the index field area based on field information of a historical field in the target data table; or When it is determined that the field change request is to change the field to be changed to a second type index field, the target storage location of the field to be changed is determined in the second type index field area of the index field area according to the field information of the historical field in the target data table.
10. The data storage method according to claim 7, further comprising: after copying the existing data from the current storage location of the field to be changed to the target storage location: When it is determined that the existing data at the current storage location is inconsistent with the existing data at the target storage location and the current number of copies is less than a preset number threshold, continue to execute the step of copying the existing data from the current storage location of the field to be changed to the target storage location.
11. A data query method, comprising: According to the received data query request, field information of the historical fields in the target data table is obtained, wherein the data query request carries data information of the data to be queried, the target data table includes an index field area and a non-index field area, the target data table is a pre-constructed wide table data table, and key values corresponding to the index field area and the non-index field area in the target data table are pre-divided during construction, the index field area includes a unique index field area and a common index field area, and the fields of the unique index field area and the common index field area are established based on non-single field key values combined with object IDs in metadata; when a new index field is added and it is determined that there is no free storage location in the index field area based on the field information of the historical fields in the target data table, a corresponding storage location is added in the index field area for the new index field; Processing the data query request according to preset processing rules to obtain an initial data query statement; If it is determined that a query engine exists and the initial data query statement meets the preset retrieval condition, generating a target data query statement corresponding to the query engine according to the initial data query request; The query engine is called to perform data query according to the target data query statement and the field information to obtain the target query result of the data to be queried.
12. The data query method according to claim 11, after obtaining the initial data query statement, further comprising: If it is determined that the query engine does not exist, generating a target query statement according to the initial data query condition; The target query statement is executed in a database according to the target query statement to obtain the target query result.
13. A computing device comprising: memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the data storage method described in any one of claims 1 to 10 or the steps of the data query method described in any one of claims 11 to 12 are implemented.
14. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the data storage method according to any one of claims 1 to 10 or the steps of the data query method according to any one of claims 11 to 12.
Citation Information
Patent Citations
Data querying method and device
CN106202451A
Data management method and device, and electronic device
CN108959381A
KV database configuration method, KV database query method, equipment and storage medium
CN110175176A
File system dynamic indexing method and device
CN111143284A
Index changing method and device
CN112507187A