A data query method, device, equipment, storage medium and database
By storing data in different data nodes in the vector database and using data partitioning and mapping tables to determine the target node for querying, the problem of insufficient cost and performance of existing vector databases is solved, achieving low-cost storage and high-throughput data query efficiency.
Patent Information
- Application Number
- CN202510645358.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2026-11-20
AI Technical Summary
Existing vector databases are inadequate in terms of cost and performance, resulting in low data query efficiency and an inability to simultaneously achieve low-cost storage and high throughput.
By storing vector data in different data nodes, data partitioning and mapping tables are used to determine the target data node for querying, avoiding redundant caching. Only relevant nodes participate in the query, and similarity and partitioning algorithms are used to optimize the data query process.
It achieves low-cost storage and high-throughput data querying, improves database query efficiency, and avoids redundant caching of vector data.
Smart Images

Figure CN123138293A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, specifically to a data query method, apparatus, device, storage medium, and database. Background Technology
[0002] In the development of large model applications, in order to solve the illusion problem of large models and improve the accuracy, privacy and timeliness of large model inference, vector databases are usually introduced as knowledge bases to enhance the performance of large models after training.
[0003] However, current vector databases generally have shortcomings in terms of cost or performance. That is, current vector databases cannot achieve low-cost storage and high throughput at the same time, resulting in low efficiency when querying data based on current vector databases. Summary of the Invention
[0004] This application provides a data query method, apparatus, device, storage medium, and database, with the aim of improving the query efficiency of the database.
[0005] To achieve the above objectives, this application provides the following technical solution:
[0006] A first aspect of this application provides a data query method, the method comprising:
[0007] Receive a data query request, the data query request including query vector data;
[0008] Determine the target data partition in the first data partition that corresponds to the query vector data, where one first data partition corresponds to one or more vector data;
[0009] The query result is determined based on the target data node and the query vector data. The target data node is the first data node corresponding to the target data partition. The query result includes one or more target vector data. Among them, one first data partition corresponds to one first data node, and the first data node includes one or more vector data. Different first data nodes are used to store different vector data.
[0010] In the above implementation scheme, since different vector data are stored in different first data nodes, and each first data node corresponds to one or more first data partitions, after receiving a data query request, the target data partition corresponding to the query vector data can be determined first. Then, the target data node corresponding to the target data partition can directly retrieve the query vector data to obtain the query results. This allows only some target data nodes related to the data query request to participate in the query during data query, without all data nodes needing to participate. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of vector data. In other words, low-cost storage and high throughput can be achieved simultaneously during data query, thereby improving the database query efficiency.
[0011] In one possible implementation of the first aspect of this application, determining the query result based on the target data node and the query vector data includes:
[0012] The target data node is determined based on the target data partition and the first partition mapping table, wherein the first partition mapping table is used to record the mapping relationship between the first data partition and the first data node;
[0013] The query results are obtained by performing a similarity search on the query vector data based on the target data node.
[0014] In the above implementation scheme, after determining the target data partition corresponding to the query vector, the target data node corresponding to the target data partition can be further determined based on the first partition mapping table that records the mapping relationship between the first data partition and the first data node. The query vector data can be sent to the target data node, which performs a similarity search on the query vector data to obtain the query result corresponding to the query vector data. That is, when performing data query, only some target data nodes related to the data query request need to participate in the query, instead of all data nodes participating in the data query. Furthermore, since the query is performed by the first data node that stores the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of vector data. In other words, low-cost storage and high throughput can be achieved simultaneously during data query, thereby improving the query efficiency of the database.
[0015] In one possible implementation of the first aspect of this application, determining the target data partition in the first data partition corresponding to the query vector data includes:
[0016] The target data partition is determined based on the query vector data and the first partition similarity algorithm, wherein the first partition similarity algorithm is used to calculate the similarity between the first data partitions.
[0017] In the above implementation scheme, after obtaining the query vector data, the target data partition corresponding to the query vector data can be determined based on the first partition similarity algorithm. That is, the first data partition where the vector data similar to the query vector data is located can be determined based on the first partition similarity algorithm. This allows only some target data nodes corresponding to the target data partition to participate in the query when performing data query, instead of all data nodes participating in the data query. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of vector data. In other words, low-cost storage and high throughput can be achieved simultaneously during data query, thereby improving the query efficiency of the database.
[0018] In one possible implementation of the first aspect of this application, the method further includes:
[0019] The first data partition is constructed based on the vector data and the first partitioning algorithm, wherein the first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition;
[0020] The first partition mapping table is constructed based on the first data partition and the first partition distribution algorithm. The first partition distribution algorithm is used to determine the mapping relationship between the first data partition and the first data node.
[0021] In the above implementation scheme, when constructing the first data partition and the first data node, different vector data can be divided into different first data partitions based on the first partitioning algorithm. That is, the first data partition corresponding to each vector data can be determined based on the first partitioning algorithm. Then, the first data node corresponding to the first data partition can be constructed based on the first data partition and the first partition distribution algorithm. That is, the first data node used to store the vector data corresponding to the first data partition can be constructed, so that different vector data can be stored in different data nodes, and different first data partitions can correspond to different first data nodes. This allows only some target data nodes related to the data query request to participate in the query when performing data query, without all data nodes participating in the data query. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of vector data. That is, low-cost storage and high throughput can be achieved simultaneously during data query, thereby improving the query efficiency of the database.
[0022] In one possible implementation of the first aspect of this application, the method further includes:
[0023] A hypergraph segmentation problem is constructed based on the first data partition and the expected query plan. The hypergraph segmentation problem includes at least one of supernodes, superedges, supernode weights, or superedge weights. The supernode is the first data partition. The superedge is determined based on the second data partition. The second data partition is the first data partition that meets the query precision threshold in a single query. The supernode weight is determined based on the data volume of the supernode. The superedge weight is determined based on the query probability of the second data partition.
[0024] The hypergraph segmentation problem is solved based on the expected optimization objective, resulting in the first partitioning distribution algorithm.
[0025] In the above implementation scheme, a pre-set expected query plan can be determined first. Then, a hypergraph partitioning problem can be constructed based on the constructed first data partition and the expected query plan. Finally, the hypergraph partitioning problem can be solved based on the set expected optimization objective to determine the first partition distribution algorithm used to determine the mapping relationship between the first data partition and the first data node. This allows the first data node constructed based on the first partition distribution algorithm to achieve the expected optimization objective, that is, it is possible to determine the first data node corresponding to each first data partition based on the expected optimization objective.
[0026] In one possible implementation of the first aspect of this application, the anticipated optimization objective includes at least one of the following:
[0027] The weights of the supernodes contained in each subgraph are balanced across the subgraphs. A subgraph includes one or more supernodes, and a subgraph corresponds to a first data node.
[0028] Alternatively, in the case of a single query executing the expected query plan, the total amount of data retrieved by all the first data nodes is minimized;
[0029] Alternatively, when executing the expected query plan, the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all the first data nodes is the smallest, and the most loaded data node is the first data node with the largest amount of data retrieved.
[0030] In the above implementation scheme, by balancing the weights of the supernodes in each subgraph, the amount of data carried by each first data node partitioned by the first partitioning algorithm can be made as equal as possible. This avoids situations where one first data node stores a large amount of vector data while other first data nodes store only a small amount. By minimizing the total amount of data retrieved by the first data nodes corresponding to all subgraphs during a single query of the expected query plan, the load on the first data nodes partitioned by the first partitioning algorithm during vector queries can be minimized, thus reducing the load on all first data nodes during a single vector query. By minimizing the difference between the amount of data retrieved by the data node with the highest load and the average amount of data retrieved by all first data nodes during the execution of the expected query plan, the load on the first data nodes partitioned by the first partitioning algorithm during vector queries can be made as balanced as possible. This ensures that the amount of data retrieved by the first data node with the largest expected query volume is as close as possible to the average amount of data retrieved by all first data nodes, avoiding situations where one first data node needs to retrieve a large amount of data while other first data nodes retrieve only a small amount. In other words, by setting the expected optimization goal, the first partition distribution algorithm determined based on the expected optimization goal can reasonably determine the mapping relationship between the first data partition and the first data node, so as to achieve load balancing for each first data node when performing vector queries.
[0031] In one possible implementation of the first aspect of this application, the method further includes:
[0032] Receive data migration requests;
[0033] A third data partition is constructed based on the sampled vector data and the second partitioning algorithm. The second partitioning algorithm is used to determine the mapping relationship between the vector data and the third data partition. The sampled vector data is obtained by sampling the vector data. One third data partition corresponds to one or more sampled vector data.
[0034] The second partition mapping table is constructed based on the third data partition and the second partition distribution algorithm. The second partition distribution algorithm is used to determine the mapping relationship between the third data partition and the second data node. The second partition mapping table is used to record the mapping relationship between the third data partition and the second data node. One third data partition corresponds to one second data node. The second data node is used to store one or more vector data. Different second data nodes are used to store different vector data.
[0035] Data migration is performed on the vector data based on the second partitioning algorithm and the second partitioning mapping table.
[0036] In the above implementation scheme, after receiving the data migration request, the third data partition corresponding to the sampled vector data can be determined based on the second partitioning algorithm. That is, the mapping relationship between the vector data and the new data partition can be determined based on the new second partitioning algorithm. Then, the third data partition can be further allocated to the corresponding second data node based on the second partitioning distribution algorithm. That is, a second data node for storing the vector data corresponding to the third data partition can be constructed, so that different vector data can be stored in different data nodes, and different third data partitions can correspond to different second data nodes. Thus, when the database performs data queries after data migration, only some of the target data nodes related to the data query request need to participate in the query, instead of all data nodes participating in the data query. Moreover, the query is performed by the second data node storing the vector data, so there is no need to cache the vector data locally during data query, avoiding redundant caching of vector data. That is, low-cost storage and high throughput can be achieved simultaneously during data query, thereby improving the query efficiency of the database.
[0037] In one possible implementation of the first aspect of this application, the method further includes:
[0038] Receive a data insertion request, the data insertion request including vector data to be inserted;
[0039] A fourth data partition is determined based on the vector data to be inserted and the first partitioning algorithm. The first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition. The fourth data partition is the first data partition corresponding to the vector data to be inserted.
[0040] The third data node is determined based on the fourth data partition and the first partition mapping table. The first partition mapping table is used to record the mapping relationship between the first data partition and the first data node. The third data node is the first data node corresponding to the fourth data partition.
[0041] The vector data to be inserted is written into the third data node.
[0042] In the above implementation scheme, when a data insertion request including the vector data to be inserted is received, the fourth data partition into which the vector data to be inserted can be determined from the first data partition based on the first partitioning algorithm. Then, based on the first partitioning mapping table that records the mapping relationship between the first data partition and the first data node, the third data node corresponding to the fourth data partition can be determined from the first data node. Finally, the vector data to be inserted can be written into the third data node, thereby avoiding redundant storage of the vector data to be inserted.
[0043] Secondly, embodiments of this application provide a data query device, the device comprising:
[0044] A receiving module is used to receive data query requests, wherein the data query requests include query vector data;
[0045] The determination module is used to determine the target data partition in the first data partition that corresponds to the query vector data, wherein one first data partition corresponds to one or more vector data.
[0046] The determining module is further configured to determine the query result based on the target data node and the query vector data, wherein the target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data; wherein, one first data partition corresponds to one first data node, the first data node includes one or more vector data, and different first data nodes are used to store different vector data.
[0047] The data query apparatus provided in the second aspect of this application can also perform the steps described in the first aspect and various possible implementations, as detailed in the foregoing description of the first aspect and various possible implementations.
[0048] The second aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the second aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.
[0049] Thirdly, embodiments of this application provide a database, the database including a coordinating node and a first data node, the first data node including one or more vector data, different first data nodes being used to store different vector data; wherein, the coordinating node is used to execute the following method:
[0050] The system receives a data query request, which includes query vector data; determines a target data partition in a first data partition that corresponds to the query vector data, wherein one first data partition corresponds to one or more vector data; and determines a query result based on the target data node and the query vector data, wherein the target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data; wherein one first data partition corresponds to one first data node.
[0051] The coordinating node of the database provided in the second aspect of this application can also perform the steps described in the first aspect and various possible implementations, as detailed in the foregoing description of the first aspect and various possible implementations.
[0052] The third aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the third aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.
[0053] Fourthly, embodiments of this application provide a computer device that may include a memory and a processor, wherein the memory is used to store computer programs or computer instructions, and the processor is used to execute the computer programs or computer instructions stored in the memory, so that the computer and device perform the method of the first aspect of the embodiments of this application or any possible implementation thereof.
[0054] Fifthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in the first aspect above.
[0055] In a sixth aspect, embodiments of this application provide a computer program product containing instructions that, when run on a computer, cause the computer to perform the method described in the first aspect above.
[0056] In a seventh aspect, this application provides a chip system including a processor for supporting a prompting processing device in implementing the functions involved in the foregoing aspects, such as transmitting or processing data and / or information involved in the foregoing methods. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the prompting processing device. This chip system may be composed of chips or may include chips and other discrete devices.
[0057] Eighthly, embodiments of this application provide a chip including one or more interface circuits and one or more processors; the interface circuits are used to receive signals from the memory of an electronic device and send signals to the processors, the signals including computer instructions stored in the memory; when the processor executes the computer instructions, it causes the electronic device to perform the task execution method in the first aspect or any possible implementation of the first aspect.
[0058] The eighth aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects corresponding to the eighth aspect and any implementation thereof are similar to those corresponding to the first aspect and any implementation thereof, and will not be repeated here. Attached Figure Description
[0059] Figure 1A An architecture diagram of a database system provided in this application embodiment;
[0060] Figure 1B This is a schematic diagram of the database system structure after decoupling based on microservice components in the embodiments of this application;
[0061] Figure 2 A flowchart illustrating a data query method provided in an embodiment of this application;
[0062] Figure 3 This is a schematic diagram of a hypergraph structure provided in an embodiment of this application;
[0063] Figure 4 A schematic diagram of a database structure provided in an embodiment of this application;
[0064] Figure 5 This is a schematic diagram of the structure of a data query device provided in an embodiment of this application;
[0065] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of this application;
[0066] Figure 7 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation
[0067] This application provides a data query method, apparatus, device, storage medium, and database to improve the query efficiency of the database.
[0068] The embodiments of this application will now be described with reference to the accompanying drawings.
[0069] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0070] The method provided in this application embodiment can be applied to a database system. Figure 1A This application illustrates the architecture of a database system provided in an embodiment, based on... Figure 1A The database system 10 includes a database management system (DBMS) 100, a database 101, and a data storage 103.
[0071] Database 101 is an organized collection of data stored in data storage 103; that is, a related collection of data organized, stored, and used according to a specific data model. Depending on the data model used to organize the data, data can be divided into various types, such as relational data, graph data, and time series data. Relational data is data modeled using a relational model, typically represented as tables, where rows represent a set of related values for an object or entity. Graph data, simply called a "graph," is used to represent relationships between objects or entities, such as social relationships. Time series data, or simply time-series data, is a series of data columns recorded and indexed in chronological order, used to describe the state changes of an object over time.
[0072] The database management system (DBMS) is the core of the database system, serving as system software for organizing, storing, and maintaining data. Client 30 establishes a communication connection with the DBMS via network 20 and can access database 101 through the DBMS. The database administrator (DBA) also uses the DBMS to maintain database 101. The DBMS provides various functions for client 30 to create, modify, and query database 101. Client 30 can be an application or a user device. The functions provided by the database management system may include, but are not limited to, the following: (1) Data definition function: The database management system provides a Data Definition Language (DDL) to define the structure of database 101. DDL is used to describe the database framework and can be stored in the data dictionary; (2) Data access function: The database management system provides a Data Manipulation Language (DML) to implement basic access operations on database 101, such as retrieval, insertion, modification and deletion; (3) Database operation management function: The database management system provides data control function to effectively control and manage the operation of database 101 to ensure that the data is correct and valid; (4) Database creation and maintenance function: This includes loading the initial data of the database, database dumping, recovery, reorganization, system performance monitoring and analysis, etc.; (5) Database transmission: The database management system provides data transmission to realize communication between client 30 and the database management system, which is usually coordinated with the operating system.
[0073] The operation of a database management system depends on necessary hardware and software environments, including but not limited to hardware layer 104 and operating system 102. Hardware layer 104 contains the basic hardware units required for the operation of operating system 102 and the database management system, such as processors, memory, input / output (I / O) devices, and network interface controllers (NICs). Operating system 102 is the system software that manages the hardware units and provides functions such as memory management and thread scheduling.
[0074] The data storage device 103 can be a non-transient computer-readable storage medium such as a hard disk, disk, storage array, storage server, cloud storage, or Storage Area Network (SAN), and is communicatively connected to the computing node where the hardware layer 104 is located. Alternatively, the data storage device 103 can also be integrated into the computing node where the hardware layer 104 is located, and interact with the processor and I / O devices through a bus or other internal communication methods. It should be noted that, in the embodiments of this application, "computing node" refers to an entity that has the hardware resources required to perform data computation and / or storage, such as a physical machine or database server, or an entity that can call hardware resources for computation and / or storage, such as a virtual machine (VM) or container deployed in a physical machine.
[0075] In one embodiment, the functionality of the database management system can be implemented by a processor executing executable code stored in memory. It should be understood that, in various embodiments of the invention, "executable program" should be broadly interpreted to include, but is not limited to: instructions, instruction sets, code, code segments, subroutines, software modules, applications, software packages, threads, processes, functions, firmware, middleware, etc. In one embodiment, the database management system can be software running on a server or virtual machine, with its corresponding code or instructions stored in memory, which, when executed by at least one processor, implements the corresponding functionality.
[0076] Those skilled in the art can understand that a database system may include more than Figure 1A The components shown are fewer or more components, or include those with Figure 1A The components shown are different components. Figure 1A Only components more relevant to the implementation disclosed in the embodiments of the present invention are shown.
[0077] Figure 1B The logical architecture of a database management system according to an embodiment of this application is shown. Figure 1B Database management systems include:
[0078] The database management system includes an application programming interface (API) 110, a job manager 120, a component manager 130, a message communication service 140, an operating system 150, and a memory 103. Furthermore, the database management system also includes multiple database components, which are microservice components, each implementing a specific function of the database management system. In one embodiment, the database components included in the database management system include: a parser service 160, an optimizer service 170, a parser and optimizer combination service 165, an executor service 180, a storage engine service 182, a metadata service 184, a statistics service 186, a self-monitoring service 188, and a clock service 190. The functions of each component of the database management system are further described below:
[0079] Application programming interface 110 is an interface provided to clients for connecting to and accessing the database management system, such as the Java Database Connectivity (JDBC) interface, the Open Database Connectivity (ODBC) interface, and so on.
[0080] The job manager 120 includes a scheduler 121, which selects the optimal execution path from the execution paths provided by the component manager 231 based on user requests from clients, such as queries, and schedules service components to perform corresponding processing based on the optimal execution path. If an error occurs in a microservice component within the execution path, the scheduler 121 schedules an alternative execution path to continue executing the current user request, thereby improving database service availability. The job manager 120 itself can also embed service components such as a parser 122, optimizer 123, executor 124, and storage engine 125. The scheduler 121 can call service components embedded in the job manager 120, as well as service components external to the job manager 120, such as the parser and optimizer combined service 165, and the executor service 180. When calling external service components, a Remote Procedure Call (RPC) method can be used.
[0081] Component Manager 130 is mainly responsible for the management of microservice components, including but not limited to: component registration and deregistration, component start-up and shutdown, component fault tolerance, component upgrade, and component status monitoring. (1) Component registration and deregistration: When adding a new service component, it needs to be registered with Component Manager 130. When deleting a service component, it also needs to be deregistered with Component Manager 130. Component Manager 130 can maintain relevant metadata to record the status, deployment location, and other information of each service component. This ensures that Component Manager 130 knows the available service components in the system and the deployment location of each service component. (2) Component start-up and shutdown: When the system starts, Component Manager 130 starts service components such as metadata service, self-monitoring service, and statistics service according to the hardware configuration. In a distributed scenario, each service component can be started multiple times (the specific number can be configured) for backup. (3) Component fault tolerance: When a service component fails, Component Manager 130 needs to schedule a backup service component to continue executing the current assembly scheme. (4) Component upgrade: Components can be upgraded in rotation. Stateless components can be upgraded at any time. For stateful components, they can only be upgraded when the current task is completed. (5) Component Status Monitoring: Monitor the running status of service components. When a node is added to or removed from the database system, the running status needs to be updated. The running status includes component service status and component cluster status. Component service status refers to the number of tasks executed by each running service component and its resource usage. Component cluster status refers to the running and available service components on each compute node, as well as the resource usage of each compute node.
[0082] The messaging service 140 provides low-latency, high-bandwidth communication capabilities and can be used for communication between microservice components.
[0083] Parser service 160: Its main function is to perform lexical analysis, syntax analysis, and semantic analysis on the input SQL statement and output a query parse tree;
[0084] Optimizer Service 170: Its main function is to process the input query parse tree to generate an execution plan. Its processing logic includes query rewriting, path generation, cost model evaluation, optimal path selection, and execution plan tree generation.
[0085] Executer Service 180: Responsible for reading data from the storage engine, processing the data according to the execution plan, and returning it to the client;
[0086] Storage Engine Service 182: Its main function is to ensure persistent storage of data, provide efficient data access capabilities, and realize the atomicity, consistency, isolation, and durability (ACID) capabilities of the database.
[0087] Metadata Service 184: Primarily provides persistent storage of metadata and efficient metadata access capabilities;
[0088] Statistics Service 186: Primarily responsible for collecting and storing statistical information about tables, including the number of pages, number of rows, and value distribution information for each column;
[0089] The self-monitoring service (Instrumentation Service 188) monitors various status data of the database, such as hardware resource usage information (CPU, I / O, memory, network), key performance indicators (KPIs) of each service component of the database, etc.
[0090] Clock Service 190: Provides unique and incremental timestamps with an error typically within 100ns.
[0091] The self-assembly manager, which consists of job manager 120 and component manager 130, is mainly responsible for starting, scheduling and managing component services, running self-assembly algorithms, and realizing the self-assembly of database components.
[0092] In this embodiment, the component manager 130 can also determine one or more service component execution paths (hereinafter referred to as "execution paths") based on system resources, such as generating TOP-N optimal component execution paths. Each component execution path indicates multiple microservice components that are executed in an orderly manner. These ordered microservice components constitute a complete database management system that can be executed end-to-end. Each microservice component on the execution path can be deployed on different computing nodes.
[0093] In this embodiment, the component manager 130 may include one component manager or multiple component manager clients. Each component manager client is deployed on a single computing node (physical machine or virtual machine) and implements functions such as component registration, component deregistration, component start / stop, component resource management, and component upgrade on that node. In the entire database management system, multiple component managers can serve as backups, such as three.
[0094] Microservice components can start and run independently. For example, each microservice component can run as one or more instances, where an instance can be a thread. Service components communicate with each other using lightweight communication mechanisms. In one embodiment, multiple microservice components can also be combined into a larger-granularity composite service component, such as... Figure 1B The parser and optimizer combined service 165 shown is a combined service component that includes both parser service and optimizer service functions.
[0095] Microservice components can be deployed independently on bare metal or in containers and support online upgrades. Users or the database kernel can flexibly combine and assemble microservice components to build different types of database management systems based on current business scenarios.
[0096] In one embodiment, the microservice components of a database management system can be deployed in a distributed manner across compute nodes in a data center, or across data centers. The compute nodes in the data center are interconnected via a high-speed network, such as an InfiniBand network. The compute nodes are physical machines or other devices with data processing capabilities. Each compute node contains the basic hardware resources required for the operating system and application operation, such as processors, memory, input / output (I / O) devices, etc. One or more virtual machines (VMs) run on a compute node, and one or more microservice components can be deployed on each VM. Each microservice component can be deployed on a single VM, but it should be understood that multiple microservice components can also be deployed on the same VM.
[0097] In one embodiment, the microservice components of the database management system can also be deployed as an appliance. Each physical machine has one or more microservice components deployed on it, and multiple physical machines can be integrated into a single rack and communicate via a bus, such as a PCI-E bus.
[0098] In one embodiment, microservice components can be dynamically loaded as dynamic link libraries. For example, during the execution of a microservice component, one or more other microservice components that exist in the form of dynamic link libraries can be dynamically loaded.
[0099] In this embodiment, the number of components is only illustrated using the number shown in Figure 1 as an example. It is understood that the number of each component can be set differently as needed, and the specific number of each component is not limited here. For example, Figure 1BThe diagram shows two parser services, two optimizer services, three executor services, and three storage services, while the number of metadata services, statistics services, and accelerator services is one each. Database management systems may also contain multiple types of microservice components with similar functionalities. Taking storage service 180 as an example... Figure 1B The diagram illustrates three types of storage engines: column-oriented, row-oriented, and in-memory. For example, a database management system (DBMS) can simultaneously include multiple types of parser service components, such as parsers for relational queries, graph queries, and time-series queries. Each type of microservice component can be one or more. Based on information from client-submitted queries, such as query type and system load (e.g., the load on each microservice component), the DBMS can automatically select multiple microservice components to assemble into an ordered sequence. This ordered sequence forms a path, and the microservice components indicated by this path are executed sequentially. This enables the DBMS to perform its functions, thereby improving the availability and maintainability of the entire system. Therefore, the core capability of a DBMS is to dynamically select the optimal path (component sequence) and invoke or trigger the components indicated by that path to perform response operations in response to queries. In one embodiment, selecting the optimal path and invoking components to perform operations can be implemented by the component manager 130 and the job manager 120, respectively. In another embodiment, the job manager 120 and the component manager 130 can also be integrated into a large functional unit, such as a self-assembly manager. The self-assembly manager can also serve as a service component of a database management system, independent of the microservice components involved in the execution process. It serves as the input that guides the execution process, using the results of database execution as feedback to continue reinforcing learning and updating its own model.
[0100] After receiving a query command, the database management system (DBMS) determines how its various service components are combined and assembled—that is, which components are selected and in what order (path) to respond to the query command. This can be achieved through reinforcement learning (RL), search algorithms, and generative adversarial networks (GANs) to select the optimal path (a sequence of components responding to the query command) for that specific query command.
[0101] A vector database is a database system specifically designed for storing, retrieving, and managing high-dimensional vector data. It uses vector embedding technology to convert data, such as text, images, audio, and video, into numerical vectors, and utilizes similarity calculations between vectors, such as cosine similarity and Euclidean distance, to efficiently perform tasks such as search, recommendation, classification, and clustering.
[0102] Vector data refers to unstructured or semi-structured data such as text, images, and audio, which are transformed into numerical vector representations in a high-dimensional space through specific algorithms, such as word embedding and sentence embedding. This representation allows data to be processed and analyzed more effectively by computers, especially in fields such as natural language processing, computer vision, and recommendation systems. The characteristics of vector data include high dimensionality, numerical representation, and rich semantics. High dimensionality means that vector data is usually located in a high-dimensional space, such as hundreds or even thousands of dimensions. This high dimensionality allows vectors to capture complex features and semantic information of the data. Numerical representation means that vector data consists of numerical values, which allows computers to perform mathematical operations on it, such as addition, subtraction, and dot product. Rich semantics means that through training, vectors can capture the semantic relationships between data. For example, in text data, sentences with similar semantics will be close together in the vector space.
[0103] The core concepts of vector databases include vector embedding and similarity calculation. Vector embedding is the process of converting unstructured data into numerical vectors; similarity calculation methods can include cosine similarity, Euclidean distance, and inner product. Key features of vector databases include efficient retrieval, scalability, and hybrid indexing. Typical application scenarios for vector databases include semantic search, recommender systems, image / video retrieval, natural language processing, and anomaly detection.
[0104] Currently, the two mainstream vector databases are Milvus and Pinecone. Milvus primarily comprises a coordination service, worker nodes, object storage, and message queues. In the coordination service, the root coordination service handles Data Definition Language (DDL) and Data Control Language (DCL) requests; the query coordination service handles load balancing for query nodes; and the data coordination service manages background data operations for data nodes and index nodes. In the worker nodes, query nodes load historical data from object storage and subscribe to incremental data to perform vector retrieval operations; data nodes subscribe to incremental data, package log snapshots, and store them in object storage; and index nodes create indexes. Pinecone includes an API (Application Programming Interface) gateway, control plane, data plane, and object storage. The API gateway acts as the request entry point, handling service authentication and request routing; the control plane handles management requests; the data plane handles index read and write operations; and object storage stores the data. Pinecone manages data by dividing it into multiple clusters, with each cluster and its corresponding central vector stored in distributed object storage. During a write operation, vector data is written only to the cluster corresponding to the nearest central vector, and simultaneously to the freshness layer.
[0105] A large model is a deep learning model with a massive number of parameters and powerful learning and generalization capabilities. Its core is to capture complex patterns and relationships through large-scale data training and ultra-large-scale computing resources, so as to achieve efficient processing of cross-domain tasks.
[0106] In the development of large-scale model applications, to address the hallucination problem and improve the accuracy, privacy, and timeliness of large-scale model inference, vector databases are typically introduced as knowledge bases to enhance the performance of the trained large-scale model. The hallucination problem refers to the phenomenon where the content generated by the large-scale model appears reasonable and logical, but is inconsistent with real-world facts, logic, or the context of user input, manifesting as fabricated, fictitious, or misleading information.
[0107] However, current vector databases generally suffer from shortcomings in cost or performance. For example, when querying based on the Milvus vector database, Milvus divides a set of data into multiple segments, and then each query node loads an index based on the segments. When a query arrives, it is broadcast to all query nodes. Each node queries its local segments and returns the query results. Finally, the broker aggregates and reduces the results to return the final top-k results. In other words, every query node in the Milvus vector database needs to participate in the processing of every query request. The throughput of the entire database cluster instance is limited by the performance of a single query node, and the overall throughput cannot be improved by scaling up the cluster. Similarly, when querying based on the Pinecone vector database, the query execution node loads the clusters corresponding to the nearest centroid vectors to the query vector from object storage and caches them locally. It then performs vector similarity queries on both the locally cached clusters and the temporary storage area, returning the final top-k results. In other words, when the execution node in the Pinecone vector database queries different query vectors, it may cache the same cluster locally. Since the clusters cached in the execution node need to be stored in memory, the repeated caching of the same cluster will lead to serious resource waste. At the same time, since each query requires the participation of a temporary storage area, this component will also become a performance bottleneck when read and write are frequent.
[0108] Current vector databases cannot simultaneously achieve low-cost storage and high throughput, resulting in low efficiency when querying data based on current vector databases.
[0109] Based on this, embodiments of this application provide a data query method, apparatus, device, storage medium, and database, aiming to improve the query efficiency of the database. It should be noted that this method can be applied to vector databases as well as other types of databases; embodiments of this application do not limit its application to this.
[0110] Figure 2 This is a flowchart illustrating a data query method provided in an embodiment of this application. It should be noted that the data query method provided in this embodiment can be applied to, for example... Figure 3 The database shown can also be applied to other databases, and this application embodiment does not limit this. A data query method provided in this application embodiment includes the following steps:
[0111] 201. Receive data query request.
[0112] Among them, data query requests include query vector data.
[0113] In this embodiment, when there is a query requirement for vector data, query vector data can be sent to the database based on the data query request. This allows the database to perform retrieval or querying based on the query vector data when it receives a data query request carrying the query vector data, thus obtaining the query results. It can be understood that a query vector is a numerical vector representation of an input query, used for efficiently retrieving data items similar to the query in semantics or features. Its core is to map complex queries to a high-dimensional vector space through mathematical modeling, combined with vector database technology to achieve rapid matching. In other words, query vector data can be vector data that requires similarity retrieval.
[0114] For example, when a large model or other device or equipment has a need to query vector data, a data query request carrying query vector data can be sent to the database through an interface with the database. When the database receives the data query request carrying query vector data, it can perform retrieval or query based on the query vector data to obtain the query results of the query vector data, and can return the query results of the query vector data to the large model or other device or equipment through the interface.
[0115] 202. Determine the target data partition in the first data partition that corresponds to the query vector data.
[0116] In this context, a first data partition corresponds to one or more vector data.
[0117] In this embodiment, after determining the query vector data, the database can first perform a similarity search on the query vector data to determine the target data partition corresponding to the query vector data in the first data partition that corresponds to one or more vector data. That is, the database can determine the data partition and vector data to be queried when querying the query vector data. It is understood that the target data partition can be one first data partition or multiple first data partitions. In other words, when performing a similarity search on the query vector data, the database can determine the first data partition most similar to the query vector data as the target data partition, or it can determine multiple first data partitions similar to the query vector data as the target data partition. This embodiment does not limit the scope of the target data partition.
[0118] Specifically, the database can pre-divide one or more stored vector data into corresponding first data partitions, establishing a mapping relationship between each vector data and the first data partition. That is, the first data partition corresponding to each vector data can be determined in advance, such that each vector data corresponds to one first data partition, and each first data partition contains one or more vector data. Furthermore, each first data partition can contain a representation vector, allowing the database to perform similarity retrieval based on the query vector data and the representation vector of each first data partition to determine the target data partition corresponding to the query vector data.
[0119] Data partitioning is a technique that splits large datasets into multiple independent parts according to specific rules, aiming to improve query performance, simplify data management, and optimize resource utilization. Data partitioning can divide the physical storage of tables or indexes into multiple logical units, enabling database systems to process queries in parallel, reduce the scope of data scans, and support independent maintenance operations for specific partitions.
[0120] In one possible implementation of this application embodiment, step 202, determining the target data partition in the first data partition corresponding to the query vector data, includes:
[0121] A1. Determine the target data partition based on the query vector data and the first partition similarity algorithm.
[0122] The first partition similarity algorithm is used to calculate the similarity between the first data partitions.
[0123] In this embodiment, after obtaining the query vector data, the database can invoke a pre-set first partition similarity algorithm and determine the target data partition corresponding to the query vector data based on the first partition similarity algorithm. That is, it can determine the first data partition containing vector data similar to the query vector data, so that only some target data nodes corresponding to the target data partition participate in the query, without all data nodes participating. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the query, avoiding redundant caching of vector data. This achieves both low-cost storage and high throughput during data querying, thereby improving the database's query efficiency. Specifically, each first data partition can contain a representation vector representing the first data partition, allowing the database to perform similarity calculations between the query vector data and the representation vector of each first data partition based on the first partition similarity algorithm to determine the target data partition corresponding to the query vector data.
[0124] It should be noted that the first partition similarity algorithm can be a pre-set algorithm in the database used to calculate the similarity between the first data partitions. The first partition similarity algorithm can be determined based on the first partitioning algorithm; that is, different partitioning algorithms can have different partition similarity algorithms. Specifically, the first partitioning algorithm is used to determine the mapping relationship between vector data and the first data partitions.
[0125] 203. Determine the query results based on the target data nodes and query vector data.
[0126] The target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data. One first data partition corresponds to one first data node, and the first data node includes one or more vector data. Different first data nodes are used to store different vector data.
[0127] In this embodiment, after determining the target data partition corresponding to the query vector data, the database can send the query vector data to the target data node corresponding to the target data partition. The target data node of the target data partition retrieves the query vector data to obtain the query results. That is, when retrieving the query vector data, not all data nodes need to participate in the query; only some target data nodes related to the query vector data in the data query request participate in the query, thereby improving the throughput during data query. Furthermore, since different first data nodes are used to store different vector data, redundant storage is avoided when querying the query vector data, and repeated retrieval of the same vector data is avoided, achieving low-cost storage. In other words, low-cost storage and high throughput can be achieved simultaneously during data query, thereby improving the database query efficiency. The target data node can be one first data node or multiple first data nodes. The query results can include only one target vector data most similar to the query vector data, or they can include multiple target vector data with high similarity to the query vector data. Understandably, after retrieving the query vector data and obtaining multiple vector data similar to the query vector data, the target data node can summarize and prune these vector data to determine the target vector data that is most similar to the query vector data, or determine multiple target vector data that are highly similar to the query vector data.
[0128] Specifically, the database can predetermine the first data node corresponding to each first data partition. That is, each first data partition can be assigned to a corresponding first data node, allowing each first data node to store one or more vector data items corresponding to that first data partition. Since different first data partitions correspond to different vector data, and each first data partition corresponds to a first data node, different first data nodes store different vector data. It should be noted that a data node is the core physical unit in a distributed database or cluster architecture, responsible for the actual storage and processing of data. It is a key component for achieving horizontal scalability, high availability, and fault tolerance in a database system.
[0129] Furthermore, it should be noted that after determining the query results of the query vector data based on the target data node and the query vector data, the database can return the query results to the device or equipment that sent the data query request.
[0130] In one possible implementation of this application embodiment, step 203, determining the query result based on the target data node and query vector data, includes:
[0131] B1. Determine the target data node based on the target data partition and the first partition mapping table.
[0132] The first partition mapping table is used to record the mapping relationship between the first data partition and the first data node.
[0133] In this embodiment, after determining the target data partition corresponding to the query vector, the database can further determine the target data node corresponding to the target data partition based on a first partition mapping table that records the mapping relationship between the first data partition and the first data node. It is understood that when the database pre-determines the first data node corresponding to each first data partition, it can also record the mapping relationship between each first data partition and the first data node in the first partition mapping table, so that after determining the target data partition corresponding to the query vector, the target data node corresponding to the target data partition can be quickly determined based on the first partition mapping table.
[0134] B2. Perform similarity retrieval on the query vector data based on the target data node to obtain the query results.
[0135] In this embodiment, after determining the target data node corresponding to the target data partition based on the first partition mapping table, the query vector data can be sent to the target data node. The target data node then performs a similarity search on the query vector data to obtain the query results corresponding to the query vector data. This means that during data querying, only a subset of the target data nodes related to the data query request need to participate in the query, rather than all data nodes. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the query, avoiding redundant caching of the vector data. This achieves both low-cost storage and high throughput during data querying, thereby improving the database's query efficiency. It is understood that the database can directly send a data query request containing the query vector data to the target data node, so that the target data node can retrieve the query vector data based on the data query request and obtain the query results corresponding to the query vector data. Specifically, the target data node can perform similarity matching between the query vector data and the vector data stored in the target data node to identify multiple vector data that are similar to the query vector data. It can also summarize and prune these vector data to identify a target vector data that is most similar to the query vector data, or identify multiple target vector data that are highly similar to the query vector data.
[0136] In one possible implementation of this application embodiment, the method further includes:
[0137] C1. Construct the first data partition based on vector data and the first partitioning algorithm.
[0138] The first partitioning algorithm is used to determine the mapping relationship between vector data and the first data partition.
[0139] In this embodiment, the database can first divide different vector data into different first data partitions based on a pre-set first partitioning algorithm. That is, it can first determine the first data partition corresponding to each vector data based on the first partitioning algorithm, and thus determine the mapping relationship between vector data and first data partitions. The first partitioning algorithm can be a pre-determined algorithm used by the database to determine the mapping relationship between vector data and first data partitions. Specifically, the database can first perform table creation, that is, it can first construct initial first data partitions based on the first partitioning algorithm and the first partition similarity algorithm, and can store the first partitioning algorithm and the first partition similarity algorithm. Since the table creation operation does not require the participation of vector data, the first partitioning algorithm can use a Locality-Sensitive Hashing (LSH) algorithm independent of vector data, and the first partition similarity algorithm can use the Hamming distance algorithm. The smaller the Hamming distance calculated by the Hamming distance algorithm between two vectors, the closer the two vectors are. After constructing the initial first data partition, the database can further determine the initial first data partition corresponding to each vector data based on the first partitioning algorithm, thereby obtaining the first data partition corresponding to one or more vector data.
[0140] C2. Construct the first partition mapping table based on the first data partition and the first partition distribution algorithm.
[0141] The first partition distribution algorithm is used to determine the mapping relationship between the first data partition and the first data node.
[0142] In this embodiment, after constructing the first data partition, the database can further construct the first data node corresponding to the first data partition based on the first data partition and the first partition distribution algorithm. That is, it can construct a first data node for storing the vector data corresponding to the first data partition, and record the mapping relationship between the first data partition and the first data node in the first partition mapping table. This allows only a portion of the target data nodes related to the data query request to participate in the query during data retrieval, without all data nodes needing to participate. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the query, avoiding redundant caching of the vector data. This achieves both low-cost storage and high throughput during data querying, thereby improving the database's query efficiency. The first partition distribution algorithm can be a pre-determined algorithm used by the database to determine the mapping relationship between the first data partition and the first data node.
[0143] Specifically, the database can first determine the first data node corresponding to each first data partition based on the first partition distribution algorithm. That is, each first data partition can be assigned to a corresponding first data node, and the mapping relationship between each first data partition and its corresponding first data node can be recorded in the first partition mapping table. Finally, based on the first partition mapping table, the vector data corresponding to each first data partition can be written into the first data node corresponding to that first data partition for storage. It is understandable that since different first data partitions correspond to different vector data, and each first data partition corresponds to a first data node, different first data nodes store different vector data. The first partition mapping table can be shown in Table 1 below for example:
[0144] Table 1
[0145] First data partition identifier First data node 0 Data Node 1 1 Data Node 2 2 Data Node 0 ... ... N-1 Data Node 2
[0146] In one possible implementation of this application embodiment, the method further includes:
[0147] D1. Construct a hypergraph partitioning problem based on the first data partition and the expected query plan.
[0148] The hypergraph segmentation problem includes at least one of supernodes, superedges, supernode weights, or superedge weights. A supernode is a first data partition, and a superedge is determined based on a second data partition. The second data partition is a first data partition that meets the query precision threshold in a single query. The supernode weight is determined based on the amount of data in the supernode, and the superedge weight is determined based on the query probability of the second data partition.
[0149] In this embodiment, the database can first determine a pre-set expected query plan, and then construct a hypergraph partitioning problem based on the constructed first data partition and the expected query plan. The expected query plan can be one or more predicted query events that the database may execute in the future; that is, the expected query plan may include one or more predicted expected data query requests, and each expected data query request may carry one or more expected query vector data. It should be noted that the hypergraph partitioning problem is an important problem in graph theory and combinatorial optimization, aiming to partition the vertex set of a hypergraph into several disjoint subsets while satisfying specific constraints and optimizing certain objective functions. The input to the hypergraph partitioning problem can include: a hypergraph H = (V, E), where V is the vertex set and E is the hyperedge set (each hyperedge e ∈ E is a subset of V); the output of the hypergraph partitioning problem can include: partitioning V into k disjoint subsets V1, V2, ..., Vk.
[0150] Specifically, each constructed first data partition can be used as a supernode in the hypergraph segmentation problem. Each first data partition can contain a representation vector, which serves as the representation vector of the supernode. The representation vector can be obtained based on a first partitioning algorithm, such as the k-means algorithm. Then, the first data partitions that meet the query precision threshold (i.e., the second data partitions) and their corresponding supernodes can form a hyperedge in the hypergraph segmentation problem. The weight of each supernode can be determined based on the amount of data contained in the first data partition corresponding to each supernode, i.e., the amount of vector data corresponding to the first data partition. The weight of each hyperedge can also be determined based on the probability that each second data partition constituting the hyperedge may be called during a query, i.e., the query probability. The query precision of the first data partition and the query probability of the second data partition can be determined based on the expected query plan, and the query precision threshold can be set based on the actual situation. This embodiment of the application does not limit this.
[0151] D2. Solve the hypergraph segmentation problem based on the expected optimization objective to obtain the first partitioning distribution algorithm.
[0152] In this embodiment, after constructing the hypergraph partitioning problem, the database can solve the problem based on the desired optimization objective. This allows the determined first partitioning distribution algorithm to partition the hypergraph into subgraphs equal to the number of first data nodes, achieving the desired optimization objective. Each subgraph corresponds to one first data node, and each first data partition on a subgraph is mapped to a first data node. Furthermore, the data on the first data nodes does not overlap, ensuring no data redundancy and minimizing storage costs. The first data nodes constructed based on the first partitioning distribution algorithm also achieve the desired optimization objective, meaning that the first data node corresponding to each first data partition can be determined based on the desired optimization objective. It is understood that the desired optimization objective can be set according to the actual needs of the database, and this embodiment does not limit it.
[0153] For example, the hypergraph constructed in the embodiments of this application can be as follows: Figure 3 As shown in the diagram, each circle represents a supernode. The upper number in the circle represents the supernode's identifier, and the lower number represents the amount of data in the first data partition corresponding to the supernode, which is also the amount of vector data in the first data partition. The dashed circle represents a superedge centered on supernode 6, connecting supernodes 4, 5, and 6. The first data partition corresponding to supernode 6 contains 7 data items, meaning the superedge weight can be 7.
[0154] In one possible implementation of the embodiments of this application, it is anticipated that at least one of the following objectives will be optimized:
[0155] The weights of the supernodes contained in each subgraph are balanced across the subgraphs. A subgraph contains one or more supernodes, and a subgraph corresponds to a first data node.
[0156] Alternatively, in the case of a single query executing the expected query plan, the total amount of data retrieved by all first data nodes is minimized;
[0157] Alternatively, in the case of executing the expected query plan, the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all first data nodes is the smallest, and the most loaded data node is the first data node that retrieves the largest amount of data.
[0158] In this embodiment, the expected optimization objective includes balancing the supernode weights of each subgraph among the subgraphs. This means minimizing the difference in data volume between each subgraph and other subgraphs, ensuring that the amount of vector data within the first data partitions of different subgraphs is as similar as possible, and that the amount of vector data stored in the first data nodes corresponding to different subgraphs is as similar as possible. By balancing the supernode weights of each subgraph among the subgraphs, the amount of data carried in each first data node partitioned by the first partitioning algorithm can be made as equal as possible, thus avoiding situations where one first data node stores a large amount of vector data while other first data nodes store only a small amount of vector data.
[0159] The expected optimization objective is to minimize the total amount of data retrieved by all first data nodes in a single query executing the expected query plan. This means minimizing the total amount of vector data requiring similarity retrieval across all first data nodes during a single query within the expected query plan. In other words, it aims to accurately retrieve the required vector data for a single query by retrieving as little vector data as possible. By minimizing the total amount of data retrieved by the first data nodes corresponding to all subgraphs during a single query executing the expected query plan, the load on the first data nodes partitioned by the first partitioning algorithm during vector queries can be minimized, thus reducing the load on all first data nodes during a single vector query.
[0160] The expected optimization objective is to minimize the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all first data nodes when executing the expected query plan. The most loaded data node, defined as the first data node that retrieves the most vector data during the expected query plan, should have its data retrieved as close as possible to the average amount of data determined based on the total amount of data retrieved by all first data nodes during the expected query plan. In other words, the amount of data retrieved by the most loaded data node should be minimized. By minimizing the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all first data nodes during the expected query plan, the load on the first data nodes, as determined by the first partitioning algorithm, during vector queries can be made as balanced as possible. This ensures that the amount of data retrieved by the first data node with the largest expected query volume is as close as possible to the average amount of data retrieved by all first data nodes, thus avoiding situations where one first data node retrieves a large amount of data while other first data nodes retrieve only a small amount.
[0161] It is understandable that by setting the expected optimization goal, the first partition distribution algorithm determined based on the expected optimization goal can reasonably determine the mapping relationship between the first data partition and the first data node, so as to achieve load balancing for each first data node when performing vector queries.
[0162] In one possible implementation of this application embodiment, the method further includes:
[0163] E1, Receive data migration request.
[0164] E2. Construct a third data partition based on the sampled vector data and the second partitioning algorithm.
[0165] The second partitioning algorithm is used to determine the mapping relationship between vector data and the third data partition. The sampled vector data is obtained by sampling the vector data, and one third data partition corresponds to one or more sampled vector data.
[0166] In this embodiment, when the database cluster needs to be expanded or shrunk, or when the load is uneven due to the skew of vector data corresponding to the first data partition, the vector data in the database can be redistributed, i.e., the database can be migrated. The database can first receive a data migration request, and then sample the vector data in the database to obtain sampled vector data. After determining the sampled vector data, different sampled vector data can be divided into different third data partitions based on a pre-determined second partitioning algorithm. That is, the third data partition corresponding to each sampled vector data can be determined first based on the second partitioning algorithm, and the mapping relationship between the sampled vector data and the third data partition can be determined first based on the second partitioning algorithm. The second partitioning algorithm can be a pre-determined algorithm used by the database to determine the mapping relationship between vector data and the third data partition. Specifically, the database can first perform a table creation operation, i.e., it can first construct the initial third data partition based on the second partitioning algorithm and the second partition similarity algorithm, and can store the second partitioning algorithm and the second partition similarity algorithm. Since the table creation operation does not require the participation of sampled vector data, the second partitioning algorithm can employ a locality-sensitive hashing algorithm independent of the vector data, and the second partition similarity algorithm can use the Hamming distance algorithm. After constructing the initial third data partition, the database can further determine the initial third data partition corresponding to each sampled vector data based on the second partitioning algorithm, thereby obtaining a third data partition corresponding to one or more sampled vector data.
[0167] E3. Construct a second partition mapping table based on the third data partition and the second partition distribution algorithm.
[0168] The second partition distribution algorithm is used to determine the mapping relationship between the third data partition and the second data node. The second partition mapping table is used to record the mapping relationship between the third data partition and the second data node. One third data partition corresponds to one second data node. The second data node is used to store one or more vector data. Different second data nodes are used to store different vector data.
[0169] In this embodiment, after constructing the third data partition, the database can further construct the second data node corresponding to the third data partition based on the third data partition and the second partition distribution algorithm. That is, it can construct a second data node for storing the vector data corresponding to the third data partition, and record the mapping relationship between the third data partition and the second data node in the second partition mapping table. The second partition distribution algorithm can be a pre-determined algorithm used by the database to determine the mapping relationship between the third data partition and the second data node. Specifically, the database can first determine the second data node corresponding to each third data partition based on the second partition distribution algorithm; that is, it can assign each third data partition to a corresponding second data node, and record the mapping relationship between each third data partition and the second data node in the second partition mapping table.
[0170] E4. Data migration of vector data is performed based on the second partitioning algorithm and the second partitioning mapping table.
[0171] In this embodiment, the database can first use a second partitioning algorithm to allocate vector data similar to the sampled vector data to the third data partition corresponding to the sampled vector data. That is, the third data partition corresponding to each vector data can be determined first based on the second partitioning algorithm. Then, based on the constructed second partitioning mapping table, the second data node corresponding to each third data partition can be determined, and the vector data corresponding to each third data partition can be written into the second data node corresponding to that third data partition for storage, thereby completing the database data migration and ending the data migration task. It is understood that since different third data partitions correspond to different vector data, and each third data partition corresponds to one second data node, different second data nodes store different vector data.
[0172] In one possible implementation of this application embodiment, the method further includes:
[0173] F1, Receive data insertion request.
[0174] The data insertion request includes the vector data to be inserted.
[0175] F2. Determine the fourth data partition based on the vector data to be inserted and the first partitioning algorithm.
[0176] The first partitioning algorithm is used to determine the mapping relationship between vector data and the first data partition, and the fourth data partition is the first data partition corresponding to the vector data to be inserted.
[0177] In this embodiment, when there is vector data to be inserted into the database, the database can first receive a data insertion request containing the vector data to be inserted. Then, a pre-stored first partitioning algorithm can be invoked to determine the fourth data partition from the first data partition where the vector data to be inserted can be inserted. That is, the fourth data partition corresponding to the vector data to be inserted can be determined by the first partitioning algorithm.
[0178] F3. Determine the third data node based on the mapping table of the fourth data partition and the first partition.
[0179] The first partition mapping table records the mapping relationship between the first data partition and the first data node, and the third data node is the first data node corresponding to the fourth data partition.
[0180] F4. Write the vector data to be inserted into the third data node.
[0181] In this embodiment of the application, after determining the fourth data partition into which the vector data to be inserted can be inserted, a first partition mapping table that records the mapping relationship between the first data partition and the first data node can be called. Then, based on the first partition mapping table, the third data node corresponding to the fourth data partition can be determined from the first data node. Finally, the vector data to be inserted can be written into the third data node, thereby avoiding redundant storage of the vector data to be inserted.
[0182] According to the data query method provided in the embodiments of this application, since different vector data are stored in different first data nodes, and each first data node corresponds to one or more first data partitions, after receiving a data query request, the target data partition corresponding to the query vector data can be determined first, and then the target data node corresponding to the target data partition can directly retrieve the query vector data to obtain the query results. This allows only some target data nodes related to the data query request to participate in the query when performing a data query, without all data nodes participating in the data query. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of the vector data. In other words, low-cost storage and high throughput can be achieved simultaneously during the data query, thereby improving the query efficiency of the database.
[0183] Furthermore, it should be noted that the database mentioned in the above embodiments may refer to the database itself, or to the database management system, or to devices in the database, such as coordination nodes, etc. This application embodiment does not limit these aspects.
[0184] Please see Figure 4This application also provides a database, which may include one or more coordinating nodes and one or more first data nodes. For example, the database may include two coordinating nodes: a primary coordinating node and a backup coordinating node. When the primary coordinating node is in a normal state, only the primary coordinating node can run; when the primary coordinating node is in an abnormal state, only the backup coordinating node 402 can run. The database may also include three first data nodes: first data node 0, first data node 1, and first data node 2.
[0185] Specifically, the first data node includes one or more vector data, that is, the first data node can store one or more vector data, and different first data nodes can be used to store different vector data.
[0186] Specifically, the coordinating node can be used to receive data query requests, which include query vector data; determine the target data partition in the first data partition that corresponds to the query vector data, where one of the first data partitions corresponds to one or more vector data; determine the query result based on the target data node and the query vector data, where the target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data; wherein, one first data partition corresponds to one first data node.
[0187] In one possible implementation of this application embodiment, the coordinating node can specifically be used for:
[0188] The target data node is determined based on the target data partition and the first partition mapping table. The first partition mapping table is used to record the mapping relationship between the first data partition and the first data node.
[0189] The query results are obtained by performing a similarity search on the query vector data based on the target data node.
[0190] In one possible implementation of this application embodiment, the coordinating node can specifically be used for:
[0191] The target data partition is determined based on the query vector data and the first partition similarity algorithm, wherein the first partition similarity algorithm is used to calculate the similarity between the first data partitions.
[0192] In one possible implementation of this application embodiment, the coordinating node can also be used for:
[0193] The first data partition is constructed based on the vector data and the first partitioning algorithm, wherein the first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition;
[0194] The first partition mapping table is constructed based on the first data partition and the first partition distribution algorithm. The first partition distribution algorithm is used to determine the mapping relationship between the first data partition and the first data node.
[0195] In one possible implementation of this application embodiment, the coordinating node can also be used for:
[0196] A hypergraph segmentation problem is constructed based on the first data partition and the expected query plan. The hypergraph segmentation problem includes at least one of supernodes, superedges, supernode weights, or superedge weights. The supernode is the first data partition. The superedge is determined based on the second data partition. The second data partition is the first data partition that meets the query precision threshold in a single query. The supernode weight is determined based on the data volume of the supernode. The superedge weight is determined based on the query probability of the second data partition.
[0197] The hypergraph segmentation problem is solved based on the expected optimization objective, resulting in the first partitioning distribution algorithm.
[0198] In one possible implementation of this application embodiment, the anticipated optimization objective includes at least one of the following:
[0199] The weights of the supernodes contained in each subgraph are balanced across the subgraphs. A subgraph includes one or more supernodes, and a subgraph corresponds to a first data node.
[0200] Alternatively, in the case of a single query executing the expected query plan, the total amount of data retrieved by all the first data nodes is minimized;
[0201] Alternatively, when executing the expected query plan, the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all the first data nodes is minimized, where the most loaded data node is the first data node with the largest amount of data retrieved.
[0202] In one possible implementation of this application embodiment, the coordinating node can also be used for:
[0203] Receive data migration requests;
[0204] A third data partition is constructed based on the sampled vector data and the second partitioning algorithm. The second partitioning algorithm is used to determine the mapping relationship between the vector data and the third data partition. The sampled vector data is obtained by sampling the vector data. One third data partition corresponds to one or more sampled vector data.
[0205] A second partition mapping table is constructed based on the third data partition and the second partition distribution algorithm. The second partition distribution algorithm is used to determine the mapping relationship between the third data partition and the second data node. The second partition mapping table is used to record the mapping relationship between the third data partition and the second data node. One third data partition corresponds to one second data node. The second data node is used to store one or more vector data. Different second data nodes are used to store different vector data.
[0206] Data migration is performed on the vector data based on the second partitioning algorithm and the second partitioning mapping table.
[0207] In one possible implementation of this application embodiment, the coordinating node can also be used for:
[0208] Receive a data insertion request, the data insertion request including vector data to be inserted;
[0209] A fourth data partition is determined based on the vector data to be inserted and the first partitioning algorithm. The first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition. The fourth data partition is the first data partition corresponding to the vector data to be inserted.
[0210] The third data node is determined based on the fourth data partition and the first partition mapping table. The first partition mapping table is used to record the mapping relationship between the first data partition and the first data node. The third data node is the first data node corresponding to the fourth data partition.
[0211] The vector data to be inserted is written into the third data node.
[0212] In one possible implementation of this application embodiment, the database may further include a cluster management module, which can be responsible for cluster management functions such as cluster scaling, fault detection, and failover.
[0213] According to the database provided in the embodiments of this application, since different vector data are stored in different first data nodes, and each first data node corresponds to one or more first data partitions, after receiving a data query request, the target data partition corresponding to the query vector data can be determined first, and then the target data node corresponding to the target data partition can directly retrieve the query vector data to obtain the query results. This allows only some target data nodes related to the data query request to participate in the query when performing a data query, without all data nodes participating in the data query. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of the vector data. In other words, low-cost storage and high throughput can be achieved simultaneously during the data query, thereby improving the query efficiency of the database.
[0214] To facilitate better implementation of the above-described solutions in the embodiments of this application, related apparatus for implementing the above-described solutions is also provided below.
[0215] Please see Figure 5 As shown in the figure, an embodiment of this application provides a data query device, including:
[0216] The receiving module 501 is used to receive a data query request, wherein the data query request includes query vector data;
[0217] The determining module 502 is used to determine the target data partition in the first data partition that corresponds to the query vector data, wherein one first data partition corresponds to one or more vector data.
[0218] The determining module 502 is further configured to determine a query result based on the target data node and the query vector data, wherein the target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data; wherein, one first data partition corresponds to one first data node, the first data node includes one or more vector data, and different first data nodes are used to store different vector data.
[0219] In one possible implementation of this application embodiment, the determining module 502 is specifically used for:
[0220] The target data node is determined based on the target data partition and the first partition mapping table, wherein the first partition mapping table is used to record the mapping relationship between the first data partition and the first data node;
[0221] The query results are obtained by performing a similarity search on the query vector data based on the target data node.
[0222] In one possible implementation of this application embodiment, the determining module 502 is specifically used for:
[0223] The target data partition is determined based on the query vector data and the first partition similarity algorithm, wherein the first partition similarity algorithm is used to calculate the similarity between the first data partitions.
[0224] In one possible implementation of this application embodiment, the apparatus further includes:
[0225] A construction module is used to construct the first data partition based on the vector data and the first partitioning algorithm, wherein the first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition;
[0226] The construction module is further configured to construct the first partition mapping table based on the first data partition and the first partition distribution algorithm, wherein the first partition distribution algorithm is used to determine the mapping relationship between the first data partition and the first data node.
[0227] In one possible implementation of this application embodiment, the apparatus further includes:
[0228] A construction module is used to construct a hypergraph segmentation problem based on the first data partition and the expected query plan. The hypergraph segmentation problem includes at least one of supernodes, superedges, supernode weights, or superedge weights. The supernode is the first data partition, the superedge is determined based on a second data partition, the second data partition is the first data partition that meets the query precision threshold in a single query, the supernode weight is determined based on the data volume of the supernode, and the superedge weight is determined based on the query probability of the second data partition.
[0229] The solution module is used to solve the hypergraph segmentation problem based on the expected optimization objective, and obtain the first partitioning distribution algorithm.
[0230] In one possible implementation of this application embodiment, the anticipated optimization objective includes at least one of the following:
[0231] The weights of the supernodes contained in each subgraph are balanced across the subgraphs. A subgraph includes one or more supernodes, and a subgraph corresponds to a first data node.
[0232] Alternatively, in the case of a single query executing the expected query plan, the total amount of data retrieved by all the first data nodes is minimized;
[0233] Alternatively, when executing the expected query plan, the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all the first data nodes is minimized, where the most loaded data node is the first data node with the largest amount of data retrieved.
[0234] In one possible implementation of this application embodiment, the apparatus further includes:
[0235] The receiving module 501 is also used to receive data migration requests;
[0236] A construction module is used to construct a third data partition based on sampled vector data and a second partitioning algorithm. The second partitioning algorithm is used to determine the mapping relationship between the vector data and the third data partition. The sampled vector data is obtained by sampling the vector data. One third data partition corresponds to one or more of the sampled vector data.
[0237] The construction module is further configured to construct a second partition mapping table based on the third data partition and the second partition distribution algorithm. The second partition distribution algorithm is used to determine the mapping relationship between the third data partition and the second data node. The second partition mapping table is used to record the mapping relationship between the third data partition and the second data node. In this case, one third data partition corresponds to one second data node. The second data node is used to store one or more vector data. Different second data nodes are used to store different vector data.
[0238] The data migration module is used to migrate the vector data based on the second partitioning algorithm and the second partitioning mapping table.
[0239] In one possible implementation of this application embodiment, the apparatus further includes:
[0240] The receiving module 501 is further configured to receive a data insertion request, the data insertion request including vector data to be inserted;
[0241] The determining module 502 is further configured to determine a fourth data partition based on the vector data to be inserted and the first partitioning algorithm, wherein the first partitioning algorithm is configured to determine the mapping relationship between the vector data and the first data partition, and the fourth data partition is the first data partition corresponding to the vector data to be inserted.
[0242] The determining module 502 is further configured to determine a third data node based on the fourth data partition and the first partition mapping table, wherein the first partition mapping table is used to record the mapping relationship between the first data partition and the first data node, and the third data node is the first data node corresponding to the fourth data partition;
[0243] The writing module is used to write the vector data to be inserted into the third data node.
[0244] According to the data query apparatus provided in the embodiments of this application, since different vector data are stored in different first data nodes, and each first data node corresponds to one or more first data partitions, after receiving a data query request, the target data partition corresponding to the query vector data can be determined first, and then the target data node corresponding to the target data partition can directly retrieve the query vector data to obtain the query results. This allows only some target data nodes related to the data query request to participate in the query when performing a data query, without all data nodes participating in the data query. Furthermore, since the query is performed by the first data node storing the vector data, there is no need to cache the vector data locally during the data query, avoiding redundant caching of the vector data. In other words, low-cost storage and high throughput can be achieved simultaneously during the data query, thereby improving the query efficiency of the database.
[0245] In this embodiment, the module is an example of a software functional unit, and the data query device may include code running on a computing instance. The computing instance may be at least one of a physical host (computer device), a virtual machine, a container, or other computer device. Further, the aforementioned computer device may be one or more. For example, the data query device may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the application may be distributed in the same region or in different regions. The multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.
[0246] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a single region. Communication between two VPCs within the same region, and between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.
[0247] As an example of a hardware functional unit, a data query device may include at least one computer device, such as a server. Alternatively, the data query device may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The aforementioned PLD may be implemented using a complex PLD (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.
[0248] The data query device comprises multiple computer devices that can be distributed within the same region or in different regions. Similarly, the multiple computer devices can be distributed within the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computer devices can be distributed within the same Virtual Private Cloud (VPC) or multiple VPCs. These multiple computer devices can be any combination of computer devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0249] This application also provides a computer device 630. For example... Figure 6 As shown, computer device 630 includes a bus 632, a processor 634, a memory 636, and a communication interface 638. The processor 634, memory 636, and communication interface 638 communicate with each other via the bus 632. Computer device 630 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computer device 630.
[0250] The 632 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 6 The bus 634 is represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 634 may include a path for transmitting information between various components of the computer device 630 (e.g., memory 636, processor 634, communication interface 638).
[0251] The processor 634 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0252] Memory 636 may include volatile memory, such as random access memory (RAM). Processor 634 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0253] The memory 636 stores executable program code, and the processor 634 executes the executable program code to implement the functions of the aforementioned acquisition module and training module, thereby realizing the data query method applied to the computer device cluster in the above embodiment. That is, the memory 636 stores instructions for executing the data query method applied to the computer device cluster in the above embodiment.
[0254] The communication interface 638 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computer device 630 and other devices or communication networks.
[0255] This application also provides a computer program product that, when run on a computer, causes the computer to execute the steps performed by the prompting processing device in the method described in the foregoing embodiments.
[0256] The prompting processing device provided in this application embodiment can be a chip, which includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the server to execute the prompting processing method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).
[0257] Specifically, the aforementioned processing unit or processor can be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0258] For example, please refer to Figure 7 , Figure 7 This is a schematic diagram of a chip provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU1200). The NPU1200 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1203, which is controlled by the controller 1204 to extract matrix data from the memory and perform multiplication operations.
[0259] In some implementations, the arithmetic circuit 1203 internally includes multiple process engines (PEs). In some implementations, the arithmetic circuit 1203 is a two-dimensional pulsating array. The arithmetic circuit 1203 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1203 is a general-purpose matrix processor.
[0260] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1202 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1201 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is stored in the accumulator 1208.
[0261] Unified memory 1206 is used to store input and output data. Weight data is directly transferred to weight memory 1202 via direct memory access controller (DMAC) 1205. Input data is also transferred to unified memory 1206 via DMAC.
[0262] The bus interface unit (BIU) 1210 is used for interaction between the bus and the DMAC and the instruction fetch buffer (IFB) 1209.
[0263] The bus interface unit 1210 (BIU) is used by the instruction fetch memory 1209 to fetch instructions from external memory, and also by the memory access controller 1205 to fetch the original data of the input matrix A or the weight matrix B from external memory.
[0264] The DMAC is mainly used to move input data from external memory DDR to unified memory 1206, or to weight data to weight memory 1202, or to input data to input memory 1201.
[0265] The vector computation unit 1207 includes multiple arithmetic processing units that, when needed, further process the output of the computation circuit, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.
[0266] In some implementations, the vector computation unit 1207 can store the processed output vector in the unified memory 1206. For example, the vector computation unit 1207 can apply linear and / or nonlinear functions to the output of the computation circuit 1203, such as performing linear interpolation on the feature planes extracted by the convolutional layer, or, for example, accumulating a vector of values to generate activation values. In some implementations, the vector computation unit 1207 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as an activation input to the computation circuit 1203, for example, for use in subsequent layers of the neural network.
[0267] The instruction fetch buffer 1209 connected to the controller 1204 is used to store the instructions used by the controller 1204;
[0268] Unified memory 1206, input memory 1201, weight memory 1202, and instruction fetch memory 1209 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.
[0269] The operations of each layer in the recurrent neural network can be performed by the operation circuit 1203 or the vector calculation unit 1207.
[0270] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the program for the above-described prompt processing method.
[0271] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0272] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0273] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0274] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0275] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0276] Finally, it should be noted that the above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope 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.
Claims
1. A data query method, characterized in that, The method includes: Receive a data query request, the data query request including query vector data; Determine the target data partition in the first data partition that corresponds to the query vector data, where one first data partition corresponds to one or more vector data; The query result is determined based on the target data node and the query vector data. The target data node is the first data node corresponding to the target data partition. The query result includes one or more target vector data. Among them, one first data partition corresponds to one first data node, and the first data node includes one or more vector data. Different first data nodes are used to store different vector data.
2. The method according to claim 1, characterized in that, Determining the query result based on the target data node and the query vector data includes: The target data node is determined based on the target data partition and the first partition mapping table, wherein the first partition mapping table is used to record the mapping relationship between the first data partition and the first data node; The query results are obtained by performing a similarity search on the query vector data based on the target data node.
3. The method according to claim 1 or 2, characterized in that, Determining the target data partition in the first data partition that corresponds to the query vector data includes: The target data partition is determined based on the query vector data and the first partition similarity algorithm, wherein the first partition similarity algorithm is used to calculate the similarity between the first data partitions.
4. The method according to claim 2 or 3, characterized in that, The method further includes: The first data partition is constructed based on the vector data and the first partitioning algorithm, wherein the first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition; The first partition mapping table is constructed based on the first data partition and the first partition distribution algorithm. The first partition distribution algorithm is used to determine the mapping relationship between the first data partition and the first data node.
5. The method according to claim 4, characterized in that, The method further includes: A hypergraph segmentation problem is constructed based on the first data partition and the expected query plan. The hypergraph segmentation problem includes at least one of supernodes, superedges, supernode weights, or superedge weights. The supernode is the first data partition. The superedge is determined based on the second data partition. The second data partition is the first data partition that meets the query precision threshold in a single query. The supernode weight is determined based on the data volume of the supernode. The superedge weight is determined based on the query probability of the second data partition. The hypergraph segmentation problem is solved based on the expected optimization objective, resulting in the first partitioning distribution algorithm.
6. The method according to claim 5, characterized in that, The expected optimization objective includes at least one of the following: The weights of the supernodes contained in each subgraph are balanced across the subgraphs. A subgraph includes one or more supernodes, and a subgraph corresponds to a first data node. Alternatively, in the case of a single query executing the expected query plan, the total amount of data retrieved by all the first data nodes is minimized; Alternatively, when executing the expected query plan, the difference between the amount of data retrieved by the most loaded data node and the average amount of data retrieved by all the first data nodes is minimized, where the most loaded data node is the first data node with the largest amount of data retrieved.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Receive data migration requests; A third data partition is constructed based on the sampled vector data and the second partitioning algorithm. The second partitioning algorithm is used to determine the mapping relationship between the vector data and the third data partition. The sampled vector data is obtained by sampling the vector data. One third data partition corresponds to one or more sampled vector data. A second partition mapping table is constructed based on the third data partition and the second partition distribution algorithm. The second partition distribution algorithm is used to determine the mapping relationship between the third data partition and the second data node. The second partition mapping table is used to record the mapping relationship between the third data partition and the second data node. One third data partition corresponds to one second data node. The second data node is used to store one or more vector data. Different second data nodes are used to store different vector data. Data migration is performed on the vector data based on the second partitioning algorithm and the second partitioning mapping table.
8. The method according to any one of claims 1 to 7, characterized in that, The method further includes: Receive a data insertion request, the data insertion request including vector data to be inserted; A fourth data partition is determined based on the vector data to be inserted and the first partitioning algorithm. The first partitioning algorithm is used to determine the mapping relationship between the vector data and the first data partition. The fourth data partition is the first data partition corresponding to the vector data to be inserted. The third data node is determined based on the fourth data partition and the first partition mapping table. The first partition mapping table is used to record the mapping relationship between the first data partition and the first data node. The third data node is the first data node corresponding to the fourth data partition. The vector data to be inserted is written into the third data node.
9. A data query device, characterized in that, The device includes: A receiving module is used to receive data query requests, wherein the data query requests include query vector data; The determination module is used to determine the target data partition in the first data partition that corresponds to the query vector data, wherein one first data partition corresponds to one or more vector data. The determining module is further configured to determine the query result based on the target data node and the query vector data, wherein the target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data; wherein, one first data partition corresponds to one first data node, the first data node includes one or more vector data, and different first data nodes are used to store different vector data.
10. A database, characterized in that, The database includes a coordinating node and a first data node, wherein the first data node includes one or more vector data, and different first data nodes are used to store different vector data; wherein the coordinating node is used to execute the following method: The system receives a data query request, which includes query vector data; determines a target data partition in a first data partition that corresponds to the query vector data, wherein one first data partition corresponds to one or more vector data; and determines a query result based on the target data node and the query vector data, wherein the target data node is the first data node corresponding to the target data partition, and the query result includes one or more target vector data; wherein one first data partition corresponds to one first data node.
11. A computer device, characterized in that, The device includes: Memory is used to store computer programs or computer instructions; A processor for executing a computer program or computer instructions stored in the memory, causing the computer device to perform the method as described in any one of claims 1 to 8.
12. A computer storage medium for storing a computer program, which, when executed, implements the method of any one of claims 1 to 8.
13. A computer program product comprising instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 8.
14. A chip, the chip comprising a processor and a data interface, the processor reading instructions stored in a memory through the data interface to execute the method as described in any one of claims 1 to 8.
