CN115803715A - Intelligent Process Routing in Partitioned Database Management Systems - Google Patents
Intelligent Process Routing in Partitioned Database Management Systems Download PDFInfo
- Publication number
- CN115803715A CN115803715A CN202080102917.6A CN202080102917A CN115803715A CN 115803715 A CN115803715 A CN 115803715A CN 202080102917 A CN202080102917 A CN 202080102917A CN 115803715 A CN115803715 A CN 115803715A
- Authority
- CN
- China
- Prior art keywords
- stored procedure
- data
- stored
- input parameters
- node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5033—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering data affinity
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N20/00—Machine learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/09—Supervised learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5019—Workload prediction
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computing Systems (AREA)
- Artificial Intelligence (AREA)
- Mathematical Physics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Biomedical Technology (AREA)
- Molecular Biology (AREA)
- General Health & Medical Sciences (AREA)
- Computational Linguistics (AREA)
- Biophysics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Medical Informatics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种数据库系统,可以包括至少一个负载均衡节点和多个计算节点。负载均衡节点可以接收包括存储过程的分布式事务,以及从多个预测函数中选择针对该存储过程的预测函数。负载均衡节点可以从存储过程中提取一个或多个输入参数,以及使用预测函数至少部分地基于该一个或多个输入参数从多个计算节点中确定计算节点。然后,负载均衡节点可以将存储过程转发给该计算节点以对该存储过程进行处理。
A database system may include at least one load balancing node and multiple computing nodes. The load balancing node can receive a distributed transaction including a stored procedure, and select a predictive function for the stored procedure from multiple predictive functions. The load balancing node may extract one or more input parameters from the stored procedure and determine a compute node from among the plurality of compute nodes based at least in part on the one or more input parameters using a prediction function. Then, the load balancing node can forward the stored procedure to the computing node to process the stored procedure.
Description
背景技术Background technique
随着各行各业中存储的数据量不断增加,例如公司数据、购物数据、个人数据等,在云或服务器网络上运行的分区分布式数据库管理系统(PDBMS)越来越受欢迎。在PDBM中,数据表被水平划分为多个部分,通常称为数据分片。每个数据分片是行的集合,并且被独立托管和复制。分片可以被移动、拆分或合并以提高性能和弹性。As the amount of data stored in various industries continues to increase, such as corporate data, shopping data, personal data, etc., Partitioned Distributed Database Management Systems (PDBMS) running on the cloud or server network are becoming more and more popular. In PDBM, a data table is divided horizontally into multiple parts, usually called data shards. Each data shard is a collection of rows and is hosted and replicated independently. Shards can be moved, split or merged to improve performance and resiliency.
涉及单个节点(即数据库服务器)上托管的数据的事务称为本地事务。这些事务本质上与传统的单个数据库管理系统中的事务没有区别。另一方面,涉及多个节点上数据的事务为全局事务,在执行提交操作时需要经过被称为两阶段提交(2PC)的复杂过程。因此,全局事务比本地事务慢得多。Transactions involving data hosted on a single node (i.e. the database server) are called local transactions. These transactions are essentially indistinguishable from transactions in a traditional single database management system. On the other hand, a transaction involving data on multiple nodes is a global transaction, and a complex process called two-phase commit (2PC) is required when performing a commit operation. Therefore, global transactions are much slower than local transactions.
为了获得更好的性能,数据库管理员(DBA)通常会指定数据分区和放置策略,以便可以在本地执行大多数事务。例如,电子商务应用的数据库可能包括仓库表和客户表等。如果提交给电子商务应用的大多数订单可以由本地仓库完成,则数据库管理员可以选择根据地理位置对表进行分区,使得表示同一位置的仓库和客户的行处于其各自表的同一分片中。数据库管理员也可以指定将同一位置的客户表的数据分片和仓库表的数据分片托管在同一节点上。通过这种方式,可以通过执行本地事务来为大多数订单提供服务,从而获得更好的性能。For better performance, database administrators (DBAs) typically specify data partitioning and placement strategies so that most transactions can be performed locally. For example, a database for an e-commerce application might include warehouse tables, customer tables, and so on. If the majority of orders submitted to an e-commerce application can be fulfilled by local warehouses, the database administrator may choose to partition the table based on geographic location such that rows representing warehouses and customers in the same location are in the same shard of their respective tables. The database administrator can also specify that the data shards of the customer table and the data shards of the warehouse table in the same location are hosted on the same node. In this way, better performance can be achieved by performing local transactions to service most orders.
如果PDBMS可以对数据进行计算,即直接在托管或存储数据的节点上执行事务,那么这种数据库分区工作可以实现最佳性能。然而,事实证明这样做很困难,原因如下:1)事务最好由单个节点执行,中止该事务并在另一个节点上重新启动该事务是可行的,但通常成本高昂;2)在事务开始之前很难预测相关数据所在的节点,尤其是当大多数事务涉及多个查询时。因此,执行交易的节点通常不托管与交易相关的数据,而是需要将查询请求转发给实际的托管节点,因而产生高昂的通信成本。最糟糕的是,由于事务已经分配给节点,该节点需要充当控制节点来协调其他节点对事务中包含的多个查询的执行或处理,向这些其他节点发送提交指令以完成2阶段提交,并从其他节点收集与多个查询的执行或处理相关的查询结果,并将查询结果发送到数据库管理员的客户端设备以供呈现或查看,因此,在控制节点与其他节点之间传输查询结果和指令进一步产生通信成本和时间。This database partitioning works best for performance if the PDBMS can perform computations on the data, i.e. execute transactions directly on the nodes hosting or storing the data. However, this has proven difficult for the following reasons: 1) a transaction is best performed by a single node, aborting the transaction and restarting it on another node is feasible, but usually costly; 2) before the transaction starts It can be difficult to predict where related data resides, especially when most transactions involve multiple queries. Therefore, nodes performing transactions usually do not host transaction-related data, but need to forward query requests to actual hosting nodes, resulting in high communication costs. Worst of all, since the transaction has been assigned to a node, that node needs to act as a control node to coordinate the execution or processing of multiple queries contained in the transaction by other nodes, send a commit instruction to these other nodes to complete the 2-phase commit, and from Other nodes collect query results related to the execution or processing of multiple queries and send the query results to the database administrator's client device for presentation or viewing, thus transferring query results and instructions between the control node and other nodes Further communication costs and time are generated.
发明内容Contents of the invention
该发明内容部分介绍分区数据库管理系统中智能过程路由的简化概念,这些将在下面的具体实施方式中进一步描述。该概述不旨在识别所要求保护的主题的基本特征,也不旨在用于限制所要求保护的主题的范围。This Summary section introduces simplified concepts of intelligent process routing in partitioned database management systems, which are further described in the detailed description below. This summary is not intended to identify essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
本公开内容描述了分区数据库管理系统中的智能过程路由的示例实现方式。在实现方式中,一个或多个计算设备可以对存储过程执行静态程序分析以确定一个或多个输入参数。该一个或多个计算设备还可以获得存储数据,存储数据包括存储过程的一个或多个输入参数的多个值集和多个数据分片的标识。在实现方式中,该一个或多个计算设备可以使用多个值集作为输入并使用多个数据分片的对应标识作为输出来训练分类模型,并且将经训练的分类模型设置为预测函数,用于将存储过程的一个或多个输入参数设置的新值集映射到对应的数据分片。This disclosure describes example implementations of intelligent procedure routing in a partitioned database management system. In an implementation, one or more computing devices may perform static program analysis on a stored procedure to determine one or more input parameters. The one or more computing devices may also obtain stored data including multiple value sets for one or more input parameters of the stored procedure and identifications of multiple data slices. In an implementation, the one or more computing devices may use a plurality of value sets as input and use corresponding identifications of a plurality of data slices as output to train a classification model, and set the trained classification model as a prediction function, using It is used to map the new value set set by one or more input parameters of the stored procedure to the corresponding data fragment.
附图说明Description of drawings
参考附图阐述详细描述。在附图中,附图标记中最左侧数字标识该附图标记首次出现的图。在不同的附图中使用相同的附图标记表示相似或相同的项。The detailed description is set forth with reference to the accompanying drawings. In the figures, the left-most digit(s) in a reference number identifies the figure in which the reference number first appears. The use of the same reference numbers in different drawings indicates similar or identical items.
图1示出了可以使用数据库系统的示例环境。Figure 1 illustrates an example environment in which a database system may be used.
图2更详细地示出了示例计算节点。Figure 2 shows an example compute node in more detail.
图3更详细地示出了示例负载均衡节点。Figure 3 shows an example load balancing node in more detail.
图4更详细地示出了示例监控节点。Figure 4 shows an example monitoring node in more detail.
图5示出了确定预测函数的示例方法。Figure 5 illustrates an example method of determining a prediction function.
图6示出了处理分布式数据库事务的示例方法。Figure 6 illustrates an example method of processing distributed database transactions.
具体实施方式Detailed ways
概述overview
如上所述,现有的分区分布式数据库系统采用负载均衡策略,无法确定性或策略性地将分布式数据库事务分配给特定节点,该特定节点包括数据库事务中涉及的一个或多个数据表,并且分配有数据库事务的节点可能需要充当控制或协调节点,协调其他节点来处理分布式数据库事务并同步提交该分布式数据库事务,这些其他节点包括该分布式数据库事务中涉及的数据表。这不仅增加了节点之间传输的数据和指令的通信成本和时间,而且浪费了分布式数据库事务可能不需要的控制或协调节点的处理资源。As mentioned above, the existing partitioned distributed database system adopts a load balancing strategy, and cannot deterministically or strategically assign distributed database transactions to a specific node, which includes one or more data tables involved in the database transaction, And the node assigned to the database transaction may need to act as a control or coordinating node, coordinate other nodes to process the distributed database transaction and submit the distributed database transaction synchronously, and these other nodes include the data tables involved in the distributed database transaction. This not only increases communication cost and time for data and instructions transferred between nodes, but also wastes processing resources of control or coordination nodes that may not be needed for distributed database transactions.
本公开内容描述了示例数据库系统。在实现方式中,数据库系统可以包括负载均衡节点、多个计算节点和监控节点。在实现方式中,数据库系统可以与多个过程相关联,这多个过程预先注册并存储在与数据库系统相关联的分布式数据库中。每个存储过程可以包括一个或多个数据库查询,这些数据库查询访问一个或多个数据库表的数据分片,这些数据分片位于或分布在数据库系统的一个或多个计算节点中。在实现方式中,存储过程可以包括一个或多个输入参数,这些输入参数可以充当占位符以从用户接收输入值用于执行数据库事务。在实现方式中,数据库系统可以将唯一标识分配给多个存储过程中的每个存储过程。This disclosure describes an example database system. In an implementation, the database system may include a load balancing node, a plurality of computing nodes, and a monitoring node. In an implementation, a database system may be associated with a plurality of procedures that are pre-registered and stored in a distributed database associated with the database system. Each stored procedure may include one or more database queries that access data slices of one or more database tables that are located or distributed across one or more computing nodes of the database system. In an implementation, a stored procedure may include one or more input parameters that may serve as placeholders to receive input values from a user for performing a database transaction. In an implementation, the database system may assign a unique identifier to each stored procedure of the plurality of stored procedures.
在实现方式中,数据库系统可以包括或存储一个或多个预测函数。在实现方式中,一个或多个预测函数中的预测函数可用于多个存储过程中的一个或多个存储过程。在实现方式中,每个预测函数可以用相应的标识来标记,并且数据库系统或负载均衡节点可以包括第一数据结构(例如表或映射),其将一个或多个预测函数中的每个预测函数与相应标识相关联或存储。此外,数据库系统还可以包括第二数据结构(例如表或映射),其将一个或多个存储过程的标识与对应的预测函数的标识相关联或存储。In an implementation, a database system may include or store one or more predictive functions. In an implementation, a predictive function of the one or more predictive functions may be used in one or more of the plurality of stored procedures. In an implementation, each prediction function may be labeled with a corresponding identifier, and the database system or load balancing node may include a first data structure (such as a table or map) that lists each of the one or more prediction functions Functions are associated or stored with corresponding identities. In addition, the database system may also include a second data structure (eg, a table or a map) that associates or stores identifications of one or more stored procedures with identifications of corresponding predictive functions.
在实现方式中,预测函数可以被配置成预测或尝试将存储过程映射到数据分片的标识,该存储过程为输入参数具有的特定值的存储过程的,该数据分片可以包括与存储过程的至少一个查询对应的数据。可选地,预测函数可以被配置成预测或尝试将存储过程映射到计算节点的标识,该存储过程为具有输入参数的特定值的存储过程,该计算节点可以包括与存储过程的至少一个查询对应的数据。In an implementation, the prediction function may be configured to predict or attempt to map a stored procedure to an identification of a data slice for a stored procedure that has a particular value for an input parameter, which may include a Data corresponding to at least one query. Optionally, the prediction function may be configured to predict or attempt to map a stored procedure, the stored procedure being a stored procedure having a specific value for an input parameter, to an identification of a computing node, the computing node may include at least one query corresponding to the stored procedure The data.
在实现方式中,数据库系统可以从客户端设备接收存储过程,该存储过程具有该存储过程的输入参数的输入值。数据库系统可以基于将多个存储过程与一个或多个预测函数相关联的第二数据结构从一个或多个预测函数中选择或确定用于存储过程的预测函数。在实现方式中,数据库系统可以通过静态程序分析来确定或提取存储过程的一个或多个输入参数的输入值,并采用所选择或确定的预测函数(如果预测函数输出数据分片的标识,而不是计算节点的标识,则还采用映射函数)来确定该存储过程被转发或分配的计算节点,该计算节点是根据提取的所述输入值确定。In an implementation, the database system may receive a stored procedure from a client device, the stored procedure having input values for input parameters of the stored procedure. The database system may select or determine a predictive function for the stored procedure from among the one or more predictive functions based on a second data structure that associates the plurality of stored procedures with the one or more predictive functions. In the implementation manner, the database system can determine or extract the input value of one or more input parameters of the stored procedure through static program analysis, and adopt the selected or determined prediction function (if the prediction function outputs the identifier of the data fragment, and If it is not the identifier of the computing node, then the mapping function) is also used to determine the computing node to which the stored procedure is forwarded or allocated, and the computing node is determined according to the extracted input value.
在实现方式中,一个或多个预测函数可以包括一个或多个分类模型,该分类模型由数据库系统通过基于由多个计算节点收集的历史数据进行训练而获得。在实现方式中,预测函数的历史数据可以包括但不限于与预测函数相关联的一个或多个存储过程的相应一个或多个输入参数的多个值集、数据分片或计算节点的标识等。在实现方式中,一个或多个分类模型可以包括但不限于神经网络模型、深度学习模型、决策树模型等。在实现方式中,数据库系统可以周期性地或当预测误差达到预定误差阈值时更新或重新训练一个或多个预测函数。In an implementation, the one or more predictive functions may include one or more classification models obtained by the database system through training based on historical data collected by the plurality of computing nodes. In an implementation manner, the historical data of the prediction function may include, but not limited to, multiple value sets of corresponding one or more input parameters of one or more stored procedures associated with the prediction function, data shards or identifications of computing nodes, etc. . In an implementation manner, the one or more classification models may include but not limited to neural network models, deep learning models, decision tree models, and the like. In an implementation, the database system may update or retrain one or more prediction functions periodically or when the prediction error reaches a predetermined error threshold.
如上所述,用以示范的数据库系统可以接收具有输入参数的输入值的存储过程,并且基于预测函数预测或确定(确定该存储过程被转发或分配的)计算节点,该计算节点可能存储有该存储过程的至少一次查询中所涉及的数据表的数据分片,从而潜在地避免了将存储过程发送到未存储该过程查询或访问的任何数据分片的计算节点的情况,从而减少因该计算节点与其他计算节点之间的交互而产生的额外需求所导致的资源浪费、通信成本和处理延迟,所述其他计算节点存储有该存储过程查询或访问的数据分片。As described above, the exemplary database system may receive a stored procedure with input values for input parameters, and based on a prediction function predict or determine (determine that the stored procedure is forwarded or assigned) a computing node, which may store the The data shards of the data tables involved in at least one query of the stored procedure, thereby potentially avoiding the situation where the stored procedure is sent to a compute node that does not store any data shards queried or accessed by the procedure, thereby reducing the Waste of resources, communication costs, and processing delays resulting from additional requirements arising from interactions between nodes and other computing nodes that store data fragments queried or accessed by the stored procedure.
在实现方式中,本文描述的由数据库系统执行的功能可以由多个单独的单元或服务来执行。此外,尽管在本文描述的示例中,数据库系统可以被实现为在多个设备中实现和分布的软件和硬件的组合,但是在其他示例中,数据库系统可以作为服务来实现和分布,该服务通过网络和/或云计算架构上的一个或多个计算设备提供。In an implementation, the functions described herein to be performed by a database system may be performed by a number of separate units or services. Furthermore, while in the examples described herein the database system may be implemented as a combination of software and hardware implemented and distributed across multiple devices, in other examples the database system may be implemented and distributed as a service that is accessed through provided by one or more computing devices on a network and/or cloud computing architecture.
该申请描述了多种不同的实施例和实现方式。以下部分描述了适用于实践各种实现方式的示例框架。接下来,本申请描述了用于实现数据库系统的示例系统、设备和过程。This application describes a number of different embodiments and implementations. The following sections describe example frameworks suitable for practicing various implementations. Next, the application describes example systems, devices, and processes for implementing a database system.
示例环境example environment
图1示出了可用于实现数据库系统的示例环境100。环境100可以包括数据库系统102。在实现方式中,数据库系统102可以包括多个服务器或计算节点104-1、104-2、……、104-N(统称为计算节点104)。计算节点104可以通过网络106彼此传送数据。在实现方式中,数据库系统102还可以包括至少一个负载均衡节点108,用于将工作负载分配给服务器或计算节点104。在实现方式中,一个或多个服务器或者计算节点104可以被指定或用作至少一个负载均衡节点108。在实现方式中,数据库系统102还可以包括监控节点110。Figure 1 illustrates an
在实现方式中,每个服务器或计算节点104可以被实现为多种计算设备中的任何一种,不限于台式计算机、笔记本或便携式计算机、手持设备、上网本、互联网设备、平板电脑或平板计算机、移动设备(例如,移动电话、个人数字助理、智能手机等)、服务器计算机等,或是其组合。In an implementation, each server or computing node 104 may be implemented as any of a variety of computing devices, not limited to desktop computers, notebook or portable computers, handheld devices, netbooks, Internet appliances, tablet or tablet computers, Mobile devices (eg, mobile phones, personal digital assistants, smartphones, etc.), server computers, etc., or combinations thereof.
网络106可以是无线网络或有线网络,或是其组合。网络106可以是彼此互连以用作单个大型网络(例如,因特网或内联网)的独立网络的集合。这种独立网络的示例包括但不限于电话网络、电缆网络、局域网(LAN)、广域网(WAN)和城域网(MAN)。此外,独立网络可以是无线网络或有线网络,或是其组合。有线网络可以包括电载体连接(例如通信电缆等)和/或光学载体或连接(例如光纤连接等)。无线网络可以包括例如WiFi网络、其他射频网络(例如蓝牙、Zigbee等)、等等。Network 106 may be a wireless network or a wired network, or a combination thereof. Network 106 may be a collection of separate networks interconnected to act as a single large network (eg, the Internet or an intranet). Examples of such separate networks include, but are not limited to, telephone networks, cable networks, local area networks (LANs), wide area networks (WANs), and metropolitan area networks (MANs). Additionally, the stand-alone network may be a wireless network or a wired network, or a combination thereof. A wired network may include electrical carrier connections (eg, communication cables, etc.) and/or optical carriers or connections (eg, fiber optic connections, etc.). Wireless networks may include, for example, WiFi networks, other radio frequency networks (eg, Bluetooth, Zigbee, etc.), and the like.
在实现方式中,环境100还可以包括客户端设备112。客户端设备112可以被实现为多种计算设备中的任何一种,不限于台式计算机、笔记本或便携式计算机、手持设备、上网本、互联网设备、平板电脑或平板计算机、移动设备(例如,移动电话、个人数字助理、智能手机等)、服务器计算机等,或是其组合。In an implementation, the
在实现方式中,数据库系统102可以从客户端设备112接收处理分布式数据库事务的请求。例如,客户端设备112的用户114(例如数据库管理员等)可以向数据库系统102提交涉及一个或多个数据表的多个查询请求作为分布式数据库事务。响应于接收到的该请求,数据库系统102可以基于路由指令确定至少一个计算节点,该计算节点包括该分布式数据库事务中涉及的数据表的数据部分,将该分布式数据库事务发送给该至少一个计算节点进行处理,并将对该分布式数据库事务的处理结果返回给客户端设备112。In an implementation, database system 102 may receive a request from client device 112 to process a distributed database transaction. For example, a user 114 (eg, a database administrator, etc.) of a client device 112 may submit multiple query requests involving one or more data tables to the database system 102 as distributed database transactions. In response to receiving the request, the database system 102 may determine, based on the routing instructions, at least one computing node that includes the data portion of the data tables involved in the distributed database transaction, and send the distributed database transaction to the at least one computing node. The computing nodes process and return the processing result of the distributed database transaction to the client device 112 .
示例分区数据库Sample Partitioned Database
在实现方式中,数据库系统102还可以包括在多个计算节点104之中分区或分布的一个或多个数据库。作为示例而非限制,分区或分布式数据库可以包括一个或多个被划分或分区的数据表,每个数据表被水平划分为多个部分,这些部分被称为数据分片或简称为分片。在实现方式中,每个分片可以包括一组行,并且可以在一个或多个计算节点104中独立托管和复制。此外,分片可以被移动、拆分或合并以提高数据库系统102的性能和弹性。In an implementation, the database system 102 may also include one or more databases partitioned or distributed among the plurality of computing nodes 104 . By way of example and not limitation, a partitioned or distributed database may include one or more data tables that are partitioned or partitioned, with each data table divided horizontally into portions known as data shards or simply shards . In an implementation, each shard can include a set of rows and can be independently hosted and replicated among one or more compute nodes 104 . Additionally, shards can be moved, split, or merged to improve database system 102 performance and resiliency.
在实现方式中,涉及托管在单个计算节点104或服务器(例如数据库服务器)上的数据的事务可以称为本地事务。本地事务本质上与传统的单体DBMS中的事务没有区别。另一方面,涉及多个计算节点上数据的事务,即全局事务,在提交时需要经过被称为2阶段提交(2PC)的复杂过程。因此,全局事务的处理比本地事务的处理慢得多。In an implementation, transactions involving data hosted on a single computing node 104 or server (eg, a database server) may be referred to as local transactions. Local transactions are essentially no different from transactions in traditional monolithic DBMSs. On the other hand, transactions involving data on multiple computing nodes, ie, global transactions, need to go through a complex process called 2-phase commit (2PC) when committing. Therefore, the processing of global transactions is much slower than the processing of local transactions.
在实现方式中,可以基于列的值或多列组合的值对数据表进行水平分区。在后一种情况下,来自每一列的值可以形成元组,并且出于分区的目的,这些列可以被视为单个逻辑列。在不失一般性的情况下,为简单起见,假设基于分区列对表进行分区。In an implementation manner, the data table may be horizontally partitioned based on column values or values combined by multiple columns. In the latter case, the values from each column can form tuples, and the columns can be treated as a single logical column for partitioning purposes. Without loss of generality, for simplicity, assume that the table is partitioned based on the partition column.
在实现方式中,分区列中具有相同值的行可以放置在同一数据段或分片中。例如,电子商务应用可以包括具有客户表的数据库,其中包括的列例如街道、城市、州、邮政编码等。这些列可以形成客户的地址。用户114(例如数据库管理员)可以单独使用与邮政编码相关联的列来划分客户表,使得客户表中具有相同邮政编码的所有行位于同一数据段或分片中。In implementations, rows with the same value in a partition column can be placed in the same data segment or shard. For example, an e-commerce application may include a database with a customer table including columns such as street, city, state, zip code, and so on. These columns can form the customer's address. A user 114 (eg, a database administrator) can use the column associated with zip code alone to partition the customer table such that all rows in the customer table with the same zip code are in the same data segment or shard.
在实现方式中,数据库系统102还可以包括或提供针对每个数据表的分区函数,parttable(k)→shard_id,其中k称为分区键,是分区列的值。在实现方式中,该函数的输出可以是包括其分区列的值等于分区键(即,k)的所有行的分片的标识(即,ID)。In an implementation manner, the database system 102 may also include or provide a partition function for each data table, part table (k)→shard_id, where k is called a partition key and is the value of a partition column. In an implementation, the output of this function may be an identification (ie, ID) of a shard that includes all rows whose partition column's value is equal to the partition key (ie, k).
在实现方式中,数据库系统102可以允许用户114为存储在分区数据库中的数据指定一个或多个分区和放置策略。继续上述电子商务应用的示例,除了客户表之外还可以包括仓库表。由于该电子商务应用的大多数订单可能需要从本地仓库完成,因此用户114可以决定基于地理位置对数据库分区。在这种情况下,仓库位置的邮政编码和客户地址的邮政编码可以分别作为仓库表和客户表的对应分区列。此外,用户114可以指示数据库系统102允许将表示同一邮政编码处的仓库和客户的行被托管或存储在同一节点中,使得大多数订单处理可以触发本地事务。换句话说,partwarehouse(k)和partcustomer(k)这两个函数都将邮政编码作为分区键,并且满足其中place(.)是放置函数。In an implementation, database system 102 may allow user 114 to specify one or more partitioning and placement policies for data stored in a partitioned database. Continuing with the e-commerce application example above, a warehouse table could be included in addition to the customer table. Since most orders for the e-commerce application may need to be fulfilled from a local warehouse, the user 114 may decide to partition the database based on geographic location. In this case, the zip code of the warehouse location and the zip code of the customer address can be used as the corresponding partition columns of the warehouse table and customer table, respectively. Additionally, user 114 may instruct database system 102 to allow rows representing warehouses and customers at the same zip code to be hosted or stored in the same node so that most order processing can trigger local transactions. In other words, both the functions part warehouse (k) and part customer (k) have zip code as the partition key and satisfy where place(.) is the placement function.
在实现方式中,分区函数和放置函数可以通过查询元数据来实现,元数据包括从分区键到分片ID的映射,以及当对应分片被托管或存储时,从分片ID到计算节点的映射。该元数据可以被复制到数据库系统102中的一些或所有计算节点104和/或负载均衡节点108。In an implementation, the partition function and placement function can be implemented by querying metadata, which includes a mapping from partition key to shard ID, and when the corresponding shard is hosted or stored, from shard ID to compute node map. This metadata may be replicated to some or all compute nodes 104 and/or load balancing nodes 108 in database system 102 .
在一些实现方式中,分区函数可能不存在或者可能由于涉及潜在的大量数据并且需要预先存储而难以构造。在实现方式中,数据库系统102可以包括或提供用于存储过程的预测函数predictproc(parameters)→shard_id,其中参数表示用户针对存储过程的输入参数输入的值。在实现方式中,该函数的输出可以是shard_id,即可能包括被存储过程的至少一个查询请求所查询或访问的数据行所属的分片的标识(即,ID)。在获得可能包括要被存储过程的至少一个查询请求查询或访问的数据行的分片的标识之后,数据库系统102可以使用如上所述的放置函数来获得该存储过程可以被分配或发送到的计算节点的标识。In some implementations, a partition function may not exist or may be difficult to construct due to the potentially large amount of data involved and the need to store it upfront. In an implementation, the database system 102 may include or provide a prediction function predict proc (parameters)→shard_id for a stored procedure, where the parameter represents a value entered by a user for an input parameter of the stored procedure. In an implementation manner, the output of the function may be shard_id, which may include an identification (ie, ID) of the shard to which the data row queried or accessed by at least one query request of the stored procedure belongs. After obtaining the identification of the shards that may include data rows to be queried or accessed by at least one query request of the stored procedure, database system 102 may use the put function as described above to obtain the compute The ID of the node.
示例计算节点Example Compute Node
图2详细地示出了计算节点104。在实现方式中,计算节点104可以包括但不限于一个或多个处理器202、输入/输出(I/O)接口204,和/或网络接口206,以及存储器208。在实现方式中,计算节点104的一些功能可以使用硬件实现,例如ASIC(即,专用集成电路)、FPGA(即,现场可编程门阵列),和/或其他硬件。Figure 2 shows compute node 104 in detail. In an implementation, a compute node 104 may include, but is not limited to, one or
在实现方式中,处理器202可以被配置成执行存储在存储器208中和/或从I/O接口204和/或网络接口206接收的指令。在实现方式中,处理器202可以被实现为一个或多个硬件处理器,包括例如微处理器、专用指令集处理器、物理处理单元(PPU)、中央处理单元(CPU)、图形处理单元、数字信号处理器、张量处理器。附加地或替选地,本文描述的功能可以至少部分地由一个或多个硬件逻辑组件执行。例如但不作为限制,可以使用的示例性硬件逻辑组件类型包括现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、系统上芯片系统(SOC)、复杂可编程逻辑器件(CPLD)等。In an implementation,
存储器208可以包括计算机可读介质,其可以是易失性存储器形式,例如随机存取存储器(RAM),和/或非易失性存储器形式,例如只读存储器(ROM)或闪存RAM。存储器208是计算机可读介质的示例。Memory 208 may include computer readable media, which may be in the form of volatile memory, such as random access memory (RAM), and/or nonvolatile memory, such as read only memory (ROM) or flash RAM. Memory 208 is an example of a computer readable medium.
计算机可读介质可以包括易失性或非易失性类型、可移动或不可移动介质,其可以使用任何方法或技术实现信息存储。该信息可以包括计算机可读指令、数据结构、程序模块或其他数据。计算机可读介质的示例包括但不限于相变存储器(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦可编程只读存储器(EEPROM)、快速闪存或其他内部存储技术、光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光存储装置、磁带、磁盘存储装置、或其他磁存储装置、或可以用于存储可由计算设备访问的信息的任何其他非传输介质。如本文所定义的,计算机可读介质不包括任何暂态介质,例如调制数据信号和载波。Computer readable media can include volatile or nonvolatile types, removable or non-removable media that implement information storage using any method or technology. The information may include computer readable instructions, data structures, program modules or other data. Examples of computer readable media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory ( ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash Flash or other internal storage technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage devices, magnetic tape, magnetic disk storage device, or other magnetic storage device, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include any transitory media, such as modulated data signals and carrier waves.
尽管在该示例中,仅描述了计算节点104中的硬件组件,但在其他情况下,计算节点104还可以包括其他硬件组件和/或其他软件组件,例如程序单元,以执行存储器208中存储的指令以执行各种操作。例如,计算节点104还可以包括本地或分区数据库210以用于存储数据表和其他程序数据212。作为示例而非限制,计算节点104可以在本地或分区数据库210中存储一个或多个数据表的数据段或分片。在实现方式中,可以根据不同计算节点104的相应分区键来划分和分布一个或多个数据表。Although in this example only hardware components in compute node 104 are described, in other cases compute node 104 may also include other hardware components and/or other software components, such as program elements, to execute the instructions to perform various operations. For example, compute nodes 104 may also include a local or partitioned
示例负载均衡节点Example load balancing node
图3更详细地示出了负载均衡节点108。在实现方式中,负载均衡节点108可以包括但不限于一个或多个处理器302、输入/输出(I/O)接口304、和/或网络接口306、以及存储器308。在实现方式中,负载均衡节点108的一些功能可以使用硬件来实现,例如ASIC(即,专用集成电路)、FPGA(即,现场可编程门阵列)、和/或其他硬件。Figure 3 shows the load balancing node 108 in more detail. In an implementation, load balancing node 108 may include, but is not limited to, one or
在实现方式中,处理器302可以被配置成执行在存储器308中存储的和/或从I/O接口304和/或网络接口306接收的指令。在实现方式中,处理器302可以被实现为一个或多个硬件处理器,包括例如微处理器、专用指令集处理器、物理处理单元(PPU)、中央处理单元(CPU)、图形处理单元、数字信号处理器、张量处理单元。附加地或替选地,本文描述的功能可以至少部分地由一个或多个硬件逻辑组件来执行。例如但不作为限制,可以使用的示例性硬件逻辑组件类型包括现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、系统上芯片系统(SOC)、复杂可编程逻辑器件(CPLD)等。In an implementation,
存储器308可以包括计算机可读介质,其可以是易失性存储器形式,例如随机存取存储器(RAM),和/或非易失性存储器形式,例如只读存储器(ROM)或闪存RAM。存储器308是如前文描述的计算机可读介质的示例。Memory 308 may include computer readable media, which may be in the form of volatile memory, such as random access memory (RAM), and/or nonvolatile memory, such as read only memory (ROM) or flash RAM. Memory 308 is an example of a computer readable medium as previously described.
尽管在该示例中,仅描述了负载均衡节点108中的硬件组件,但是在其他情况下,负载均衡节点108还可以包括其他硬件组件和/或其他软件组件,例如程序单元,用于执行存储器308中存储的指令以执行各种操作。例如,负载均衡节点108还可以包括映射表310和其他程序数据312。在实现方式中,映射表310可以包括从组合到计算节点的信息的映射,该组合为数据表信息和分区键信息的组合,该计算节点包括对应于所述分区键的数据表的数据段或分片。作为示例而非限制,给定数据表的名称和分区键的值,负载均衡节点108可以确定包括与分区键的值对应的数据表的数据段或分片的计算节点的标识或地址。Although in this example, only the hardware components in the load balancing node 108 are described, in other cases, the load balancing node 108 may also include other hardware components and/or other software components, such as program elements, for executing memory 308 Instructions stored in to perform various operations. For example, load balancing node 108 may also include mapping table 310 and
在实现方式中,负载均衡节点108可以预先获得映射表310,例如通过接收来自多个计算节点104的广播信息。在实现方式中,每个计算节点104的广播信息可以包括,但不限于,关于相应的计算节点104中包括或存储的对应于分区键的特定值的数据表的数据段或分片的信息。In an implementation, the load balancing node 108 may obtain the mapping table 310 in advance, for example, by receiving broadcast information from a plurality of computing nodes 104 . In an implementation, the broadcast information of each compute node 104 may include, but is not limited to, information about data segments or fragments of a data table included or stored in the corresponding compute node 104 corresponding to a particular value of the partition key.
附加地或可选地,在一些实现方式中,负载均衡节点108可以与映射装置(其可以是数据库系统102中提供的服务器或计算装置)相关联。映射装置可以从多个计算节点104收集关于每个计算节点104中包括或存储的对应于分区键的特定值的数据表的数据段或分片的信息,例如,通过如上所述从多个计算节点104广播信息来收集。在这种情况下,负载均衡节点108可以将从分布式数据库事务中获得的分区键的信息(例如值)和数据表的信息(例如名称)发送给映射装置,映射装置将数据表的信息和分区键的信息映射到计算节点的信息(例如,标识或地址),该计算节点包括对应于所述分区键的数据表的数据段或分片。负载均衡节点108然后可以从映射装置接收计算节点的信息,从而在使负载均衡节点能够持续处理传入请求或数据包的负载均衡的同时,减少负载均衡节点的工作量和复杂度。Additionally or alternatively, in some implementations, load balancing node 108 may be associated with a mapping device (which may be a server or a computing device provided in database system 102). The mapping means may collect information from the plurality of compute nodes 104 about the data segments or shards of the data table included or stored in each compute node 104 corresponding to a particular value of the partition key, for example, by Nodes 104 broadcast information to collect. In this case, the load balancing node 108 can send the partition key information (such as value) and the information of the data table (such as the name) obtained from the distributed database transaction to the mapping device, and the mapping device sends the information of the data table and The information of the partition key is mapped to the information (eg, identification or address) of the computing node including the data segment or shard of the data table corresponding to the partition key. The load balancing node 108 may then receive the information of the computing nodes from the mapping device, thereby reducing the workload and complexity of the load balancing node while enabling the load balancing node to continuously handle the load balancing of incoming requests or data packets.
在实现方式中,负载均衡节点108可以包括一个或多个预定的负载均衡策略。作为示例而非限制,一个或多个预定的负载均衡策略可以包括:将接收到(例如,从客户端设备112接收)的分布式数据库事务以随机方式分配给计算节点、将分布式数据库事务以循环方式分配给计算节点、将分布式数据库事务分配给当前工作量最小的计算节点、或根据客户端设备的IP地址与计算节点的映射关系向计算节点分配分布式数据库事务等。In an implementation, the load balancing node 108 may include one or more predetermined load balancing policies. By way of example and not limitation, one or more predetermined load balancing strategies may include: assigning received (e.g., from client device 112) distributed database transactions to computing nodes in a random manner, assigning distributed database transactions to Allocation to computing nodes in a circular manner, assigning distributed database transactions to computing nodes with the smallest current workload, or assigning distributed database transactions to computing nodes according to the mapping relationship between the IP address of the client device and computing nodes, etc.
在实现方式中,负载均衡节点108还可以包括标识数据库314。标识数据库314可以包括或存储例如在数据库102中注册和存储的存储过程的唯一标识(例如唯一名称等)、预测函数的唯一标识等。在实现方式中,负载均衡节点108还可以包括关系数据库316。关系数据库316可以包括或存储有例如存储过程的唯一标识与预测函数的唯一标识之间的关系等。在实现方式中,负载均衡节点108还可以包括预测器数据库318。预测器数据库318可以包括或存储有多个预测函数,例如可以通过预测函数的标识对其进行查询或调用。In an implementation, the load balancing node 108 may also include an
示例监控节点Example monitor node
图4更详细地示出了监控节点110。在实现方式中,监控节点110可以包括但不限于一个或更多个处理器402、输入/输出(I/O)接口404、和/或网络接口406、以及存储器408。在实现方式中,监控节点110的一些功能可以使用硬件来实现,例如ASIC(即,专用集成电路)、FPGA(即,现场可编程门阵列)、和/或其他硬件。Figure 4 shows the monitoring node 110 in more detail. In an implementation, monitoring node 110 may include, but is not limited to, one or
在实现方式中,处理器402可以被配置成执行存储器408中存储的和/或从I/O接口404和/或网络接口306接收的指令。在实现方式中,处理器402可以被实现为一个或多个硬件处理器,包括例如微处理器、专用指令集处理器、物理处理单元(PPU)、中央处理单元(CPU)、图形处理单元、数字信号处理器、张量处理单元。附加地或替选地,本文描述的功能可以至少部分地由一个或多个硬件逻辑组件来执行。例如但不作为限制,可以使用的性硬件逻辑组件类型包括现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、系统上芯片系统(SOC)、复杂可编程逻辑器件(CPLD)等。In an implementation,
存储器408可以包括计算机可读介质,其可以是易失性存储器形式,例如随机存取存储器(RAM),和/或是非易失性存储器形式,例如只读存储器(ROM)或闪存RAM。存储器408是如前文描述的计算机可读介质的示例。Memory 408 may include computer readable media, which may be in the form of volatile memory, such as random access memory (RAM), and/or nonvolatile memory, such as read only memory (ROM) or flash RAM. Memory 408 is an example of a computer readable medium as previously described.
尽管在该示例中,仅描述了监控节点110中的硬件组件,但在其他情况下,监控节点110还可以包括其他硬件组件和/或其他软件组件,例如程序单元,以执行存储器408中存储的指令以执行各种操作。例如,监控节点110可以还包括信息数据库410和其他程序数据412。在实现方式中,信息数据库410可以存储从多个计算节点104和负载均衡节点108接收的数据,可以包括但不限于下述信息:来自负载均衡节点108的各存储过程被用户单独调用或使用的相应次数、来自每个计算节点104的未命中过程的标识和相应的未命中次数、相应的输入和输出数据集(包括存储过程的一个或多个输入参数的多个值集和多个预测函数中每个预测函数的多个数据分片的标识)等。Although in this example, only the hardware components in the monitoring node 110 are described, in other cases, the monitoring node 110 may also include other hardware components and/or other software components, such as program elements, to execute the instructions to perform various operations. For example, monitoring node 110 may also include
示例方法example method
图5示出了描绘确定预测函数的示例方法的示意图。图6示出了描绘处理分布式数据库事务的示例方法的示意图。图5和图6的方法可以但不是必须在图1的环境中且使用图2至图4中的计算节点、负载均衡节点和监控节点来实现。为了便于解释,参考图1至图3描述方法500和方法600。然而,方法500和600可选地在可以其他环境中和/或使用其他系统来实现。FIG. 5 shows a schematic diagram depicting an example method of determining a prediction function. FIG. 6 shows a schematic diagram depicting an example method of processing distributed database transactions. The methods in FIG. 5 and FIG. 6 can, but not necessarily, be implemented in the environment of FIG. 1 and using the computing nodes, load balancing nodes and monitoring nodes in FIG. 2 to FIG. 4 . For ease of explanation,
方法500和方法600在计算机可执行指令的一般上下文中进行描述。通常,计算机可执行指令可以包括执行特定函数或实现特定抽象数据类型的例程、程序、对象、组件、数据结构、过程、模块、函数等。此外,示例方法中的每个被图示为逻辑流程图中的块的集合,该逻辑流程图表示可以在硬件、软件、固件或其组合中实现的操作序列。描述该方法的顺序不旨在被解释为限制,并且任何数量的所描述的方法块可以以任何顺序组合以实现该方法或替选方法。此外,在不脱离本文所述主题的精神和范围的情况下,可以省略该方法中的单独的块。在软件的上下文中,块代表计算机指令,当其由一个或多个处理器执行时,执行所述操作。在硬件的上下文中,一些或所有块可以代表专用集成电路(ASIC)或执行所述操作的其他物理组件。
返回参照图5,在块502处,监控节点110可以选择存储过程。Referring back to FIG. 5 , at
在实现方式中,数据库系统102可以包括存储在数据库系统102中的多个过程。这些过程用查询语言(例如SQL语言)编写,并且在数据库系统102中注册以供用户调用。在实现方式中,存储过程可以包括一个或多个查询请求,该一个或多个查询请求对位于数据库系统102的一个或多个计算节点中的一个或多个数据库表的一个或多个数据分片的数据进行访问或更新。在实现方式中,存储过程的查询请求可以包括分区键和输入参数,该输入参数接收的输入值来自使用该存储过程的用户。在实现方式中,存储过程可以包括输入参数的参数列表,其可以用作占位符以从用户接收存储过程的输入参数的输入值。在其他实现方式中,存储过程可以不包括输入参数的参数列表,输入参数分布在需要查找的存储过程中。In an implementation, database system 102 may include a number of procedures stored in database system 102 . These procedures are written in a query language (such as SQL language), and registered in the database system 102 for users to call. In an implementation, a stored procedure may include one or more query requests that request one or more data analyzes for one or more database tables located in one or more compute nodes of database system 102 . The data of the slice is accessed or updated. In an implementation manner, the query request of the stored procedure may include a partition key and an input parameter, and the input parameter receives an input value from a user using the stored procedure. In an implementation, a stored procedure may include a parameter list of input parameters, which may be used as a placeholder to receive input values for the input parameters of the stored procedure from a user. In other implementation manners, the stored procedure may not include a parameter list of input parameters, and the input parameters are distributed in the stored procedures that need to be searched.
在实现方式中,监控节点110可以获得在数据库系统102中新添加或注册一个或多个存储过程,并且针对这些存储过程没有预测函数,或者还没有为这些存储过程训练过的预测函数。监控节点110可以从数据库系统102中新添加或注册的一个或多个存储过程中选择存储过程。在实现方式中,在存储过程已被数据库系统102的用户使用或调用预定次数(例如,1,000次、10,000次等)和/或预定时段(例如,一周、两周等)之后,监控节点110可以选择新添加或注册存储过程。这允许有足够数量的训练数据可用于针对存储过程训练预测函数。In an implementation manner, the monitoring node 110 may obtain one or more stored procedures newly added or registered in the database system 102, and there is no prediction function for these stored procedures, or there is no predicted function trained for these stored procedures. The monitoring node 110 may select a stored procedure from one or more stored procedures newly added or registered in the database system 102 . In an implementation, after a stored procedure has been used or invoked a predetermined number of times (e.g., 1,000, 10,000, etc.) Choose New to add or register a stored procedure. This allows a sufficient amount of training data to be available for training the prediction function against the stored procedure.
附加地或可选地,监控节点110可以从与预测函数相关联的多个存储过程中选择存储过程以周期性地(例如每一周、每两周、每一个月等)进行重新训练。在实现方式中,选择某存储过程的频率可以取决于数据库系统102中用户调用或使用该存储过程的频率。作为示例而非限制,调用或使用存储过程的频率越高,选择该存储过程进行重新训练的频率越高。Additionally or alternatively, monitoring node 110 may select a stored procedure from a plurality of stored procedures associated with the predictive function to retrain periodically (eg, every week, every two weeks, every month, etc.). In an implementation manner, the frequency of selecting a certain stored procedure may depend on the frequency with which users in the database system 102 call or use the stored procedure. By way of example and not limitation, the more frequently a stored procedure is called or used, the more frequently that stored procedure is selected for retraining.
附加地或可选地,监控节点110可以监控数据库系统102中的多个存储过程的性能,并且基于存储过程的性能确定是否更新或重新训练存储过程。在实现方式中,存储过程的性能可以包括但不限于用于对存储过程进行映射的预测函数的错误率等。例如,负载均衡节点108可以对每个存储过程在预设时间间隔内(例如,每一周、每两周等)被用户使用或调用的次数进行计数,并将每个存储过程的标识和相应的使用或调用次数存储在数据结构中(例如,表等)。此外,每个计算节点104可以跟踪分配给该计算节点、在相应的计算节点104中遭遇未命中(即,一个或多个存储过程请求访问或更新的数据在该计算节点104中不存在)的一个或多个存储过程。每个计算节点104可以在预设的时间间隔内将这种存储过程的标识和该存储过程的相应的未命中次数存储在特定数据结构(例如列表等)中。Additionally or alternatively, the monitoring node 110 may monitor the performance of multiple stored procedures in the database system 102 and determine whether to update or retrain the stored procedures based on the performance of the stored procedures. In an implementation, the performance of the stored procedure may include, but not limited to, an error rate of a prediction function used to map the stored procedure, and the like. For example, the load balancing node 108 can count the number of times each stored procedure is used or invoked by the user within a preset time interval (for example, every week, every two weeks, etc.), and compare the identifier of each stored procedure with the corresponding The usage or call count is stored in a data structure (e.g. table etc.). In addition, each compute node 104 may track the number of instances assigned to that compute node that suffered a miss in the corresponding compute node 104 (i.e., one or more stored procedures requested access to or updated data that does not exist in that compute node 104). One or more stored procedures. Each computing node 104 may store the identifier of such a stored procedure and the corresponding miss count of the stored procedure in a specific data structure (such as a list, etc.) within a preset time interval.
在实现方式中,监控节点110可以从负载均衡节点108接收存储过程被用户单独调用或使用的相应次数的信息,并进一步从每个计算节点104收集未命中过程的标识和相应的未命中次数。然后,监视节点110可以确定每个存储过程的相应错误率(例如确定使用或调用导致未命中的存储过程的占比)。监控节点110可以将每个存储过程的错误率与预定错误阈值进行比较,选择错误率最高且错误率高于该预定错误阈值的存储过程的预测函数进行更新或者重新训练。In an implementation manner, the monitoring node 110 may receive from the load balancing node 108 the information of the corresponding number of times the stored procedure is invoked or used by the user alone, and further collect the identifier of the miss procedure and the corresponding miss count from each computing node 104 . The monitoring node 110 can then determine a corresponding error rate for each stored procedure (eg, determine the fraction of stored procedures whose use or invocation resulted in a miss). The monitoring node 110 can compare the error rate of each stored procedure with a predetermined error threshold, and select the prediction function of the stored procedure with the highest error rate and the error rate higher than the predetermined error threshold to update or retrain.
在块504处,监控节点110可以确定用于对存储过程相关联的预测函数进行训练的一个或多个输入参数。At
在实现方式中,在选择存储过程时,监视节点110可以确定一个或多个输入参数,这些输入参数可以用于针对存储过程训练预测函数。在实现方式中,存储过程可以包括参数列表,该参数列表包括至少一个输入参数,并且监控节点110可以使用参数列表中包括的至少一个输入参数作为用于针对存储过程训练预测函数的候选输入参数。In an implementation, upon selecting a stored procedure, monitoring node 110 may determine one or more input parameters that may be used to train a predictive function for the stored procedure. In an implementation, the stored procedure may include a parameter list including at least one input parameter, and the monitoring node 110 may use the at least one input parameter included in the parameter list as candidate input parameters for training the prediction function for the stored procedure.
附加地或可选地,监控节点110可以执行静态程序分析从存储过程中提取一个或多个候选输入参数。静态程序分析也可以称为编译时分析,是一种在程序代码运行前对程序代码进行分析以预测该程序代码运行时行为的算法。监控节点110可以采用静态程序分析来确定哪些输入参数决定或影响数据分片,存储过程中的一个或多个查询请求会在该数据片进行操作(例如,访问或更新)。在实现方式中,监控节点110可以识别在存储过程中用作一个或多个分区键的一个或多个变量。例如,对于存储过程中的SELECT查询请求,监控节点110可以在FROM子句中找到分布式表,并且识别可以用于与这些分布式表的各个分区列进行比较的变量。类似的方法也可用于UPDATE、INSERT和DELETE查询请求。Additionally or alternatively, monitoring node 110 may perform static program analysis to extract one or more candidate input parameters from the stored procedure. Static program analysis can also be called compile-time analysis, which is an algorithm that analyzes the program code before the program code runs to predict the runtime behavior of the program code. Monitoring node 110 may employ static program analysis to determine which input parameters determine or affect data slices on which one or more query requests in a stored procedure operate (eg, access or update). In an implementation, monitoring node 110 may identify one or more variables used as one or more partition keys in the stored procedure. For example, for a SELECT query request in a stored procedure, the monitoring node 110 can find distributed tables in the FROM clause, and identify variables that can be used for comparison with respective partition columns of these distributed tables. Similar methods are also available for UPDATE, INSERT, and DELETE query requests.
例如,一个存储过程,如payment_proc,可以表示如下。在此示例中,第一个UPDATE用于更新目标表,即仓库表,并且将变量in_w_zip与相应的分区列,warehouse_zip,进行比较。For example, a stored procedure, such as payment_proc, can be represented as follows. In this example, the first UPDATE is used to update the target table, the warehouse table, and the variable in_w_zip is compared to the corresponding partition column, warehouse_zip.
在实现方式中,监视节点110可以计算可能影响存储过程的一个或多个查询请求中的分区键的值的所有变量的传递闭包。如上所述,监控节点110可以采用数据流分析来估计根据控制流图可到达的程序点之间的数据流的变量的可能的值。为了定位其值可能影响存储过程中查询请求的分区键的所有变量,监控节点110可以以查询请求的分区键为起点,逆向追踪该数据流的变量的值,直到从起点传递可及的所有链路都被遍历。在实现方式中,监控节点110可以使用图遍历算法来执行这样的操作。在实现方式中,监控节点110在获取到其值可能影响查询请求的分区键的变量之后,可以将这些变量设置为候选输入参数。监控节点110可以对存储过程中的所有查询请求的所有分区键重复上述操作,从而得到可能影响存储过程的所有查询请求的分区键的候选输入参数集合。在实现方式中,监控节点110可以将这些可能影响存储过程的查询请求的分区键的候选输入参数设置为用于对与存储过程相关联的预测函数进行训练的一个或多个输入参数。In an implementation, the monitoring node 110 may compute a transitive closure of all variables that may affect the value of a partition key in one or more query requests of the stored procedure. As described above, monitoring node 110 may employ data flow analysis to estimate possible values of variables of data flow between program points reachable according to the control flow graph. In order to locate all variables whose values may affect the partition key of the query request in the stored procedure, the monitoring node 110 can use the partition key of the query request as a starting point, trace back the value of the variable of the data flow, until all the chains reachable from the starting point are passed All roads are traversed. In an implementation, monitoring node 110 may use a graph traversal algorithm to perform such operations. In an implementation manner, after the monitoring node 110 obtains variables whose values may affect the partition key of the query request, these variables may be set as candidate input parameters. The monitoring node 110 may repeat the above operations for all partition keys of all query requests in the stored procedure, so as to obtain a set of candidate input parameters of partition keys that may affect all query requests of the stored procedure. In an implementation manner, the monitoring node 110 may set these candidate input parameters of the partition key that may affect the query request of the stored procedure as one or more input parameters for training the prediction function associated with the stored procedure.
在块506处,监控节点110可以获得历史数据,包括存储过程的一个或多个输入参数的多个值集和多个数据分片的标识。At
在实现方式中,监控节点110可以从多个计算节点104和负载均衡节点108获得历史数据。在实现方式中,历史数据可以包括但不限于存储过程的一个或多个输入参数的多个值集和多个数据分片的标识。在实现方式中,多个数据分片中的每个数据分片可以包括在一个或多个输入参数采用多个值集中的相应值集时由该存储过程评估的对应数据片段。In an implementation, the monitoring node 110 may obtain historical data from the plurality of computing nodes 104 and load balancing nodes 108 . In an implementation manner, the historical data may include, but not limited to, multiple value sets of one or more input parameters of the stored procedure and identifiers of multiple data fragments. In an implementation, each data slice of the plurality of data slices may include a corresponding data slice that is evaluated by the stored procedure when one or more input parameters take a corresponding set of values of the plurality of value sets.
在块508处,监控节点110可以将多个值集用作输入并且将多个数据分片的对应标识用作输出来训练分类模型。At
在实现方式中,监控节点110可以基于历史数据训练分类模型,该防雷模型用于学习或模仿该存储过程的预测函数的行为。在实现方式中,监控节点110可以采用监督训练来训练并获得分类模型。在实现方式中,分类模型可以包括但不限于神经网络模型、深度学习模型、决策树模型等。In an implementation, the monitoring node 110 can train a classification model based on historical data, and the lightning protection model is used to learn or imitate the behavior of the prediction function of the stored procedure. In an implementation, the monitoring node 110 may use supervised training to train and obtain a classification model. In an implementation manner, the classification model may include but not limited to a neural network model, a deep learning model, a decision tree model, and the like.
作为示例而非限制,一示例中,神经网络模型被用作分类模型,以学习或模仿存储过程的预测函数的行为。在该示例中,在块504获得或确定的存储过程的一个或多个输入参数可以用作神经网络模型的输入(或输入特征),并且该一个或多个参数的历史值(或值集)是输入特征的训练值。在实现方式中,每个存储过程可以包括一个或多个查询请求,并且可以对一个或多个数据库表的一个或多个数据分片执行操作(例如,访问、更新等)。在这种情况下,监控节点110可以从一个或多个数据库表的一个或多个数据分片中选择操作最频繁的数据分片。在实现方式中,存储过程的操作最频繁的数据分片可以包括但不限于被存储过程中的查询请求访问或影响的行数最多的数据分片等。在实现方式中,监控节点110可以将操作最频繁的数据分片视为神经网络模型的相应输出(或标签)。在实现方式中,可以通过监视存储过程的执行、记录各个输入参数以及被访问的相应数据分片以及被访问或影响的相应行数等来获得这样的特征-标签对。然后,监视节点110可以使用传统的训练或学习算法来训练该神经网络模型。By way of example and not limitation, in one example, a neural network model is used as a classification model to learn or mimic the behavior of a stored procedure's prediction function. In this example, one or more input parameters of the stored procedure obtained or determined at
在块510处,监控节点110可以将经训练的分类模型设置为预测函数,用于将存储过程的一个或多个输入参数的新值集映射到对应的数据分片。At
在实现方式中,在完成分类模型的训练之后,监控节点110可以将经训练的分类模型用作存储过程的预测函数。在实现方式中,监控节点110可以将预测函数发送到负载均衡节点108,使得负载均衡节点108可以使用该预测函数将具有针对一个或多个输入参数设置的任何新输入值集的存储过程映射到对应的数据分片(例如,数据分片的标识),该数据分片可能存储有会被该存储过程的至少一个查询请求访问或更新的数据。In an implementation, after completing the training of the classification model, the monitoring node 110 may use the trained classification model as a prediction function of the stored procedure. In an implementation, monitoring node 110 may send the prediction function to load balancing node 108 so that load balancing node 108 may use the prediction function to map stored procedures with any new set of input values for one or more input parameter settings to A corresponding data fragment (for example, an identifier of the data fragment), which may store data that will be accessed or updated by at least one query request of the stored procedure.
在实现方式中,监控节点110可以继续接收新数据和数据分片的标识,该新数据与每个存储过程的一个或多个输入参数的新值集相关联,该数据分片分别包括当一个或多个输入参数采用新值集时由每个存储过程评估的相应数据段,该新值集周期性地从多个计算节点104和负载平衡节点108获取。监控节点110可以基于新数据和先前存储的数据根据如块502至块510中描述的操作来选择存储过程并针对该存储过程重新训练预测函数。In an implementation, the monitoring node 110 may continue to receive new data and identifications of data fragments associated with new value sets for one or more input parameters of each stored procedure, the data fragments respectively including when a The corresponding data segment evaluated by each stored procedure when the or plurality of input parameters assumes a new value set, which is periodically obtained from the plurality of computing nodes 104 and load balancing nodes 108 . The monitoring node 110 may select a stored procedure and retrain the predictive function for the stored procedure according to operations as described in
尽管在上述操作中,预测函数被描述为针对每个存储过程进行训练并且与每个存储过程相关联,但是在某些情况下,预测函数可以针对一组存储过程进行训练并与之相关联。在这种情况下,预测函数的输入(即,输入参数)可以包括如块504中所述从存储过程集合中的每个存储过程获得的候选输入参数的组合,并且预测器的输出可以包括可能存储或包括要由相应存储过程查询或更新的数据的数据分片的标识。在实现方式中,监控节点110可以自动将具有相似候选输入参数的存储过程划为一组,或者根据用户的请求将存储过程划为一组。Although in the above operations the prediction function is described as being trained for and associated with each stored procedure, in some cases the prediction function may be trained for and associated with a set of stored procedures. In this case, the input to the prediction function (i.e., the input parameters) may include combinations of candidate input parameters obtained from each stored procedure in the set of stored procedures as described in
返回参照图6,在块602处,负载均衡节点108可以接收包括至少一个查询过程的分布式数据库事务。Referring back to FIG. 6, at
在实现方式中,数据库系统102或数据库系统102的负载均衡节点108可以从客户端设备112接收包括至少一个查询过程的分布式数据库事务。在实现方式中,该至少一个查询过程可以包括一个或多个查询请求,其访问或操作位于数据库系统102的一个或多个计算节点(例如计算节点104)中的一个或多个数据库表的一个或更多个数据分片的数据。In an implementation, database system 102 or load balancing node 108 of database system 102 may receive a distributed database transaction from client device 112 that includes at least one query process. In an implementation, the at least one query process may include one or more query requests that access or manipulate one of the one or more database tables located in one or more computing nodes (e.g., computing node 104) of database system 102. or more data shards.
在块604处,负载均衡节点108可以确定该至少一个查询过程是否为预先存储的过程。At
在实现方式中,查询过程可以是预先注册并存储在数据库系统102中的过程(即,存储过程),或者是未在数据库系统102中注册而是由用户114根据他/她的需要以某种查询语言(例如SQL语言)编写的过程。如果查询过程是注册的存储过程,则该存储过程的一个或多个输入参数的值可以在该存储过程被发送到数据库系统102时由用户114进一步提供。在实现方式中,一个或多个输入参数可以包括与该存储过程中包括的一个或多个查询请求相关联的一个或多个潜在分区键值。In an implementation, the query process can be a process that is pre-registered and stored in the database system 102 (i.e., a stored procedure), or it can be a process that is not registered in the database system 102 but is performed by the user 114 according to his/her needs in some way. A procedure written in a query language such as SQL. If the query procedure is a registered stored procedure, values for one or more input parameters of the stored procedure may be further provided by the user 114 when the stored procedure is sent to the database system 102 . In an implementation, the one or more input parameters may include one or more potential partition key values associated with one or more query requests included in the stored procedure.
在实现方式中,多个存储过程可以注册并存储在数据库系统102中,并且可以由用户114调用。为了区分不同的存储过程,可以为每个存储过程分配一个唯一标识,该标识可以唯一地表示相应的存储过程。存储过程的唯一标识可以包括但不限于存储过程的唯一名称、存储过程的唯一索引等。在实现方式中,存储过程可以包括一个或多个输入参数或对象,用户114可以通过输入参数或对象向存储过程提供输入值。例如,在上述示例(payment_proc)这一存储过程中,存储过程可以关联唯一名称,即payment_proc,该唯一名称可以唯一地标识该存储过程,并且将该存储过程与数据库系统102中的其他存储过程区分开。示例姓地,存储过程还可以包括参数列表,该参数列表包括由用户114提供或输入的多个输入参数(即,in_w_idinteger、in_w_zip integer、in_c_idinteger、in_c_zip integer、in_payment_amountdecimal)In an implementation, a number of stored procedures can be registered and stored in database system 102 and can be invoked by users 114 . In order to distinguish different stored procedures, each stored procedure can be assigned a unique identifier, which can uniquely represent the corresponding stored procedure. The unique identifier of the stored procedure may include but not limited to a unique name of the stored procedure, a unique index of the stored procedure, and the like. In an implementation, a stored procedure may include one or more input parameters or objects through which a user 114 may provide input values to the stored procedure. For example, in the stored procedure of the above example (payment_proc), the stored procedure can be associated with a unique name, namely payment_proc, which can uniquely identify the stored procedure and distinguish the stored procedure from other stored procedures in the database system 102 open. Illustratively, the stored procedure may also include a parameter list that includes a number of input parameters provided or entered by the user 114 (i.e., in_w_idinteger, in_w_zip integer, in_c_idinteger, in_c_zip integer, in_payment_amountdecimal)
在实现方式中,由负载均衡节点10确定接收的查询过程是否为注册的存储过程,负载均衡节点10通过判断所接收的查询过程是否与标识(例如,名称等)相关联并且该标识在存储有数据库系统102中注册的存储过程的标识的数据结构(例如,表或列表等)中被注册或找到,来确定该查询过程是否为存储过程。继续上面的示例,负载均衡节点108可以确定接收到的查询过程是否关联有名称(例如payment_proc),如果是,则进一步确定该名称是否在存储有数据库系统102中注册的存储过程的标识的数据结构中被注册或找到。如果确定该名称被注册或找到,负载均衡节点108可以确定接收到的查询过程是注册的存储过程。可选地,如果接收到的查询过程不与任何名称相关联,或者接收到的查询过程所关联的名称未在存储有数据库系统102中注册的存储过程的标识的数据结构中注册或找到,则负载均衡节点108可以确定接收到的查询过程不是注册的存储过程。In an implementation, the load balancing node 10 determines whether the received query procedure is a registered stored procedure, and the load balancing node 10 judges whether the received query procedure is associated with an identifier (for example, a name, etc.) and the identifier is stored in the The identifier of the stored procedure registered in the database system 102 is registered or found in the data structure (for example, table or list, etc.) to determine whether the query procedure is a stored procedure. Continuing with the above example, the load balancing node 108 can determine whether the received query process is associated with a name (e.g. payment_proc), and if so, further determine whether the name is stored in the data structure of the identifier of the stored procedure registered in the database system 102 was registered or found in . If it is determined that the name is registered or found, the load balancing node 108 may determine that the received query procedure is a registered stored procedure. Optionally, if the received query procedure is not associated with any name, or the name associated with the received query procedure is not registered or found in the data structure storing the identification of the stored procedure registered in the database system 102, then The load balancing node 108 may determine that the received query procedure is not a registered stored procedure.
在块606处,负载均衡节点108可以响应于确定接收的查询过程不是注册的存储过程而采用预定的负载均衡策略来将分布式数据库事务分配给计算节点。At
在实现方式中,如果确定接收到的查询过程不是注册的存储过程,则负载均衡节点108可以采用预定的负载均衡策略将分布式数据库事务分配给数据库系统102中包括的多个计算节点104中的计算节点。作为示例而非限制,预定的负载均衡策略可以包括:将分布式数据库事务随机分配给计算节点、将分布式数据库事务以循环方式分配给计算节点、将分布式数据库事务分配给当前工作量最小的计算节点、或基于分布式数据库事务所来自的客户端设备的IP地址将分布式数据库事务分配给计算节点等。In an implementation, if it is determined that the received query process is not a registered stored process, then the load balancing node 108 can use a predetermined load balancing strategy to distribute the distributed database transaction to one of the multiple computing nodes 104 included in the database system 102 calculate node. As an example and not a limitation, the predetermined load balancing strategy may include: randomly assigning distributed database transactions to computing nodes, distributing distributed database transactions to computing nodes in a round-robin manner, and assigning distributed database transactions to computing nodes with the smallest current workload Computing nodes, or assigning distributed database transactions to computing nodes based on the IP address of the client device from which the distributed database transactions came.
在块608处,响应于确定接收到的查询过程是注册的存储过程,负载均衡节点108可以从多个预测函数中确定或选择用于该存储过程的预测函数。At
在实现方式中,在确定接收到的查询过程是注册的存储过程之后,负载均衡节点108可以确定或选择用于该存储过程的预测函数。在实现方式中,数据库系统102可以包括或存储多个预测函数,并且每个预测函数可以被配置成对一个或多个存储过程执行预测或映射。在实现方式中,负载均衡节点108可以至少部分地基于存储过程的标识(例如,名称或索引)来确定或选择用于存储过程的预测函数。In an implementation, after determining that the received query procedure is a registered stored procedure, the load balancing node 108 may determine or select a prediction function for the stored procedure. In an implementation, the database system 102 may include or store multiple predictive functions, and each predictive function may be configured to perform prediction or mapping on one or more stored procedures. In an implementation, the load balancing node 108 can determine or select a prediction function for the stored procedure based at least in part on the stored procedure's identification (eg, name or index).
在实现方式中,负载均衡节点108或数据库系统102可以包括或存储有数据结构(例如表等),该数据结构包括多个存储过程与多个预测函数之间的映射关系,例如多个存储过程的标识与多个预测函数的标识之间的映射关系,或者多个存储过程的标识与多个预测函数的存储位置之间的映射关系等。负载均衡节点108可以至少部分地基于存储过程的标识从包括多个存储过程与多个预测函数之间的映射关系的数据结构中确定或选择针对存储过程的预测函数。In an implementation, the load balancing node 108 or the database system 102 may include or store a data structure (such as a table, etc.), and the data structure includes a mapping relationship between multiple stored procedures and multiple predictive functions, such as multiple stored procedures The mapping relationship between identifiers of multiple predictive functions, or the mapping relationship between identifiers of multiple stored procedures and storage locations of multiple predictive functions, etc. The load balancing node 108 may determine or select a prediction function for a stored procedure from a data structure including a mapping relationship between a plurality of stored procedures and a plurality of prediction functions based at least in part on the identification of the stored procedure.
作为示例而非限制,负载均衡节点108可以确定或获得存储过程的标识,基于存储过程的标识和映射关系获得预测函数的标识,并基于预测函数的标识在多个预测函数中选择预测函数。As an example and not a limitation, the load balancing node 108 may determine or obtain the identifier of the stored procedure, obtain the identifier of the predictive function based on the identifier of the stored procedure and the mapping relationship, and select a predictive function from multiple predictive functions based on the identifier of the predictive function.
在实现方式中,每个预测函数可以包括分类模型,该分类模型基于多个分区键值和多个分片的对应标识训练得到,多个分片包括与数据库表中的多个分区键值对应的数据段,并且多个分片可以分别存储在多个计算节点中。作为示例而非限制,分类模型可以包括神经网络模型。In an implementation, each prediction function may include a classification model, the classification model is trained based on multiple partition key values and corresponding identifications of multiple fragments, and the multiple fragments include The data segment, and multiple shards can be stored in multiple computing nodes. By way of example and not limitation, classification models may include neural network models.
在块610处,负载均衡节点108可以提取或确定存储过程的一个或多个输入参数的输入值。At
在实现方式中,存储过程可以包括参数列表,用户114可以通过该参数列表输入存储过程的一个或多个输入参数的值。负载均衡节点108可以从参数列表中提取或确定存储过程的一个或多个输入参数的输入值。在实现方式中,负载均衡节点108可以使用静态程序分析来提取或确定存储过程的一个或多个输入参数的输入值。In an implementation, a stored procedure may include a parameter list through which a user 114 may enter values for one or more input parameters of the stored procedure. The load balancing node 108 may extract or determine input values for one or more input parameters of the stored procedure from the parameter list. In an implementation, load balancing node 108 may use static program analysis to extract or determine input values for one or more input parameters of the stored procedure.
在块612处,负载均衡节点108可以至少部分地基于预测函数和存储过程的一个或多个输入参数的输入值来确定存储过程被发送或分配到的计算节点。At
在实现方式中,在确定预测函数和存储过程的一个或多个输入参数的输入值之后,负载均衡节点108可以确定存储过程被发送或分配到的计算节点。在实现方式中,负载均衡节点108可以将预测函数应用于存储过程的一个或多个输入参数的输入值,以产生该预测函数的输出。在实现方式中,预测函数的输出可以是与存储过程的至少一个查询请求潜在地或可能访问或查询的数据的位置相关的标签。在实现方式中,该标签可以包括数据库表的数据分片的标识,该数据库表包括或存储潜在地或可能被存储过程的至少一个查询请求访问或查询的数据。在实现方式中,负载均衡节点108然后可以采用放置函数来将数据分片的标识映射到包括或存储该数据分片的计算节点的标识。In an implementation, after determining input values for the prediction function and one or more input parameters of the stored procedure, the load balancing node 108 may determine the compute nodes to which the stored procedure is sent or distributed. In an implementation, load balancing node 108 may apply a predictive function to input values of one or more input parameters of a stored procedure to produce an output of the predictive function. In an implementation, the output of the prediction function may be a label associated with a location of data potentially or likely to be accessed or queried by at least one query request of the stored procedure. In an implementation, the tag may include an identification of a data slice of a database table that includes or stores data potentially or likely to be accessed or queried by at least one query request of the stored procedure. In an implementation, the load balancing node 108 may then employ a placement function to map the identification of the data slice to the identification of the compute node that includes or stores the data slice.
在实现方式中,多个预测函数中的每个预测函数可以与分区函数组合以形成相应的组合预测-分区函数,并被赋予与相应预测函数相同的标识。在这种情况下,负载均衡节点108可以直接使用组合预测-分区函数来获得存储过程被分配到的计算节点的标识。In an implementation, each predictive function of the plurality of predictive functions may be combined with a partition function to form a corresponding combined predictive-partition function, and given the same identification as the corresponding predictive function. In this case, the load balancing node 108 can directly use the combined prediction-partition function to obtain the identity of the compute node to which the stored procedure is assigned.
在块614处,负载均衡节点可以将存储过程发送到该计算节点。At
在确定计算节点的标识后,负载均衡节点可以将存储过程发送给该计算节点,以允许该计算节点对该存储过程进行处理,和/或作为控制节点协调和管理对该存储过程的处理。After determining the identity of the computing node, the load balancing node can send the stored procedure to the computing node, so as to allow the computing node to process the stored procedure, and/or coordinate and manage the processing of the stored procedure as a control node.
尽管上述方法块被描述为以特定顺序执行,但在一些实现方式中,这些方法块中的一些或全部可以以其他顺序执行或并行执行。Although the above method blocks are described as being performed in a particular order, in some implementations some or all of these method blocks may be performed in other orders or in parallel.
结论in conclusion
尽管已经以特定于结构特征和/或方法动作的语言描述了实现方式,但是应当理解,权利要求不一定限于所描述的特定特征或动作。相反,具体特征和动作被公开为实现所要求保护的主题的示例性形式。附加地或替选地,操作中的一些或全部可以由一个或多个ASIC、FPGA或其他硬件实现。Although implementations have been described in language specific to structural features and/or methodological acts, it is to be understood that claims are not necessarily limited to the specific features or acts described. Rather, the specific features and acts are disclosed as example forms of implementing the claimed subject matter. Additionally or alternatively, some or all of the operations may be implemented by one or more ASICs, FPGAs, or other hardware.
使用以下条款可以进一步理解本公开。The disclosure can be further understood using the following terms.
条款1:一种由负载均衡节点实现的方法,所述方法包括:接收包括存储过程的分布式事务;从多个预测函数中选择针对所述存储过程的预测函数;从存储过程中提取一个或多个输入参数;使用所述预测函数至少部分地基于所述一个或多个输入参数确定计算节点;以及将所述存储过程转发给所述计算节点以对所述存储过程进行处理。Clause 1: A method implemented by a load balancing node, the method comprising: receiving a distributed transaction including a stored procedure; selecting a predictive function for the stored procedure from a plurality of predictive functions; extracting one or a plurality of input parameters; using the predictive function to determine a compute node based at least in part on the one or more input parameters; and forwarding the stored procedure to the compute node for processing the stored procedure.
条款2:条款1所述的方法,其中,所述一个或多个输入参数包括与所述存储过程中包括的一个或多个查询请求相关联的一个或多个分区键值。Clause 2: The method of Clause 1, wherein the one or more input parameters include one or more partition key values associated with one or more query requests included in the stored procedure.
条款3:条款1所述的方法,其中,从所述多个预测函数中选择针对所述存储过程的所述预测函数包括:确定所述存储过程的标识;根据所述存储过程的标识和映射关系获得所述预测函数的标识;以及基于所述预测函数的标识,从所述多个预测函数中选择所述预测函数。Clause 3: The method of clause 1, wherein selecting the predictive function for the stored procedure from the plurality of predictive functions comprises: determining an identity of the stored procedure; mapping based on the identity of the stored procedure obtaining an identification of the predictive function; and selecting the predictive function from the plurality of predictive functions based on the identification of the predictive function.
条款4:条款1所述的方法,其中,从所述存储过程中提取所述一个或多个输入参数包括:从所述存储过程的参数列表中提取所述一个或多个输入参数或使用静态程序分析从所述存储过程中提取所述一个或多个输入参数。Clause 4: The method of clause 1, wherein extracting the one or more input parameters from the stored procedure comprises extracting the one or more input parameters from a parameter list of the stored procedure or using a static Program analysis extracts the one or more input parameters from the stored procedure.
条款5:条款1所述的方法,其中,所述存储过程包括在被调用之前预先注册并存储在数据库系统中的存储过程。Clause 5: The method of clause 1, wherein the stored procedure comprises a stored procedure that is pre-registered and stored in the database system before being invoked.
条款6:条款1所述的方法,其中,至少部分地基于所述一个或多个输入参数确定所述计算节点包括:基于所述一个或多个输入参数、利用所述预测函数确定与所述存储过程中包括的至少一个查询请求相关联的数据分片的标识;以及基于所述数据分片的标识,利用放置函数确定所述计算节点的标识,所述计算节点存储所述数据分片。Clause 6: The method of Clause 1, wherein determining the computing node based at least in part on the one or more input parameters comprises: using the predictive function to determine a relationship with the storing an identifier of the at least one query request associated with the data fragment; and based on the identifier of the data fragment, using a placement function to determine the identifier of the computing node storing the data fragment.
条款7:条款1所述的方法,其中,所述预测函数包括分类模型,所述分类模型是基于多个分区键值和多个分片的对应标识训练的,所述多个分片包括数据库表中与所述多个分区键值对应的各个数据段,所述多个分片单独存储在多个计算节点中。Clause 7: The method of Clause 1, wherein the prediction function comprises a classification model trained based on a plurality of partition key values and corresponding identifications of a plurality of shards, the plurality of shards comprising a database Each data segment corresponding to the multiple partition key values in the table, the multiple fragments are separately stored in multiple computing nodes.
条款8:条款7所述的方法,其中,所述分类模型包括神经网络模型。Clause 8: The method of Clause 7, wherein the classification model comprises a neural network model.
条款9:一种计算机可读介质,其存储可执行指令,当所述可执行指令由一个或多个处理器执行时,使所述一个或多个处理器执行下述动作:对存储过程执行静态程序分析以确定一个或多个输入参数;获得存储数据,所述存储数据包括所述存储过程的所述一个或多个输入参数的多个值集,以及多个数据分片的标识;将所述多个值集作为输入、将所述多个数据分片的对应标识用作输出,训练分类模型;以及将经训练的分类模型设置为预测函数,所述预测函数用于将所述存储过程的所述一个或多个输入参数的新值集映射到对应的数据分片。Clause 9: A computer-readable medium storing executable instructions that, when executed by one or more processors, cause the one or more processors to perform the following actions: Execute a stored procedure Static program analysis to determine one or more input parameters; obtain stored data, the stored data includes a plurality of value sets for the one or more input parameters of the stored procedure, and identification of a plurality of data slices; The plurality of value sets are used as input, the corresponding identifiers of the plurality of data slices are used as output, and a classification model is trained; and the trained classification model is set as a prediction function, and the prediction function is used to use the stored A new set of values for the one or more input parameters of the process is mapped to a corresponding data slice.
条款10:条款9所述的计算机可读介质,其中,所述多个数据分片中的各个数据分片包括当所述一个或多个输入参数采用所述多个值集中的相应值集时由所述存储过程评估的对应数据段。Clause 10: The computer-readable medium of Clause 9, wherein each data slice of the plurality of data slices comprises when the one or more input parameters take a corresponding set of values in the plurality of sets of values The corresponding data segment evaluated by the stored procedure.
条款11:条款9所述的计算机可读介质,其中,对所述存储过程执行所述静态程序分析以确定所述一个或多个输入参数包括:识别表示所述存储过程中包括的至少一个查询请求中的分区键的变量;以及利用图遍历算法确定所述变量的一个或多个输入参数。Clause 11: The computer-readable medium of Clause 9, wherein performing the static program analysis on the stored procedure to determine the one or more input parameters comprises: identifying at least one query representing a query included in the stored procedure A variable for the partition key in the request; and one or more input parameters for determining the variable using a graph traversal algorithm.
条款12:条款9所述的计算机可读介质,其中,所述分类模型包括神经网络模型。Clause 12: The computer-readable medium of Clause 9, wherein the classification model comprises a neural network model.
条款13:条款9所述的计算机可读介质,还包括:将所述分类模型发送到负载均衡节点。Clause 13: The computer-readable medium of Clause 9, further comprising: sending the classification model to a load balancing node.
条款14:条款9所述的计算机可读介质,还包括:从多个计算节点接收与所述存储过程的所述一个或多个输入参数的新值集相关联的新数据,以及数据分片的标识,所述数据分片包括当所述一个或多个输入参数采用所述新值集时由所述存储过程评估的对应数据段。Clause 14: The computer-readable medium of Clause 9, further comprising: receiving new data associated with a new set of values for the one or more input parameters of the stored procedure from a plurality of computing nodes, and data sharding An identification of , the data shard comprising corresponding data segments evaluated by the stored procedure when the one or more input parameters assume the new set of values.
条款15:条款14所述的计算机可读介质,还包括:至少部分地基于存储数据和新数据重新训练所述分类模型。Clause 15: The computer-readable medium of Clause 14, further comprising: retraining the classification model based at least in part on stored data and new data.
条款16:一种系统,包括:一个或多个处理器;以及存储器,所述存储器存储可执行指令,当所述可执行指令由所述一个或多个处理器执行时,使所述一个或多个处理器执行下述动作:对存储过程执行静态程序分析以确定一个或多个输入参数;获得存储数据,所述存储数据包括所述存储过程的所述一个或多个输入参数的多个值集,以及多个数据分片的标识;将所述多个值集用作输入、将所述多个数据分片的对应标识用作输出,训练分类模型;以及将经训练的分类模型设置为预测函数,所述预测函数用于将所述存储过程的所述一个或多个输入参数的新值集映射到对应的数据分片。Clause 16: A system comprising: one or more processors; and memory storing executable instructions that, when executed by the one or more processors, cause the one or more The plurality of processors perform acts of: performing static program analysis on a stored procedure to determine one or more input parameters; obtaining stored data including a plurality of the one or more input parameters of the stored procedure Value set, and the identification of a plurality of data slices; Using the multiple value sets as input, using the corresponding identification of the multiple data slices as output, training classification model; and setting the trained classification model is a prediction function, and the prediction function is used to map the new value set of the one or more input parameters of the stored procedure to the corresponding data slice.
条款17:条款16所述的系统,其中,所述多个数据分片中的各个数据分片包括当所述一个或多个输入参数采用所述多个值集中的相应值集时由所述存储过程评估的对应数据段。Clause 17: The system of Clause 16, wherein each data slice of the plurality of data slices comprises the The corresponding data segment for the stored procedure evaluation.
条款18:条款16所述的系统,其中,对所述存储过程执行所述静态程序分析以确定所述一个或多个输入参数包括:识别表示所述存储过程中包括的至少一个查询请求中的分区键的变量;以及利用图遍历算法确定所述变量的一个或多个输入参数。Clause 18: The system of Clause 16, wherein performing the static program analysis on the stored procedure to determine the one or more input parameters comprises: identifying an a variable for the partition key; and determining one or more input parameters for the variable using a graph traversal algorithm.
条款19:条款16所述的系统,其中,所述分类模型包括神经网络模型。Clause 19: The system of Clause 16, wherein the classification model comprises a neural network model.
条款20:条款16所述的系统,其中,所述动作还包括:从多个计算节点接收与所述存储过程的所述一个或多个输入参数的新值集相关联的新数据,以及数据分片的标识,所述数据分片分别包括当所述一个或多个输入参数采用所述新值集时由所述存储过程评估的对应数据段;以及至少部分地基于存储数据和所述新数据重新训练所述分类模型。Clause 20: The system of Clause 16, wherein the actions further comprise: receiving from a plurality of computing nodes new data associated with a new set of values for the one or more input parameters of the stored procedure, and data identification of slices, said slices of data respectively comprising corresponding data segments evaluated by said stored procedure when said one or more input parameters assume said new set of values; and based at least in part on stored data and said new set of values data to retrain the classification model.
Claims (20)
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2020/112265 WO2022041143A1 (en) | 2020-08-28 | 2020-08-28 | Smart procedure routing in partitioned database management systems |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN115803715A true CN115803715A (en) | 2023-03-14 |
| CN115803715B CN115803715B (en) | 2025-02-21 |
Family
ID=80352509
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202080102917.6A Active CN115803715B (en) | 2020-08-28 | 2020-08-28 | Intelligent Process Routing in Partitioned Database Management Systems |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN115803715B (en) |
| WO (1) | WO2022041143A1 (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116562394A (en) * | 2023-04-27 | 2023-08-08 | 广州欢聚时代信息科技有限公司 | Method, device, equipment and medium for invoking feature data of deep learning model |
Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8418181B1 (en) * | 2009-06-02 | 2013-04-09 | Amazon Technologies, Inc. | Managing program execution based on data storage location |
| US8762299B1 (en) * | 2011-06-27 | 2014-06-24 | Google Inc. | Customized predictive analytical model training |
| JP2017126131A (en) * | 2016-01-12 | 2017-07-20 | 日本電信電話株式会社 | Rebalancing device, rebalancing method, and program |
| CN108351900A (en) * | 2015-10-07 | 2018-07-31 | 甲骨文国际公司 | Relational database organization for sharding |
| CN109523123A (en) * | 2018-10-12 | 2019-03-26 | 平安科技(深圳)有限公司 | A kind of the intelligent allocation method and server of distributing real time system |
| US20190095785A1 (en) * | 2017-09-26 | 2019-03-28 | Amazon Technologies, Inc. | Dynamic tuning of training parameters for machine learning algorithms |
| CN110321214A (en) * | 2018-03-29 | 2019-10-11 | 阿里巴巴集团控股有限公司 | A kind of data query method, device and equipment |
| US20190370601A1 (en) * | 2018-04-09 | 2019-12-05 | Nutanix, Inc. | Machine learning model that quantifies the relationship of specific terms to the outcome of an event |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20160210313A1 (en) * | 2015-01-16 | 2016-07-21 | Futurewei Technologies, Inc. | System for high-throughput handling of transactions in a data-partitioned, distributed, relational database management system |
| EP3529754B1 (en) * | 2017-01-10 | 2025-05-21 | Huawei Technologies Co., Ltd. | Systems and methods for fault tolerance recover during training of a model of a classifier using a distributed system |
| CN110334036A (en) * | 2019-06-28 | 2019-10-15 | 京东数字科技控股有限公司 | A kind of method and apparatus for realizing data cached scheduling |
| CN110362611B (en) * | 2019-07-12 | 2021-07-09 | 拉卡拉支付股份有限公司 | Database query method and device, electronic equipment and storage medium |
-
2020
- 2020-08-28 CN CN202080102917.6A patent/CN115803715B/en active Active
- 2020-08-28 WO PCT/CN2020/112265 patent/WO2022041143A1/en not_active Ceased
Patent Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8418181B1 (en) * | 2009-06-02 | 2013-04-09 | Amazon Technologies, Inc. | Managing program execution based on data storage location |
| US8762299B1 (en) * | 2011-06-27 | 2014-06-24 | Google Inc. | Customized predictive analytical model training |
| CN108351900A (en) * | 2015-10-07 | 2018-07-31 | 甲骨文国际公司 | Relational database organization for sharding |
| JP2017126131A (en) * | 2016-01-12 | 2017-07-20 | 日本電信電話株式会社 | Rebalancing device, rebalancing method, and program |
| US20190095785A1 (en) * | 2017-09-26 | 2019-03-28 | Amazon Technologies, Inc. | Dynamic tuning of training parameters for machine learning algorithms |
| CN110321214A (en) * | 2018-03-29 | 2019-10-11 | 阿里巴巴集团控股有限公司 | A kind of data query method, device and equipment |
| US20190370601A1 (en) * | 2018-04-09 | 2019-12-05 | Nutanix, Inc. | Machine learning model that quantifies the relationship of specific terms to the outcome of an event |
| CN109523123A (en) * | 2018-10-12 | 2019-03-26 | 平安科技(深圳)有限公司 | A kind of the intelligent allocation method and server of distributing real time system |
Non-Patent Citations (2)
| Title |
|---|
| A. THANTHARATE, R. PAROPKARI, V. WALUNJ AND C. BEARD: "DeepSlice: A Deep Learning Approach towards an Efficient and Reliable Network Slicing in 5G Networks", 2019 IEEE 10TH ANNUAL UBIQUITOUS COMPUTING, ELECTRONICS & MOBILE COMMUNICATION CONFERENCE (UEMCON), 13 February 2020 (2020-02-13) * |
| 孙良: "一种分布式智能信息检索系统的研究与实现", 中国优秀硕士学位论文全文数据库, 31 December 2002 (2002-12-31) * |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116562394A (en) * | 2023-04-27 | 2023-08-08 | 广州欢聚时代信息科技有限公司 | Method, device, equipment and medium for invoking feature data of deep learning model |
Also Published As
| Publication number | Publication date |
|---|---|
| WO2022041143A1 (en) | 2022-03-03 |
| CN115803715B (en) | 2025-02-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20190026335A1 (en) | Query engine selection | |
| CN104903894B (en) | System and method for distributed database query engine | |
| CN112650759B (en) | Data query method, device, computer equipment and storage medium | |
| US10565201B2 (en) | Query processing management in a database management system | |
| EP3259681B1 (en) | Method and device for deciding where to execute subqueries of an analytics continuous query | |
| US20150350324A1 (en) | Method and system for storing distributed graph data | |
| US9229960B2 (en) | Database management delete efficiency | |
| US11366809B2 (en) | Dynamic creation and configuration of partitioned index through analytics based on existing data population | |
| US11126641B2 (en) | Optimized data distribution system | |
| Shaikh et al. | GeoFlink: A distributed and scalable framework for the real-time processing of spatial streams | |
| US20200081903A1 (en) | Splitting transaction and analysis queries | |
| US10191947B2 (en) | Partitioning advisor for online transaction processing workloads | |
| US11645283B2 (en) | Predictive query processing | |
| Miao et al. | Task assignment with efficient federated preference learning in spatial crowdsourcing | |
| Khemmarat et al. | Fast top-k path-based relevance query on massive graphs | |
| CN102981913B (en) | Inference control method and inference control system with support on large-scale distributed incremental computation | |
| Davoudian et al. | A workload-adaptive streaming partitioner for distributed graph stores | |
| He et al. | GLAD: A Grid and Labeling Framework with Scheduling for Conflict-Aware $ k $ k NN Queries | |
| Sebaa et al. | Query optimization in cloud environments: challenges, taxonomy, and techniques: A. Sebaa, A. Tari | |
| CN115917525A (en) | Routing directives for partitioning databases | |
| US9229969B2 (en) | Management of searches in a database system | |
| Firth et al. | TAPER: query-aware, partition-enhancement for large, heterogenous graphs | |
| CN115795521A (en) | Access control method, device, electronic device and storage medium | |
| Hao et al. | Efficient and scalable distributed graph structural clustering at billion scale | |
| Malensek et al. | Trident: Distributed storage, analysis, and exploration of multidimensional phenomena |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |