Multi-tenant database management method and device, equipment, medium and program product
By determining the priority of the tenant database and performing parallel and/or serial updates, the problem of inefficient manual update in the prior art is solved, and a more efficient database update process is achieved.
Patent Information
- Application Number
- CN202510364407.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, data sorting and updating of multiple tenant databases is required manually, which is inefficient and error-prone.
By responding to database update requests, the priority of each tenant to be executed, the priority of the SQL group, and the priority of SQL are determined, and parallel and/or serial updates are performed based on these priorities.
Reduces execution time, improves update efficiency, and reduces the occurrence of manual errors.
Smart Images

Figure CN120216147A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular, to a multi-tenant database management method, device, equipment, medium and program product. Background Art
[0002] Currently, the network cost management system is iteratively updated by version. Each time a release is upgraded, a large number of requirements and vulnerability fixes are launched, involving a large number of database update operations that need to be executed during the upgrade.
[0003] Since the network cost management system adopts a multi-tenant mode, a set of systems is used by multiple tenants at the same time, and each tenant corresponds to a database. Therefore, database updates during version upgrades need to operate on multiple tenant databases. Most of the related technologies require manual data collation and updates for the databases of each tenant, with very low efficiency and easy errors in execution. Summary of the Invention
[0004] The present invention provides a multi-tenant database management method, device, equipment, medium and program product to solve the defect in the prior art that manual data collation and updates for the databases of each tenant are required, with very low efficiency and easy errors in execution, and to achieve reducing the execution duration and improving the update efficiency.
[0005] The present invention provides a multi-tenant database management method, and the method includes: In response to a database update request, determining the priorities of each tenant to be executed, the priorities of each structured query language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; Based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL, performing parallel and / or serial updates on the databases of each tenant to be executed.
[0006] According to the multi-tenant database management method provided by the present invention, determining the priorities of each tenant to be executed includes: Based on the configuration type of the SQL configuration information of the tenant to be executed, determining the first priority of the tenant to be executed; For at least two tenants to be executed with the same first priority, based on the tenant priorities configured in the SQL configuration information of the tenant to be executed, determining the second priorities of each tenant to be executed.
[0007] According to the multi-tenant database management method provided by the present invention, determining the priorities of each SQL group of the tenant to be executed includes: Divide all the SQL statements of the tenant to be executed into at least one SQL group; wherein, the execution tables corresponding to different SQL groups are different; Based on the execution table priority, determine the priority of each SQL group of the tenant to be executed.
[0008] According to a multi-tenant database management method provided by the present invention, determining the priority of each SQL within the SQL group includes: For different SQL statements within the SQL group of the tenant to be executed, based on the SQL priority configured in the SQL configuration information of the tenant to be executed, determine the third priority of each SQL statement; For at least two SQL statements with the same third priority, determine the fourth priority of each SQL statement based on the SQL type.
[0009] According to a multi-tenant database management method provided by the present invention, based on the priority of each tenant to be executed, the priority of each SQL group, and the priority of each SQL statement, perform parallel and / or serial updates on the databases of each tenant to be executed, including: Based on the order of the priorities of the tenants to be executed from high to low, serially schedule the tenants to be executed with each priority in turn; and When scheduling at least one SQL group of the tenant to be executed, based on the order of the priorities of the SQL groups from high to low, serially schedule the SQL groups with each priority in turn; and When scheduling the SQL statements in the same SQL group, based on the order of the priorities of the SQL statements from high to low, serially schedule the SQL statements with each priority in turn to update the database of the tenant to be executed.
[0010] According to a multi-tenant database management method provided by the present invention, it further includes: Determine at least two first tenants to be executed with the same priority and at least two second tenants to be executed with the same priority; the priority of the at least two first tenants to be executed is higher than the priority of the at least two second tenants to be executed; Parallelly schedule the at least two first tenants to be executed, and when the scheduling of the at least two first tenants to be executed is completed, parallelly schedule the at least two second tenants to be executed.
[0011] According to a multi-tenant database management method provided by the present invention, it further includes: When scheduling at least one SQL group of the tenant to be executed, determine at least two first SQL groups with the same priority and at least two second SQL groups with the same priority; the priority of the at least two first SQL groups is higher than the priority of the at least two second SQL groups; Schedule the at least two first SQL groups in parallel, and schedule the at least two second SQL groups in parallel when the scheduling of the at least two first SQL groups is completed.
[0012] According to a multi-tenant database management method provided by the present invention, the method further includes: Detect the SQL configuration information corresponding to at least one tenant to be executed; wherein, the detection includes at least one of primary key conflict detection, SQL object existence detection, and SQL syntax detection.
[0013] The present invention also provides a multi-tenant database management device, the device includes: A first multi-tenant database management module, configured to determine the priorities of each tenant to be executed, the priorities of each structured query language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group in response to a database update request; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; A second multi-tenant database management module, configured to perform parallel and / or serial updates on the databases of each tenant to be executed based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL.
[0014] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, it implements the multi-tenant database management method as described in any one of the above.
[0015] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the multi-tenant database management method as described in any one of the above.
[0016] The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the multi-tenant database management method as described in any one of the above.
[0017] The multi-tenant database management method, device, equipment, medium, and program product provided by the present invention, after receiving a database update request, first determine the priorities of each tenant to be executed, the priorities of each SQL group under each tenant to be executed, and the priorities of each SQL within the SQL group. Then, based on these priorities, update the databases of each tenant to be executed. During the update process, enable the SQLs within different tenants to be executed serially and in parallel, reduce the execution duration, and improve the update efficiency. Description of the Drawings
[0018] To more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0019] Figure 1 It is one of the schematic flowcharts of the multi-tenant database management method provided by the present invention; Figure 2 It is the second of the schematic flowcharts of the multi-tenant database management method provided by the present invention; Figure 3 It is the schematic structural diagram of the multi-tenant database management device provided by the present invention; Figure 4 It is the schematic structural diagram of the electronic device provided by the present invention. Detailed implementation manners
[0020] To make the objectives, technical solutions and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions in the present invention with reference to the drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
[0021] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such terms can be interchanged under appropriate circumstances so that the embodiments of this application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first" and "second" are usually of the same category, and the number of objects is not limited. For example, the first object can be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means an "or" relationship between the associated objects before and after.
[0022] Figure 1 It is one of the schematic flowcharts of the multi-tenant database management method provided by the present invention. As Figure 1 shown, the method includes: step 110 and step 120.
[0023] Step 110, in response to a database update request, determine the priorities of each tenant to be executed, the priorities of each structured query language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user.
[0024] Here, the SQL configuration information refers to the relevant configuration information of at least one SQL defined by the user for the tenant to be executed, such as SQL priority, error handling methods (such as interruption, rollback, and skip), SQL type (such as DDL (Data Definition Language), DML (Data Manipulation Language), DQL (Data Query Language)), etc.
[0025] After the user submits the SQL configuration information of at least one tenant to be executed through the management interface or API, a database update request can be triggered. After receiving the database update request, the system will evaluate the priority of the execution of the at least one SQL corresponding to the database update request for the tenant to be executed.
[0026] For example, in an example, an execution system for supporting multi-tenant database management is provided. This system provides a user interface, which includes multiple functional modules such as a system management module, an SQL (Structured Query Language) submission module, an SQL review module, an SQL execution module, and a result processing module.
[0027] The system management module is used for project management (maintaining project information, supporting project addition, deletion, and modification), environment management (maintaining the project database environment, usually including development, testing, pre-production, and production environments. Different configurations can be defined according to the environment), tenant management (managing the project tenant database, supporting the addition, deletion, and modification of tenant database links), user management (managing system users, supporting user addition, deletion, and modification), permission management (managing the function permissions of the user system module, and the permission to execute query or change SQL on the tenant database), tenant parameters (managing tenant parameters, SQL supports writing tenant parameters, and can be dynamically replaced according to the associated tenant when entering SQL, simplifying the entry), version management (managing the online version of the system, supporting addition and deletion).
[0028] The SQL submission module is used for SQL entry (supporting single and multiple SQL entries, and can configure the tenant to be executed, the online version, the error handling method, and the priority information), tenant parameter replacement (querying the tenant parameter variables declared in the SQL and dynamically replacing them according to the tenant parameters configured in the system), pre-check (connecting to the tenant database and pre-checking the correctness of the SQL), etc.
[0029] The SQL review module is used for configuring the SQL automatic review specification, configuring the manual SQL review process, etc.
[0030] The SQL execution module is responsible for actually executing SQL statements (for example, it can batch-select the to-be-executed SQL statements that have passed the review for automatic scheduling, determine the execution order; initiate scheduling to the background for execution according to the scheduled order, support serial and parallel scheduling, and if a task scheduling fails, it can be interrupted, rolled back or skipped according to the configuration; each time scheduling is initiated or completed, update the execution status of the scheduling link, and the execution status includes waiting for execution, in execution and execution completed).
[0031] The result processing module is used to summarize and display the execution results, such as querying the historical execution records of each tenant, change situations, and summarizing the execution results of each tenant to the same page for display.
[0032] In practical applications, users can enter the SQL configuration information of the to-be-executed tenant through the SQL submission module of the multi-tenant database management execution system. For example, it can be entered through the work order entry method or the separate entry method of the SQL group.
[0033] Here, when using the work order entry method, multiple SQL groups can be entered in one work order, and each SQL group can set one or more SQL statements. In addition, multiple to-be-executed tenants can be selected to execute the SQL statements in this work order simultaneously. When using the SQL group entry method, the to-be-executed tenant can be configured independently. That is, one SQL group corresponds to one to-be-executed tenant.
[0034] It should be noted that when entering through the work order entry method, DQL, DDL, and DML cannot be used simultaneously in the same work order. When entering through the work order entry or SQL group entry, DDL and DML cannot be used simultaneously in the same SQL group.
[0035] It should be understood that each to-be-executed tenant can include at least one to-be-executed SQL statement, and multiple SQL statements of the to-be-executed tenant can be divided into multiple SQL groups according to their functions or the transactions to be processed. Therefore, in this embodiment, the priority evaluation includes at least three aspects: the priority of the to-be-executed tenant, the priority of the SQL group, and the priority of the SQL statement.
[0036] Here, the priority of the to-be-executed tenant can be determined according to the set tenant level (such as high-level tenants first), determined according to business requirements (specific business critical tenants first), determined according to resource allocation (adjust the priority based on the tenant's resource usage), and determined according to other factors (urgent business goals, SLA, etc.). The priority of the SQL group can be determined according to factors such as the urgency of the transaction to be processed. The priority of the SQL statement can be determined according to its SQL type. There is no limitation on this.
[0037] Step 120: Based on the priorities of the tenants to be executed, the priorities of each SQL group, and the priorities of each SQL, update the databases of the tenants to be executed in parallel and / or serially.
[0038] When updating the databases of the tenants to be executed, parallel and serial updates can be combined according to the priorities at three levels: the priorities of the tenants to be executed, the priorities of the SQL groups, and the priorities of the SQLs. For example, for tenants to be executed with similar priorities, they can be processed simultaneously; within each tenant to be executed, the execution is carried out in sequence according to the priorities of the SQL groups and SQL statements.
[0039] The multi-tenant database management method proposed in this embodiment, after receiving a database update request, first determines the priorities of the tenants to be executed, the priorities of each SQL group under each tenant to be executed, and the priorities of each SQL within the SQL group. Then, based on these priorities, the databases under each tenant to be executed are updated. During the update process, the SQLs within different tenants to be executed and within a tenant to be executed can be executed serially and in parallel, reducing the execution duration and improving the update efficiency.
[0040] It should be noted that each embodiment of this application can be freely combined, the order can be swapped, or it can be executed independently, and does not need to rely on or depend on a fixed execution order.
[0041] In some embodiments, determining the priorities of the tenants to be executed includes: Based on the configuration type of the SQL configuration information of the tenant to be executed, determine the first priority of the tenant to be executed; For at least two tenants to be executed with the same first priority, based on the tenant priorities configured in the SQL configuration information of the tenant to be executed, determine the second priority of each tenant to be executed.
[0042] Here, the configuration type of the SQL configuration information of the tenant to be executed includes two types: single mapping configuration or multi-tenant shared configuration. Among them, the priority of the single mapping configuration is higher than that of the multi-tenant shared configuration.
[0043] For example, work order configuration and SQL group configuration. Among them, the work order configuration refers to entering multiple SQL groups in a work order, and multiple tenants to be executed can simultaneously configure and execute the SQLs in this work order, that is, multi-tenant shared configuration. The SQL group configuration refers to a tenant to be executed configuring and executing one SQL group, that is, single mapping configuration. If both the work order configuration and the SQL group configuration are passed at the same time, the priority of the tenant to be executed with the SQL group configuration is higher than that of the tenant to be executed with the work order configuration.
[0044] In this embodiment, an initial priority, i.e., the first priority, is assigned to each tenant to be executed according to the configuration type of the SQL configuration information of the tenant to be executed. After determining the first priority, it is further checked whether there are multiple tenants to be executed with the same first priority. For these tenants to be executed with the same first priority, their respective second priorities are determined based on the tenant priorities configured in their SQL configuration information.
[0045] Here, the tenant priority is set for each tenant in the SQL configuration information in advance. For example, some tenants may be given a higher tenant priority due to the importance, urgency of their business or other business-related factors.
[0046] The multi-tenant database management method proposed in this embodiment flexibly determines the execution order of tenants to be executed according to the configuration type and tenant priority, ensuring the efficient and orderly progress of database updates.
[0047] In some embodiments, determining the priorities of each SQL group of tenants to be executed includes: Dividing all the SQLs of the tenants to be executed into at least one SQL group; wherein, the execution tables corresponding to different said SQL groups are different; Based on the execution table priority, determine the priorities of each SQL group of tenants to be executed.
[0048] This time, obtain the SQLs of each tenant to be executed. If there are SQL groups, split the SQLs within the group into single independent SQLs, and then re-group all the SQLs of the tenants to be executed according to the execution tables. The SQLs in each SQL group after re-grouping correspond to one execution table.
[0049] Then, determine the priorities of each SQL group according to the preset execution table priority. The execution table priority is predefined according to business requirements, data dependency relationships or other factors, and there is no limitation on this. According to the priority of the execution table, a priority is assigned to each SQL group, that is, the high-priority execution table corresponds to the high-priority SQL group, and the low-priority execution table corresponds to the low-priority SQL group.
[0050] The multi-tenant database management method proposed in this embodiment ensures that the high-priority execution table is updated first in this way, thus meeting the business requirements and data consistency requirements.
[0051] In some embodiments, determining the priorities of each SQL within the SQL group includes: For different SQLs within the SQL group of the tenant to be executed, determine the third priority of each SQL based on the SQL priority configured in the SQL configuration information of the tenant to be executed; For at least two SQLs with the same third priority, determine the fourth priority of each SQL based on the SQL type.
[0052] When processing a database update request, the priority of each SQL statement within the SQL group will be further determined to ensure that the execution order of the SQL statements meets the business requirements and logical requirements.
[0053] Specifically, first determine the third priority of each SQL statement based on the SQL priority configured in the SQL configuration information of the tenant to be executed. Here, the SQL priority is pre-set by the user for each SQL statement in the SQL configuration information of the tenant to be executed, and is used to distinguish the execution order of different SQL statements.
[0054] Furthermore, when there are at least two SQL statements with the same third priority, then further determine the fourth priority of each SQL according to the SQL type. Generally, the system will give priority to executing DDL statements, followed by DML statements, and finally other types of SQL statements. Therefore, in this embodiment, re-sort according to the rule that DDL statements are higher than DML statements. If the SQL types are also the same, any order can be selected.
[0055] The multi-tenant database management method proposed in this embodiment can, in this way, arrange the execution order of each SQL statement within the SQL group to ensure the efficient and accurate execution of database updates.
[0056] In some embodiments, based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL, perform parallel and / or serial updates on the databases of each tenant to be executed, including: Sequentially and serially schedule the tenants to be executed with each priority in the order from high to low based on the priority of the tenant to be executed; and When scheduling at least one SQL group of the tenant to be executed, sequentially and serially schedule each SQL group with each priority in the order from high to low based on the priority of the SQL group; and When scheduling the SQLs in the same SQL group, sequentially and serially schedule each SQL with each priority in the order from high to low based on the priority of the SQL to update the database of the tenant to be executed.
[0057] When performing multi-tenant database updates, first, sequentially and serially schedule the tenants to be executed with each priority in the order from high to low based on the priority of the tenant to be executed. For example, if the priority of tenant A is higher than that of tenant B, then the database update of tenant A will start before that of tenant B.
[0058] Specifically, when scheduling at least one SQL group of a tenant to be executed, the SQL groups of each priority will be serially scheduled in descending order of the priority of the SQL groups. In other words, within the same tenant to be executed, the SQL group with a higher priority will be executed before the SQL group with a lower priority. For example, if the priority of SQL group 1 is higher than that of SQL group 2, then SQL group 1 will be executed before SQL group 2.
[0059] Furthermore, when scheduling SQL statements within the same SQL group, since changes to the same execution table may result in lock waits. Therefore, the SQL statements of the SQL group corresponding to the same execution table will be scheduled sequentially to avoid lock waits from extending the execution time and wasting thread resources. Specifically, within the same SQL group, the SQL statement with a higher priority will be executed before the SQL statement with a lower priority. For example, if the priority of SQL1 is higher than that of SQL2, then SQL1 will be executed before SQL2.
[0060] In addition, it should be noted that during the process of serially processing multiple SQL statements based on the priority, when an SQL statement execution error occurs, if the configured error handling method is to interrupt, then the subsequent SQL statements in its branch will no longer be scheduled. If the configured error handling method is to skip, then the subsequent SQL statements will continue to be executed. If the configured error handling method is to roll back, then the current SQL unit will be rolled back.
[0061] In some embodiments, it further includes: Determining at least two first tenants to be executed with the same priority and at least two second tenants to be executed with the same priority; the priority of the at least two first tenants to be executed is higher than the priority of the at least two second tenants to be executed; Parallelly scheduling the at least two first tenants to be executed, and when the scheduling of the at least two first tenants to be executed is completed, parallelly scheduling the at least two second tenants to be executed.
[0062] In this embodiment, when serially scheduling the tenants to be executed of each priority, for multiple tenants to be executed with the same priority, parallel scheduling will be performed. After parallelly scheduling multiple tenants to be executed with the same priority, then parallelly scheduling multiple tenants to be executed with the next priority. In this way, it can ensure that the tenants to be executed with a higher priority are executed first, and at the same time, parallel scheduling is performed among the tenants with the same priority to improve the overall execution efficiency. And within each tenant to be executed, serial scheduling will be performed according to the priorities of the SQL groups and SQL statements to ensure the accuracy and consistency of data updates.
[0063] In some embodiments, it further includes: When scheduling at least one SQL group of a tenant to be executed, determine at least two first SQL groups with the same priority and at least two second SQL groups with the same priority; the priority of the at least two first SQL groups is higher than the priority of the at least two second SQL groups; Schedule the at least two first SQL groups in parallel, and when the scheduling of the at least two first SQL groups is completed, schedule the at least two second SQL groups in parallel.
[0064] When serially scheduling SQL groups of each priority of a tenant to be executed, for multiple SQL groups with the same priority, parallel scheduling will be performed. After parallel scheduling multiple SQL groups with the same priority, then parallelly schedule multiple SQL groups of the next priority. In this way, it can ensure that SQL groups with high priority are executed first, and at the same time, parallel scheduling is performed among SQL groups with the same priority, improving the overall execution efficiency. And within each SQL group, the priorities of SQL statements will be serially scheduled to ensure the accuracy and consistency of data updates.
[0065] For ease of understanding, refer to Figure 2 , Figure 2 is the second flowchart of the multi-tenant database management method provided by the present invention. As Figure 2 shown, for ease of showing the update progress of the multi-tenant database, the progress in this embodiment is also updated at two levels: tenant and SQL within the tenant. When a tenant is to be scheduled, it is in the to-be-executed state, and when executing internal SQL, it is in the executing state. After the tenant execution is completed, the status is updated to success or failure. The scheduling of SQL within a tenant is an independent task each time. It is in the to-be-executed state before starting scheduling. When the task starts scheduling, the status changes to executing. After the task execution is completed, the status changes to success or failure.
[0066] Specifically, query all to-be-executed tables of the tenant at the current priority level, mark them as in the to-be-executed state, obtain the priority list, and record the execution priority as the highest priority; obtain the to-be-executed tables at the current priority in the arrangement order, mark the status as executing, and take out the SQL at the current priority of the to-be-executed table to start task execution; after the task execution is completed, determine whether there is still SQL of the next priority in this to-be-executed table; if so, schedule the SQL of the next priority, and the status of this to-be-executed table remains executing; if not, mark this to-be-executed table as executed; query whether there are still to-be-executed tables. If so, obtain the unexecuted SQL at the current priority in this to-be-executed table and submit it for execution, and mark this to-be-executed table as executing; if not, query whether it is the last priority; if so, determine that all SQL of the tenant at the current priority level have been executed, and return to adjust the tenant priority level.
[0067] In some embodiments, the method further includes: Detect the SQL configuration information corresponding to at least one tenant to be executed; wherein, the detection includes at least one of primary key conflict detection, SQL object existence detection, and SQL syntax detection.
[0068] Primary key conflict detection refers to checking whether the data involved in the SQL statement will cause a primary key conflict. A primary key is a field in a database table used to uniquely identify each record, and each primary key value must be unique. For example, perform insert statement detection.
[0069] SQL object existence detection refers to checking whether the database objects (such as tables, indexes of tenants to be executed, etc.) involved in the SQL statement exist in the target database.
[0070] SQL syntax detection refers to checking whether the syntax of the SQL statement is correct and conforms to the syntax rules of the database system.
[0071] The multi-tenant database management method proposed in this embodiment can, through these detections, discover potential problems in advance, avoid errors during execution, and ensure the smooth progress of database updates.
[0072] Based on any of the above embodiments, the present invention further provides a multi-tenant database management device. Figure 3 It is a schematic structural diagram of the multi-tenant database management device provided by the present invention, as Figure 3 shown. The device includes: a first multi-tenant database management module 310 and a second multi-tenant database management module 320.
[0073] The first multi-tenant database management module 310 is used to determine the priorities of each tenant to be executed, the priorities of each structured query language (SQL) group of the tenants to be executed, and the priorities of each SQL within the SQL group in response to a database update request; the database update request is triggered based on the SQL configuration information of at least one tenant entered by the user.
[0074] The second multi-tenant database management module 320 is used to perform parallel and / or serial updates on the databases of each tenant to be executed based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL.
[0075] The device provided by an embodiment of the present invention includes determining the priorities of each tenant to be executed, the priorities of each Structured Query Language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group in response to a database update request; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; and performing parallel and / or serial updates on the databases of each tenant to be executed based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL. Thus, after receiving the database update request, the present invention first determines the priorities of each tenant to be executed, the priorities of each SQL group under each tenant to be executed, and the priorities of each SQL within the SQL group. Then, based on these priorities, the databases under each tenant to be executed are updated. During the update process, the SQLs within different tenants to be executed and within a tenant to be executed can be executed serially and in parallel, reducing the execution duration and improving the update efficiency.
[0076] The multi-tenant database management device described in this embodiment can be correspondingly referred to the multi-tenant database management method provided by the present invention described above, and will not be specifically elaborated herein.
[0077] Figure 4 An entity structure diagram of an electronic device is exemplified, as Figure 4 shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440. Among them, the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call the logical instructions in the memory 430 to execute the multi-tenant database management method, and the method includes: Determining the priorities of each tenant to be executed, the priorities of each Structured Query Language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group in response to a database update request; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; Performing parallel and / or serial updates on the databases of each tenant to be executed based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL.
[0078] In addition, when the logical instructions in the above-mentioned memory 430 can be implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0079] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the multi-tenant database management method provided by the above-mentioned various methods. The method includes: In response to a database update request, determine the priorities of each tenant to be executed, the priorities of each structured query language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; Based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL, perform parallel and / or serial updates on the databases of each tenant to be executed.
[0080] In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the multi-tenant database management method provided by the above-mentioned various methods. The method includes: In response to a database update request, determine the priorities of each tenant to be executed, the priorities of each structured query language (SQL) group of the tenant to be executed, and the priorities of each SQL within the SQL group; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; Based on the priorities of each tenant to be executed, the priorities of each SQL group, and the priorities of each SQL, perform parallel and / or serial updates on the databases of each tenant to be executed.
[0081] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative work.
[0082] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical coding features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of the present invention.
Claims
1. A multi-tenant database management method, characterized in that: The method comprises: In response to a database update request, determining the priority of each tenant to be executed, the priority of each structured query language SQL group of the tenant to be executed, and the priority of each SQL in the SQL group; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; Based on the priority of each tenant to be executed, the priority of each SQL group and the priority of each SQL, the database of each tenant to be executed is updated in parallel and / or serially.
2. The multi-tenant database management method according to claim 1, characterized in that: Determine the priority of each tenant to be executed, including: Determine the first priority of the tenant to be executed based on the configuration type of the SQL configuration information of the tenant to be executed; For at least two tenants to be executed with the same first priority, the second priority of each tenant to be executed is determined based on the tenant priority configured in the SQL configuration information of the tenant to be executed.
3. The multi-tenant database management method according to claim 1, characterized in that: Determine the priority of each SQL group of the tenant to be executed, including: Divide all SQLs of the tenant to be executed into at least one SQL group; wherein different SQL groups correspond to different execution tables; Based on the execution table priority, the priority of each SQL group of the tenant to be executed is determined.
4. The multi-tenant database management method according to claim 1, characterized in that: Determine the priority of each SQL in the SQL group, including: For different SQLs in the SQL group of the tenant to be executed, determining the third priority of each SQL based on the SQL priority configured in the SQL configuration information of the tenant to be executed; For the at least two SQLs with the same third priority, a fourth priority of each SQL is determined based on the SQL type.
5. The multi-tenant database management method according to claim 1, characterized in that: Based on the priority of each tenant to be executed, the priority of each SQL group and the priority of each SQL, the database of each tenant to be executed is updated in parallel and / or serially, including: Based on the order of priority of the tenants to be executed from high to low, the tenants to be executed of each priority are serially scheduled in sequence; and When scheduling at least one SQL group of the tenant to be executed, SQL groups of different priorities are serially scheduled in order from high to low priority of the SQL groups; and When scheduling SQLs in the same SQL group, SQLs of different priorities are serially scheduled in descending order based on the SQL priority to update the database of the tenant to be executed.
6. The multi-tenant database management method according to claim 5, characterized in that: Also includes: Determine at least two first tenants to be executed with the same priority and at least two second tenants to be executed with the same priority; The priorities of the at least two first tenants to be executed are higher than the priorities of the at least two second tenants to be executed; The at least two first tenants to be executed are scheduled in parallel, and when the scheduling of the at least two first tenants to be executed is completed, the at least two second tenants to be executed are scheduled in parallel.
7. The multi-tenant database management method according to claim 5, characterized in that: Also includes: When scheduling at least one SQL group of the tenant to be executed, determining at least two first SQL groups with the same priority and at least two second SQL groups with the same priority; the priority of the at least two first SQL groups is higher than the priority of the at least two second SQL groups; The at least two first SQL groups are scheduled in parallel, and when the scheduling of the at least two first SQL groups is completed, the at least two second SQL groups are scheduled in parallel.
8. The multi-tenant database management method according to claim 1, characterized in that: The method further comprises: The SQL configuration information corresponding to at least one tenant to be executed is detected; wherein the detection includes at least one of primary key conflict detection, SQL object existence detection, and SQL syntax detection.
9. A multi-tenant database management device, characterized in that: The device comprises: A first multi-tenant database management module, configured to determine, in response to a database update request, the priority of each tenant to be executed, the priority of each structured query language SQL group of the tenant to be executed, and the priority of each SQL in the SQL group; the database update request is triggered based on the SQL configuration information of at least one tenant to be executed entered by the user; The second multi-tenant database management module is used to update the database of each tenant to be executed in parallel and / or serially based on the priority of each tenant to be executed, the priority of each SQL group and the priority of each SQL.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the multi-tenant database management method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the multi-tenant database management method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the multi-tenant database management method according to any one of claims 1 to 8 is implemented.