Data query method, device, apparatus, and storage medium

By determining the data item to be queried and locating the memory block based on the user's data query instructions on a large data platform, and querying the cardinality estimate, the problem of high storage cost and low query efficiency caused by creating an index for each data table is solved, achieving the effect of saving storage costs and improving query efficiency.

CN122309557APending Publication Date: 2026-06-30BEIJING HONGTENG INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING HONGTENG INTELLIGENT TECH CO LTD
Filing Date
2024-12-30
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

On large data platforms like Heimdall, creating an index for each data table requires a large amount of storage space, resulting in high data storage costs and low data query efficiency.

Method used

By responding to the user's data query command, the system determines the data item to be queried, locates the corresponding memory block based on the data item and the preset data table, queries the cardinality estimate in the memory block, and queries the database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried, thus avoiding the need to create an index for each data table.

Benefits of technology

It effectively saves storage costs, improves data query efficiency, and overcomes the technical shortcomings of high storage costs and low query efficiency caused by creating indexes for each data table.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309557A_ABST
    Figure CN122309557A_ABST
Patent Text Reader

Abstract

This application relates to the field of data management technology and discloses a data query method, apparatus, device, and storage medium. The method includes: responding to a user's data query instruction, determining a data item to be queried based on the data query instruction; locating a corresponding memory block according to the data item to be queried and a preset data table; querying a cardinality estimate corresponding to the data item to be queried in the memory block; and querying a database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried. This application can effectively improve data query efficiency while saving data storage costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data management technology, and in particular to data query methods, apparatus, devices and storage media. Background Technology

[0002] With the advent of the big data era, the demand for data storage and retrieval is growing rapidly. Many fields have generated massive datasets. For example, in large data platforms like Haimerdal, the number of tables often reaches hundreds or thousands, with a single table containing tens of billions or even more rows of data. When a user enters a string and initiates a search request, it is necessary to quickly determine the table corresponding to the input and retrieve related data from that table. Traditional methods typically rely on creating indexes for each table. However, on the Haimerdal platform, due to the sheer number of tables and the massive amount of data, creating comprehensive indexes for all tables would not only require a large amount of storage space but also lead to a sharp increase in data storage costs. Furthermore, although data retrieval can be performed by creating indexes, the efficiency of data retrieval remains very low when dealing with extremely large datasets.

[0003] Therefore, how to improve data query efficiency while saving data storage costs is an urgent problem to be solved.

[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0005] The main objective of this application is to provide a data query method, apparatus, device, and storage medium, which aims to solve the technical problems of high data storage costs and low efficiency in data querying due to the large amount of storage space required to create an index for each data table.

[0006] To achieve the above objectives, this application proposes a data query method, which includes:

[0007] In response to a user's data query command, determine the data item to be queried based on the data query command;

[0008] Locate the corresponding memory block based on the data item to be queried and the preset data table;

[0009] Query the cardinality estimate corresponding to the data item to be queried in the memory block;

[0010] Based on the estimated base value and the preset data table, the database is queried to obtain the query data corresponding to the data item to be queried.

[0011] In one embodiment, locating the corresponding memory block based on the data item to be queried and a preset data table includes:

[0012] Retrieve the table identifier and table name of the preset data table;

[0013] The corresponding memory block is located based on the data item to be queried, the table identifier, and the table name.

[0014] In one embodiment, locating the corresponding memory block based on the data item to be queried, the table identifier, and the table name includes:

[0015] A first hash value is obtained by performing hash processing on the data item to be queried, the table identifier, and the table name;

[0016] The memory blocks corresponding to the preset data table are obtained by matching the first hash value with the memory addresses of multiple pre-divided memory blocks.

[0017] In one embodiment, the step of performing hash processing based on the data item to be queried, the table identifier, and the table name to obtain a first hash value includes:

[0018] Combine the data item to be queried, the table identifier, and the table name into a string;

[0019] Obtain the initial offset base and hash constant;

[0020] Based on the initial offset base and the hash constant, each character in the string is sequentially XORed and multiplied to obtain the first hash value.

[0021] In one embodiment, the step of querying the database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried includes:

[0022] Determine whether the data corresponding to the data item to be queried exists based on the estimated cardinality value;

[0023] When the data corresponding to the data item to be queried exists, the database is queried according to the preset data table to obtain the query data corresponding to the data item to be queried.

[0024] In one embodiment, determining whether the data corresponding to the data item to be queried exists based on the cardinality estimate includes:

[0025] Compare the estimated base value with the preset value;

[0026] When the estimated base value is greater than the preset value, it is determined that the data corresponding to the data item to be queried exists;

[0027] When the estimated base value is equal to the preset value, it is determined that the data corresponding to the data item to be queried does not exist.

[0028] In one embodiment, when the data corresponding to the data item to be queried exists, querying the database according to the preset data table to obtain the query data corresponding to the data item to be queried includes:

[0029] When the data corresponding to the data item to be queried exists, construct an SQL query statement based on the table identifier and table name of the preset data table;

[0030] The database is queried according to the SQL query statement to obtain the query data corresponding to the data item to be queried.

[0031] In one embodiment, before locating the corresponding memory block based on the data item to be queried and the preset data table, the method further includes:

[0032] Divide the preset memory space into multiple memory blocks;

[0033] Retrieve the data table to be stored;

[0034] The data in the data table to be stored is mapped to target memory blocks in multiple memory blocks.

[0035] In one embodiment, storing the data table to be stored into a target memory block among the plurality of memory blocks includes:

[0036] A second hash value is generated based on the data table to be stored.

[0037] Obtain the memory address of each memory block;

[0038] The target memory block among the multiple memory blocks is determined based on the second hash value and the memory address of each memory block.

[0039] In one embodiment, determining the target memory block among multiple memory blocks based on the second hash value and the memory addresses of each of the memory blocks includes:

[0040] Obtain the data storage size and base address of the memory block;

[0041] The target memory address is determined based on the second hash value, the amount of data stored, and the base address;

[0042] The target memory address is matched with the memory addresses of each memory block to obtain the matching memory address;

[0043] The memory block corresponding to the matched memory address is taken as the target memory block.

[0044] Furthermore, to achieve the above objectives, this application also proposes a data query device, which includes:

[0045] The determination module is used to determine the data item to be queried based on the user's data query instruction in response to the data query instruction;

[0046] The positioning module is used to locate the corresponding memory block based on the data item to be queried and the preset data table;

[0047] The query module is used to query the cardinality estimate corresponding to the data item to be queried in the memory block;

[0048] The query module is also used to query the database based on the estimated base value and the preset data table to obtain the query data corresponding to the data item to be queried.

[0049] In one embodiment, the positioning module is further configured to obtain the table identifier and table name of a preset data table;

[0050] The corresponding memory block is located based on the data item to be queried, the table identifier, and the table name.

[0051] In one embodiment, the positioning module is further configured to perform hash processing based on the data item to be queried, the table identifier, and the table name to obtain a first hash value;

[0052] The memory blocks corresponding to the preset data table are obtained by matching the first hash value with the memory addresses of multiple pre-divided memory blocks.

[0053] In one embodiment, the positioning module is further configured to combine the data item to be queried, the table identifier, and the table name into a string;

[0054] Obtain the initial offset base and hash constant;

[0055] Based on the initial offset base and the hash constant, each character in the string is sequentially XORed and multiplied to obtain the first hash value.

[0056] In one embodiment, the query module is further configured to determine whether the data corresponding to the data item to be queried exists based on the cardinality estimate;

[0057] When the data corresponding to the data item to be queried exists, the database is queried according to the preset data table to obtain the query data corresponding to the data item to be queried.

[0058] In one embodiment, the query module is further configured to compare the estimated cardinality with a preset value;

[0059] When the estimated base value is greater than the preset value, it is determined that the data corresponding to the data item to be queried exists;

[0060] When the estimated base value is equal to the preset value, it is determined that the data corresponding to the data item to be queried does not exist.

[0061] In one embodiment, the query module is further configured to construct an SQL query statement based on the table identifier and table name of the preset data table when the data corresponding to the data item to be queried exists;

[0062] The database is queried according to the SQL query statement to obtain the query data corresponding to the data item to be queried.

[0063] In one embodiment, the data query device further includes a mapping module, which is used to divide a preset memory space into multiple memory blocks;

[0064] Retrieve the data table to be stored;

[0065] The data in the data table to be stored is mapped to target memory blocks in multiple memory blocks.

[0066] In addition, to achieve the above objectives, this application also proposes a data query device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the data query method as described above.

[0067] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the data query method described above.

[0068] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the data query method described above.

[0069] This application provides a data query method. The method involves first responding to a user's data query command, determining the data item to be queried based on the command, locating the corresponding memory block based on the data item and a preset data table, querying the cardinality estimate corresponding to the data item in the memory block, and then querying a database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item. This method effectively improves data query efficiency while saving data storage costs.

[0070] In summary, this application determines the data item to be queried based on the user's data query command, then quickly locates the corresponding memory block based on the data item and the preset data table, and queries the cardinality estimate corresponding to the data item in that memory block. This eliminates the need to create an index for each data table, effectively saving storage costs. Furthermore, it quickly determines whether corresponding data exists in the preset data table based on the cardinality estimate and performs a data query. This allows for rapid retrieval of the corresponding data table, significantly improving data query efficiency. It overcomes the technical shortcomings of creating an index for each data table, which requires a large amount of storage space, leading to high data storage costs, and the low efficiency of data querying using indexes. Therefore, it effectively improves data query efficiency while saving data storage costs. Attached Figure Description

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

[0072] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0073] Figure 1 This is a flowchart illustrating an embodiment of the data query method of this application.

[0074] Figure 2 This is a flowchart illustrating Embodiment 2 of the data query method of this application;

[0075] Figure 3 This is a flowchart illustrating Embodiment 3 of the data query method of this application;

[0076] Figure 4 This is a schematic diagram of a memory block provided in one embodiment of the data query method of this application;

[0077] Figure 5 This is a schematic diagram of the module structure of the data query device according to an embodiment of this application;

[0078] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the data query method of this application embodiment.

[0079] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0080] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0081] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0082] The main solution of this application embodiment is: responding to the user's data query instruction, determining the data item to be queried based on the data query instruction; locating the corresponding memory block according to the data item to be queried and a preset data table; querying the cardinality estimate corresponding to the data item to be queried in the memory block; querying the database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried.

[0083] With the advent of the big data era, the demand for data storage and retrieval is growing rapidly. Many fields have generated massive datasets. For example, in large data platforms like Haimerdal, the number of tables often reaches hundreds or thousands, with a single table containing tens of billions or even more rows. When a user enters a string and initiates a search request, it's necessary to quickly determine the corresponding table and retrieve related data. Traditional methods typically rely on creating indexes for each table. However, on the Haimerdal platform, due to the sheer number of tables and the massive amount of data, creating comprehensive indexes for all tables would not only require a huge amount of storage space but also drastically increase data storage costs. Furthermore, although data retrieval can be performed using indexes, the efficiency remains very low given the extremely large volume of data. Therefore, improving data retrieval efficiency while saving data storage costs is a pressing issue that needs to be addressed.

[0084] This application determines the data item to be queried based on the user's data query command, then quickly locates the corresponding memory block based on the data item and a preset data table, and queries the cardinality estimate corresponding to the data item in that memory block. This eliminates the need to create an index for each data table, effectively saving storage costs. Furthermore, it quickly determines whether corresponding data exists in the preset data table based on the cardinality estimate and performs a data query. This allows for rapid retrieval of the corresponding data table, significantly improving data query efficiency. It overcomes the technical shortcomings of creating an index for each data table, which requires a large amount of storage space, leading to high data storage costs, and the low efficiency of data querying using indexes. Therefore, it effectively improves data query efficiency while saving data storage costs.

[0085] Based on this, the embodiments of this application provide a data query method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the data query method of this application.

[0086] In this embodiment, the data query method includes steps S10 to S40:

[0087] Step S10: In response to the user's data query instruction, determine the data item to be queried based on the data query instruction.

[0088] It should be noted that a data query instruction refers to an instruction issued by a user to request specific information. For example, a user may request a data query service by entering specific keywords, conditions, or parameters. In this embodiment, the data query instruction can be a query request entered by the user through a graphical user interface, or a query command sent through an application programming interface (API). This embodiment does not impose specific limitations on this.

[0089] It is understood that the data query instruction carries the data item to be queried, which refers to the specific information the user wishes to retrieve. For example, the user may want to query information about a specific customer, such as all individuals whose skills are "engineer" in the skills list, or all individuals whose allergies are "peanut" in the allergy information. In this embodiment, the data item to be queried can be any data field that the user wishes to query, such as name, age, address, phone number, email address, etc. The data item to be queried can be single or multiple combined together; this embodiment does not impose specific limitations on this.

[0090] Step S20: Locate the corresponding memory block based on the data item to be queried and the preset data table.

[0091] It should be noted that the preset data table can be a single table provided by the user, or it can be a collection of multiple tables, depending on the data query requirements. In this embodiment, we take a preset data table as a collection of multiple tables as an example, which could be 50 data tables, 100 data tables, etc. This embodiment does not impose any specific limitations on this.

[0092] Understandably, a predefined data table refers to a pre-defined data structure containing a large amount of data organized according to certain formats and rules. The system matches the data item to be queried with the information in the predefined data table to find the memory block that maps to the relevant data.

[0093] In practical implementation, the corresponding memory block can be quickly located based on the table information of the preset data table and the data item to be queried. The memory block is the basic unit of data storage, and each memory block stores a large amount of data mapped from the data table. By locating a specific memory block, the amount of data that needs to be processed during data querying can be significantly reduced, thereby improving query efficiency. Furthermore, mapping the data table data into memory blocks saves a significant amount of storage space, effectively reducing storage costs.

[0094] Step S30: Query the cardinality estimate corresponding to the data item to be queried in the memory block.

[0095] It's important to note that the cardinality estimate is a value estimated based on the distribution of data items within a memory block. It reflects the density of data items within the memory block. By using the cardinality estimate, it's possible to quickly determine whether a queried data item exists in a pre-defined data table, thus avoiding a full scan of the entire table and significantly improving query efficiency.

[0096] Understandably, MurmurHash3 is used to hash the elements in the memory block; a bucket is selected based on the first few bits of the hash value; the number of consecutive 0s in the hash value is calculated; the value in the bucket is updated to the maximum number of leading zeros currently observed; the process of hashing, selecting buckets, and updating buckets is repeated until all elements have been processed; the harmonic mean is calculated based on the values ​​of all buckets; if most buckets are empty, a linear counting correction is used; an empirical bias correction formula is used; and the final cardinality estimate is output.

[0097] Step S40: Based on the estimated base value and the preset data table, query the database to obtain the query data corresponding to the data item to be queried.

[0098] It should be noted that the cardinality estimate can determine whether the data item to be queried exists in the preset data table. If it exists, the query is performed based on the preset data table. If it does not exist, the data table can be quickly excluded, and other user-provided data tables that may contain the preset data table can be queried instead. The query method based on the cardinality estimate not only improves the accuracy of the query, but also reduces unnecessary data table scanning, thereby further improving the query efficiency.

[0099] In one feasible implementation, step S40 specifically includes: determining whether the data corresponding to the data item to be queried exists based on the cardinality estimate; and if the data corresponding to the data item to be queried exists, querying the database according to the preset data table to obtain the query data corresponding to the data item to be queried.

[0100] It should be noted that the cardinality estimate can be used to quickly determine whether the data item to be queried exists in the preset data table. Specifically, this can be achieved by comparing the cardinality estimate of the data item to be queried with the set standard value. This embodiment does not impose any specific restrictions on this.

[0101] Understandably, if the data corresponding to the data item to be queried exists in the preset data table of the current query, then the database is queried based on the information of the preset mapping table of the current query, so as to quickly obtain the query data corresponding to the data item to be queried.

[0102] It is worth noting that if the data corresponding to the data item to be queried does not exist in the current preset data table, the current data table can be quickly excluded, and other preset data tables provided by the user can be queried instead, until all preset data tables provided by the user have been queried. The above method can significantly reduce the time required for querying, because once it is determined that the data item to be queried does not exist in a certain data table, further searching of that table can be stopped immediately, and the next possible data table can be searched instead. This not only improves query efficiency, but is also particularly effective when dealing with a large number of data tables.

[0103] In one feasible implementation, determining whether the data corresponding to the data item to be queried exists based on the cardinality estimate includes: comparing the cardinality estimate with a preset value; determining that the data corresponding to the data item to be queried exists when the cardinality estimate is greater than the preset value; and determining that the data corresponding to the data item to be queried does not exist when the cardinality estimate is equal to the preset value.

[0104] It should be noted that in this embodiment, the preset value can be 0. That is, when the cardinality estimate of the data item to be queried is greater than 0, it indicates that data related to the data item to be queried exists in the memory block. Therefore, it can be determined that the data corresponding to the data item to be queried in the current preset data table exists, and the ID and table name of the preset data table are stored. Conversely, if the cardinality estimate is equal to 0, it indicates that there is no data related to the data item to be queried in the memory block, thus it can be determined that the data corresponding to the data item to be queried does not exist. In this way, unnecessary data table scans can be effectively reduced, and the efficiency of data query can be improved.

[0105] In one feasible implementation, the step of querying the database according to the preset data table to obtain the query data corresponding to the data item to be queried when the data corresponding to the data item to be queried exists includes: constructing an SQL query statement according to the table identifier and table name of the preset data table when the data corresponding to the data item to be queried exists; and querying the database according to the SQL query statement to obtain the query data corresponding to the data item to be queried.

[0106] It's important to note that the table identifier, or table ID, is a unique identifier used to identify each data table in a database, while the table name is the name used to identify the data table within the database. An SQL query statement is a structured query language statement used for database queries; it can retrieve specific data from the database based on the user's needs.

[0107] Understandably, in this implementation, after constructing the SQL query statement, the statement will be executed to extract records from the database that match the data item to be queried. The query results will be returned to the user to satisfy their data query needs. The constructed SQL query statement can efficiently retrieve the required data from the database, thereby quickly responding to the user's query request. Furthermore, since the existence of the data has been confirmed through cardinality estimation before the query, invalid query operations can be avoided, further improving query efficiency.

[0108] This embodiment provides a data query method. This embodiment first responds to a user's data query command, determines the data item to be queried based on the data query command; locates the corresponding memory block according to the data item to be queried and a preset data table; queries the memory block for the cardinality estimate corresponding to the data item to be queried; and queries the database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried. This method can effectively improve data query efficiency while saving data storage costs.

[0109] In summary, this embodiment determines the data item to be queried based on the user's data query command, then quickly locates the corresponding memory block based on the data item and the preset data table, and queries the cardinality estimate corresponding to the data item in the memory block. This eliminates the need to create an index for each data table, effectively saving storage costs. Furthermore, it quickly determines whether corresponding data exists in the preset data table based on the cardinality estimate and performs a data query. This allows for rapid retrieval of the corresponding data table, effectively improving data query efficiency. It overcomes the technical shortcomings of creating an index for each data table, which requires a large amount of storage space, leading to high data storage costs, and the low efficiency of data querying with an index. Therefore, it effectively improves data query efficiency while saving data storage costs.

[0110] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 Step S20 further includes steps S201-S202:

[0111] Step S401: Obtain the table identifier and table name of the preset data table.

[0112] It should be noted that the table identifier and table name of the preset data table can be obtained through the preset data table configuration file or directly queried through the database management system. The table identifier and table name of the preset data table can accurately locate the corresponding memory block.

[0113] Step S402: Locate the corresponding memory block based on the data item to be queried, the table identifier, and the table name.

[0114] It should be noted that the corresponding memory block refers to the memory block associated with the preset data table being queried. Each memory block may map data from different data tables. By locating a specific memory block, the data stored within can be quickly accessed and processed, thereby speeding up the query process.

[0115] Understandably, locating a memory block can be achieved using its memory address, where the memory address is a unique identifier for each storage unit in memory. By using the memory address, a specific memory block can be accessed precisely, thus enabling rapid location.

[0116] In one feasible implementation, step S202 may include: performing hash processing on the data item to be queried, the table identifier, and the table name to obtain a first hash value; and matching the first hash value with the memory addresses of multiple pre-divided memory blocks to obtain the memory block corresponding to the preset data table.

[0117] It should be noted that the first hash value is the result obtained by processing the data item to be queried, the table identifier, and the table name using a hash algorithm. Hash algorithms can convert input data of arbitrary length into a fixed-length output, typically used for fast lookups and data integrity verification. Through hash processing, complex query conditions can be transformed into simple hash values, thereby simplifying the process of locating memory blocks. After matching the hash value with the memory address of the memory block, the memory block corresponding to the preset data table can be quickly determined, enabling efficient data retrieval.

[0118] Understandably, before performing a data search, a certain amount of memory space is divided into multiple memory blocks, each corresponding to a specific memory address. Different data tables can map data to the same memory block or to different memory blocks. This method of memory block partitioning allows for flexible processing of data from different data tables while maintaining query efficiency. The size of the memory blocks can be adjusted according to the size of the data table and the query frequency to achieve optimal performance.

[0119] In one feasible implementation, the step of hashing the data item to be queried, the table identifier, and the table name to obtain a first hash value includes: combining the data item to be queried, the table identifier, and the table name into a string; obtaining an initial offset base and a hash constant; and performing XOR and multiplication operations on each character in the string sequentially based on the initial offset base and the hash constant to obtain the first hash value.

[0120] It should be noted that in this embodiment, the hashing process is implemented using the FNV hash algorithm. The FNV hash algorithm is a non-cryptographic hash function that generates a hash value by treating the input data as a series of characters and performing XOR and multiplication operations on these characters.

[0121] It is understandable that the initial offset base, i.e., the initial hash value, and the hash constant, i.e., the FNV prime, are specific numerical values ​​used for hash calculation. In the FNV hash algorithm, the initial offset base is typically used to initialize the hash value, while the hash constant is used to update the hash value after each character processing. This ensures that even if the order of the input data changes, the final hash value still has a high degree of uniqueness, thereby reducing the possibility of hash collisions. Different offset bases and FNV prime values ​​exist for different bit widths (e.g., 32-bit and 64-bit). For example, for a 32-bit FNV hash, the offset base is 2166136261, and the FNV prime is 16777619; for a 64-bit FNV hash, the offset base is 14695981039346656037, and the FNV prime is 1099511628211. This embodiment does not impose specific limitations on these values.

[0122] Understandably, the first hash value, fnv(data item_table name_id), combines the data item to be queried, the table identifier, and the table name into a single string. For each byte b in the string, the initial offset base hash is XORed with b, the hash is multiplied by the FNV prime number, and the final fnv(data item_table name_id) is returned. For example, if the data item to be queried is zhsngsan, the table name is persion, and the table id is 10, then fnv(data value_table name_id) = 744227134.

[0123] It's worth noting that because FNV has a relatively low collision rate, using fnv(data item_table name_id) as the primary key allows for quick data retrieval.

[0124] In this embodiment, by calculating a hash value based on the data item to be queried, the table identifier, and the table name, the memory block corresponding to the preset data table can be quickly and accurately located based on the calculated hash value, thereby effectively improving the data query efficiency.

[0125] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Before step S20, steps S01-S03 are also included:

[0126] Step S01: Divide the preset memory space into multiple memory blocks.

[0127] It should be noted that the preset memory space can be a memory space capable of storing a preset amount of data, such as 120MB of memory. This embodiment does not impose specific limitations on this. Dividing the preset memory space into multiple memory blocks is to optimize data storage and retrieval efficiency. Each memory block can independently store and manage data, which can reduce conflicts and waiting time during data retrieval.

[0128] In the specific implementation, 120MB of memory is created and divided into 10 memory blocks, each 12MB. This represents the value error and data size that HyperLogLog theory can handle. The HLL algorithm can estimate very large cardinality within a relatively small amount of memory. The accuracy of HLL mainly depends on the number of registers (m) it uses internally, and the total memory space occupied by these registers determines the level of accuracy the algorithm can achieve. Considering a 12MB memory space, HLL typically uses multiple registers to store the maximum length of a specific hash value. Assuming each register occupies 1 byte (in reality, registers may occupy less space, such as 4 or 5 bits), then 12MB of space can support 12 × 1024 × 1024 = 12,288,000 registers. If each register occupies 1 byte, then there are approximately 12,288,000 registers. The standard error of HLL can be determined by... The calculation is performed, where m is the number of registers. Therefore, for 12MB of space, the error is ≈0.0003, or about 0.03%, meaning that in 12MB of memory, HLL can estimate cardinality with an error in the range of approximately ±0.03%. As for the maximum cardinality that HLL can handle, HLL using 12MB of memory is more likely to be used to estimate cardinality in the range of millions to billions while maintaining high accuracy.

[0129] It's worth noting that, taking MySQL as an example, with 10 million records, 10 fields, each with a length of varchar(32), and all indexed using the InnoDB engine and UTF-8 encoding, creating a global index requires 10GB of space (assuming a standard mechanical hard drive and 20GB of memory). The estimated search time for some indexes in memory is [1s, 10s]. Assuming a project with 5 tables, requiring 50GB of index space, the maximum estimated search time is [5s, 50s]. However, using this solution: assuming each record is unique, for 100 million records, the first block (12MB) is sufficient for storage. The search time for `hyperloglog(value)` to the corresponding memory block is estimated at 10-50µs. Retrieving the primary key from MySQL takes 10ms-100ms. Therefore, this solution effectively improves data query efficiency.

[0130] Step S02: Obtain the data table to be stored.

[0131] It should be noted that the data table to be stored refers to the data table that needs to be mapped into memory. This data table can be queried through the database management system or specified by the user. During the process of retrieving the data table, its structure and content need to be checked to ensure that the data can be correctly mapped into memory blocks, thereby ensuring data accuracy and efficient querying.

[0132] Step S03: Map the data in the data table to be stored to target memory blocks in the multiple memory blocks.

[0133] It's important to note that during the process of mapping data to memory blocks, ensuring the uniqueness and consistency of the data is crucial. A hash table-based mapping mechanism can be employed. When a data item needs to be stored, its hash value is first calculated, and then the data item is allocated to the corresponding memory block based on the hash value. This mechanism effectively distributes data items, reduces conflicts between memory blocks, and thus improves the efficiency of data storage and retrieval.

[0134] Understandably, the design of the data structure within the memory block is crucial during the data mapping process. To quickly retrieve cardinality estimates, hash tables, B-trees, or other efficient data structures can be used within the memory block to optimize data storage and retrieval efficiency. Hash tables map data items to specific locations within the memory block using hash functions, while B-trees are self-balancing tree data structures that maintain data order, thereby optimizing the performance of lookup, sequential access, insertion, and deletion operations. Choosing an appropriate data structure can significantly improve query speed, especially when processing large amounts of data.

[0135] In one feasible implementation, step S03 may include: performing hash processing based on the data table to be stored to generate a second hash value; obtaining the memory address of each memory block; and determining the target memory block among the multiple memory blocks based on the second hash value and the memory address of each memory block.

[0136] It should be noted that the method of generating the second hash value by hashing the data table to be stored is the same as the method of generating the first hash value. The same method is to calculate fnv (data item_table name_id in the data table to be stored) using the FNV algorithm. This embodiment will not be described in detail here.

[0137] Understandably, the generation of the second hash value is to ensure that data items are evenly distributed across memory blocks, reducing data collisions and improving data retrieval efficiency. Through hashing, each data item is allocated to a specific memory block, enabling fast location and access. Obtaining the memory address of the memory block is to determine which specific memory block the data table should be mapped to, ensuring that the location of data items in memory is predictable, thereby speeding up data retrieval. Once the target memory block is determined, the data table can be mapped to the corresponding memory block, achieving efficient data storage and retrieval.

[0138] In one feasible implementation, determining the target memory block among multiple memory blocks based on the second hash value and the memory addresses of each memory block includes: obtaining the data storage volume and base address of the memory block; determining the target memory address according to the second hash value, the data storage volume, and the base address; matching the target memory address with the memory addresses of each memory block to obtain a matching memory address; and using the memory block corresponding to the matching memory address as the target memory block.

[0139] It should be noted that since the preset memory space is divided into multiple blocks, the data storage amount and base address of each memory block are consistent. In this embodiment, the data storage amount of each memory block, i.e., the size of each memory block, is 12MB, and the base address is 0x1000. This embodiment does not impose specific limitations on this.

[0140] Understandably, after obtaining the second hash value, a modulo operation is needed to obtain the memory block number. Then, the target memory address is determined based on the memory block number, the second hash value, the data storage size, and the base address. If the second hash value is 744227134, the memory block number is index = 744227134 % 10, the data storage size is block_size = 12 * 1024 * 1024, and the base address is base_address = 0x1000, then the target memory address is start_address = base_address + index * block_size.

[0141] like Figure 4 As shown, Figure 4 This is a schematic diagram of memory blocks. The diagram includes multiple memory blocks, each corresponding to its own memory address, such as the initial address, memory block 0 address, memory block 1 address, and end address.

[0142] It's worth noting that by matching the target memory address with the memory addresses of each memory block, it can be ensured that data items are accurately mapped to the correct memory block. This mapping mechanism not only improves the efficiency of data retrieval but also simplifies memory management because the size of the memory blocks is fixed. Each memory block can be read and written independently, which helps reduce latency caused by data access conflicts.

[0143] In this embodiment, by dividing the preset memory space into multiple memory blocks, the efficiency of data storage and retrieval can be optimized. Each memory block can independently store and manage data, which can reduce conflicts and waiting time during data retrieval. This allows data in the data table to be stored to be mapped to the corresponding target memory block, effectively distributing data items, reducing conflicts between memory blocks, and thus improving the efficiency of data storage and retrieval.

[0144] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the data query method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0145] This application also provides a data query device, please refer to... Figure 5 The data query device includes:

[0146] The determination module 10 is used to determine the data item to be queried based on the user's data query instruction.

[0147] The positioning module 20 is used to locate the corresponding memory block based on the data item to be queried and the preset data table.

[0148] The query module 30 is used to query the cardinality estimate corresponding to the data item to be queried in the memory block.

[0149] The query module 30 is also used to query the database based on the base estimate and the preset data table to obtain the query data corresponding to the data item to be queried.

[0150] This embodiment provides a data query device. Responding to a user's data query command, this embodiment determines the data item to be queried based on the data query command; locates the corresponding memory block according to the data item to be queried and a preset data table; queries the memory block for the cardinality estimate corresponding to the data item to be queried; and queries the database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried. This effectively improves data query efficiency while saving data storage costs.

[0151] In summary, this embodiment determines the data item to be queried based on the user's data query command, then quickly locates the corresponding memory block based on the data item and the preset data table, and queries the cardinality estimate corresponding to the data item in the memory block. This eliminates the need to create an index for each data table, effectively saving storage costs. Furthermore, it quickly determines whether corresponding data exists in the preset data table based on the cardinality estimate and performs a data query. This allows for rapid retrieval of the corresponding data table, effectively improving data query efficiency. It overcomes the technical shortcomings of creating an index for each data table, which requires a large amount of storage space, leading to high data storage costs, and the low efficiency of data querying with an index. Therefore, it effectively improves data query efficiency while saving data storage costs.

[0152] Optionally, the positioning module 20 is further configured to obtain the table identifier and table name of a preset data table; and locate the corresponding memory block according to the data item to be queried, the table identifier, and the table name.

[0153] Optionally, the positioning module 20 is further configured to perform hash processing on the data item to be queried, the table identifier, and the table name to obtain a first hash value; and match the first hash value with the memory addresses of multiple pre-divided memory blocks to obtain the memory block corresponding to the preset data table.

[0154] Optionally, the positioning module 20 is further configured to combine the data item to be queried, the table identifier, and the table name into a string; obtain the initial offset base and hash constant; and perform XOR and multiplication operations on each character in the string based on the initial offset base and the hash constant to obtain a first hash value.

[0155] Optionally, the query module 30 is further configured to determine whether the data corresponding to the data item to be queried exists based on the cardinality estimate; and when the data corresponding to the data item to be queried exists, to query the database based on the preset data table to obtain the query data corresponding to the data item to be queried.

[0156] Optionally, the query module 30 is further configured to compare the estimated cardinality with a preset value; when the estimated cardinality is greater than the preset value, determine that the data corresponding to the data item to be queried exists; when the estimated cardinality is equal to the preset value, determine that the data corresponding to the data item to be queried does not exist.

[0157] Optionally, the query module 30 is further configured to, when the data corresponding to the data item to be queried exists, construct an SQL query statement based on the table identifier and table name of the preset data table; query the database based on the SQL query statement to obtain the query data corresponding to the data item to be queried.

[0158] Optionally, the data query device further includes a mapping module, which is used to divide a preset memory space into multiple memory blocks; obtain a data table to be stored; and map the data in the data table to be stored to target memory blocks in the multiple memory blocks.

[0159] Optionally, the mapping module is further configured to perform hash processing based on the data table to be stored to generate a second hash value; obtain the memory address of each memory block; and determine the target memory block among the multiple memory blocks based on the second hash value and the memory address of each memory block.

[0160] Optionally, the mapping module is further configured to obtain the data storage volume and base address of the memory block; determine the target memory address based on the second hash value, the data storage volume and the base address; match the target memory address with the memory addresses of each memory block to obtain a matching memory address; and use the memory block corresponding to the matching memory address as the target memory block.

[0161] The data query device provided in this application, employing the data query method described in the above embodiments, can solve the technical problems of high data storage costs and low efficiency in data querying due to the large amount of storage space required to create indexes for each data table. Compared with the prior art, the beneficial effects of the data query device provided in this application are the same as those of the data query method provided in the above embodiments, and other technical features in the data query device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0162] This application provides a data query device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the data query method in Embodiment 1 above.

[0163] The following is for reference. Figure 6 The diagram illustrates a structural schematic of a data query device suitable for implementing embodiments of this application. The data query device in this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6The data query device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0164] like Figure 6 As shown, the data query device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the data query device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the data query device to communicate wirelessly or wiredly with other devices to exchange data. Although the figures show data query devices with various systems, it should be understood that it is not required to implement or possess all of the systems shown. More or fewer systems may be implemented alternatively.

[0165] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0166] The data query device provided in this application, employing the data query method described in the above embodiments, can solve the technical problems of high data storage costs and low efficiency in data querying due to the large amount of storage space required to create indexes for each data table. Compared with the prior art, the beneficial effects of the data query device provided in this application are the same as those of the data query method provided in the above embodiments, and other technical features of this data query device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0167] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0168] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that cannot be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0169] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the data query method described in the above embodiments.

[0170] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0171] The aforementioned computer-readable storage medium may be included in the data query device; or it may exist independently and not assembled into the data query device.

[0172] The aforementioned computer-readable storage medium carries one or more programs. When the one or more programs are executed by a data query device, the data query device causes the data query device to: respond to a user's data query instruction, determine a data item to be queried based on the data query instruction; locate the corresponding memory block according to the data item to be queried and a preset data table; query the cardinality estimate corresponding to the data item to be queried in the memory block; and query the database based on the cardinality estimate and the preset data table to obtain the query data corresponding to the data item to be queried.

[0173] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0174] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0175] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0176] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described data query method. This solves the technical problem that creating an index for each data table requires a large amount of storage space, resulting in high data storage costs and low efficiency in data querying. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the data query method provided in the above embodiments, and will not be repeated here.

[0177] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the data query method described above.

[0178] The computer program product provided in this application can solve the technical problems of high data storage costs and low efficiency in data querying due to the large amount of storage space required to create indexes for each data table. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the data query method provided in the above embodiments, and will not be repeated here.

[0179] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

[0180] This invention discloses A1. A data query method, the method comprising:

[0181] In response to a user's data query command, determine the data item to be queried based on the data query command;

[0182] Locate the corresponding memory block based on the data item to be queried and the preset data table;

[0183] Query the cardinality estimate corresponding to the data item to be queried in the memory block;

[0184] Based on the estimated base value and the preset data table, the database is queried to obtain the query data corresponding to the data item to be queried.

[0185] A2. The method as described in A1, wherein locating the corresponding memory block based on the data item to be queried and the preset data table includes:

[0186] Retrieve the table identifier and table name of the preset data table;

[0187] The corresponding memory block is located based on the data item to be queried, the table identifier, and the table name.

[0188] A3. The method as described in A2, wherein locating the corresponding memory block based on the data item to be queried, the table identifier, and the table name includes:

[0189] A first hash value is obtained by performing hash processing on the data item to be queried, the table identifier, and the table name;

[0190] The memory blocks corresponding to the preset data table are obtained by matching the first hash value with the memory addresses of multiple pre-divided memory blocks.

[0191] A4. The method described in A3, wherein the step of performing hash processing based on the data item to be queried, the table identifier, and the table name to obtain a first hash value includes:

[0192] Combine the data item to be queried, the table identifier, and the table name into a string;

[0193] Obtain the initial offset base and hash constant;

[0194] Based on the initial offset base and the hash constant, each character in the string is sequentially XORed and multiplied to obtain the first hash value.

[0195] A5. As described in A1, the step of querying the database based on the estimated base value and the preset data table to obtain the query data corresponding to the data item to be queried includes:

[0196] Determine whether the data corresponding to the data item to be queried exists based on the estimated cardinality value;

[0197] When the data corresponding to the data item to be queried exists, the database is queried according to the preset data table to obtain the query data corresponding to the data item to be queried.

[0198] A6. As described in A5, the step of determining whether the data corresponding to the data item to be queried exists based on the cardinality estimate includes:

[0199] Compare the estimated base value with the preset value;

[0200] When the estimated base value is greater than the preset value, it is determined that the data corresponding to the data item to be queried exists;

[0201] When the estimated base value is equal to the preset value, it is determined that the data corresponding to the data item to be queried does not exist.

[0202] A7. The method described in A5, wherein when the data corresponding to the data item to be queried exists, querying the database according to the preset data table to obtain the query data corresponding to the data item to be queried includes:

[0203] When the data corresponding to the data item to be queried exists, construct an SQL query statement based on the table identifier and table name of the preset data table;

[0204] The database is queried according to the SQL query statement to obtain the query data corresponding to the data item to be queried.

[0205] A8. The method as described in A1, before locating the corresponding memory block based on the data item to be queried and the preset data table, further includes:

[0206] Divide the preset memory space into multiple memory blocks;

[0207] Retrieve the data table to be stored;

[0208] The data in the data table to be stored is mapped to target memory blocks in multiple memory blocks.

[0209] A9. The method as described in A8, wherein storing the data table to be stored into a target memory block among the multiple memory blocks includes:

[0210] A second hash value is generated based on the data table to be stored.

[0211] Obtain the memory address of each memory block;

[0212] The target memory block among the multiple memory blocks is determined based on the second hash value and the memory address of each memory block.

[0213] A10. The method as described in A9, wherein determining the target memory block among multiple memory blocks based on the second hash value and the memory address of each of the memory blocks includes:

[0214] Obtain the data storage size and base address of the memory block;

[0215] The target memory address is determined based on the second hash value, the amount of data stored, and the base address;

[0216] The target memory address is matched with the memory addresses of each memory block to obtain the matching memory address;

[0217] The memory block corresponding to the matched memory address is taken as the target memory block.

[0218] The present invention also discloses B11. A data query device, the data query device comprising:

[0219] The determination module is used to determine the data item to be queried based on the user's data query instruction in response to the data query instruction;

[0220] The positioning module is used to locate the corresponding memory block based on the data item to be queried and the preset data table;

[0221] The query module is used to query the cardinality estimate corresponding to the data item to be queried in the memory block;

[0222] The query module is also used to query the database based on the estimated base value and the preset data table to obtain the query data corresponding to the data item to be queried.

[0223] B12. The device as described in B11, wherein the positioning module is further configured to obtain the table identifier and table name of a preset data table;

[0224] The corresponding memory block is located based on the data item to be queried, the table identifier, and the table name.

[0225] B13. The apparatus as described in B12, wherein the positioning module is further configured to perform hash processing based on the data item to be queried, the table identifier, and the table name to obtain a first hash value;

[0226] The memory blocks corresponding to the preset data table are obtained by matching the first hash value with the memory addresses of multiple pre-divided memory blocks.

[0227] B14. The apparatus as described in B13, wherein the positioning module is further configured to combine the data item to be queried, the table identifier, and the table name into a string;

[0228] Obtain the initial offset base and hash constant;

[0229] Based on the initial offset base and the hash constant, each character in the string is sequentially XORed and multiplied to obtain the first hash value.

[0230] B15. The apparatus as described in B11, wherein the query module is further configured to determine whether the data corresponding to the data item to be queried exists based on the cardinality estimate;

[0231] When the data corresponding to the data item to be queried exists, the database is queried according to the preset data table to obtain the query data corresponding to the data item to be queried.

[0232] B16. The apparatus as described in B15, wherein the query module is further configured to compare the estimated base value with a preset value;

[0233] When the estimated base value is greater than the preset value, it is determined that the data corresponding to the data item to be queried exists;

[0234] When the estimated base value is equal to the preset value, it is determined that the data corresponding to the data item to be queried does not exist.

[0235] B17. The apparatus as described in B15, wherein the query module is further configured to construct an SQL query statement based on the table identifier and table name of the preset data table when the data corresponding to the data item to be queried exists;

[0236] The database is queried according to the SQL query statement to obtain the query data corresponding to the data item to be queried.

[0237] B18. The apparatus as described in B11, wherein the data query apparatus further includes a mapping module, the mapping module being used to divide a preset memory space into multiple memory blocks;

[0238] Retrieve the data table to be stored;

[0239] The data in the data table to be stored is mapped to target memory blocks in multiple memory blocks.

[0240] The present invention also discloses C19. A data query device, the data query device comprising: a memory, a processor, and a data query program stored in the memory and executable on the processor, the data query program being configured to implement the data query method as described above.

[0241] The present invention also discloses D20. A storage medium storing a data query program, wherein the data query program, when executed by a processor, implements the data query method as described above.

Claims

1. A data query method, characterized by, The method includes: In response to a user's data query command, determine the data item to be queried based on the data query command; Locate the corresponding memory block based on the data item to be queried and the preset data table; Query the cardinality estimate corresponding to the data item to be queried in the memory block; Based on the estimated base value and the preset data table, the database is queried to obtain the query data corresponding to the data item to be queried.

2. The method of claim 1, wherein, The step of locating the corresponding memory block based on the data item to be queried and the preset data table includes: Retrieve the table identifier and table name of the preset data table; The corresponding memory block is located based on the data item to be queried, the table identifier, and the table name.

3. The method of claim 2, wherein, The step of locating the corresponding memory block based on the data item to be queried, the table identifier, and the table name includes: A first hash value is obtained by performing hash processing on the data item to be queried, the table identifier, and the table name; The memory blocks corresponding to the preset data table are obtained by matching the first hash value with the memory addresses of multiple pre-divided memory blocks.

4. The method of claim 3, wherein, The step of performing hash processing based on the data item to be queried, the table identifier, and the table name to obtain a first hash value includes: Combine the data item to be queried, the table identifier, and the table name into a string; Obtain the initial offset base and hash constant; Based on the initial offset base and the hash constant, each character in the string is sequentially XORed and multiplied to obtain the first hash value.

5. The method of claim 1, wherein, The step of querying the database based on the estimated base value and the preset data table to obtain the query data corresponding to the data item to be queried includes: Determine whether the data corresponding to the data item to be queried exists based on the estimated cardinality value; When the data corresponding to the data item to be queried exists, the database is queried according to the preset data table to obtain the query data corresponding to the data item to be queried.

6. The method of claim 5, wherein, The step of determining whether the data corresponding to the data item to be queried exists based on the cardinality estimate includes: Compare the estimated base value with the preset value; When the estimated base value is greater than the preset value, it is determined that the data corresponding to the data item to be queried exists; When the estimated base value is equal to the preset value, it is determined that the data corresponding to the data item to be queried does not exist.

7. The method of claim 5, wherein, When the data corresponding to the data item to be queried exists, the process of querying the database according to the preset data table to obtain the query data corresponding to the data item to be queried includes: When the data corresponding to the data item to be queried exists, construct an SQL query statement based on the table identifier and table name of the preset data table; The database is queried according to the SQL query statement to obtain the query data corresponding to the data item to be queried.

8. A data query apparatus, characterized by comprising: The data query device includes: The determination module is used to determine the data item to be queried based on the user's data query instruction in response to the data query instruction; The positioning module is used to locate the corresponding memory block based on the data item to be queried and the preset data table; The query module is used to query the cardinality estimate corresponding to the data item to be queried in the memory block; The query module is also used to query the database based on the estimated base value and the preset data table to obtain the query data corresponding to the data item to be queried.

9. A data query device, characterized in that, The data query device includes: a memory, a processor, and a data query program stored in the memory and executable on the processor, the data query program being configured to implement the data query method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium stores a data query program, which, when executed by a processor, implements the data query method as described in any one of claims 1 to 7.