Data query method and device, computer equipment, readable storage medium and chip

By introducing a second database into the enterprise information system and determining the target database based on the query scenario, the problem of low data query efficiency is solved, efficient and accurate data query is achieved, and the development process is simplified.

CN119226325APending Publication Date: 2024-12-31SF TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310786681.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Data query efficiency in existing enterprise information systems is low, especially when the data volume is large and the query scenarios are complex, resulting in slower query speed.

Method used

By introducing a second database into the enterprise information system, synchronizing data with the first database, and determining the target database according to the query scenario for data query operations, the high-performance database is used to process complex query scenarios to ensure data consistency and accuracy. The specific method includes synchronizing the data of the first database to the second database, determining the target database using the preset scenario-database name mapping relationship, and performing data query operations in the target database, and intercepting multiple data query operations using AOP sections to improve efficiency.

Benefits of technology

It improves the efficiency of data query, ensures the accuracy and consistency of data query results, reduces the invasiveness of the development process, and simplifies the code writing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226325A_ABST
    Figure CN119226325A_ABST
Patent Text Reader

Abstract

The invention provides a data query method and device, computer equipment, a readable storage medium and a chip, the method is applied to an enterprise information system, the method comprises the following steps: synchronizing data of a first database to a second database, the enterprise information system comprises the first database and the second database, the query scenes corresponding to the second database and the first database are different, and the first database and the second database are compatible with at least one same database communication protocol; obtaining a query scene in the data query request; determining a target database corresponding to the query scene, wherein the target database is a first database or a second database; and executing a data query operation of the data query request in the target database. According to the method, different databases are set, the appropriate database is adapted for the query scene, optimization of data query can be achieved, and the data query efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a data query method, device, computer equipment, readable storage medium and chip. Background Art

[0002] Based on the needs of business development, many companies will introduce some enterprise information systems to better manage their companies. Common enterprise information systems include ERP systems (Enterprise Resource Planning), CRM systems (Customer Relationship Management), OA systems (Office Automation) and FMS systems (Financial Management System). At present, many enterprise information systems are based on common relational databases (such as MySQL database, SqlServer database, DB2 database, Oracle database, etc.), and common relational databases are used to store and query enterprise-related data. However, as the amount of data increases, complex data queries for different scenarios and dimensions generally have technical problems such as slow query speed and low data query efficiency.

[0003] For example, in a CRM system based on MySQL database, when users query the business opportunity list in the CRM system, they often need to query data in a variety of different query scenarios. Common query scenarios include regions, teams, subordinates, organizations, and sales. In the case of large amounts of data, different query scenarios and dimensions result in many SQL join tables. The more complex the query scenario, the slower the query speed. Therefore, how to improve the data query efficiency of enterprise information systems has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] The embodiments of the present application provide a data query method and device, which can solve the technical problem of low data query efficiency of enterprise information systems commonly found in the prior art.

[0005] In a first aspect, an embodiment of the present application provides a data query method, which is applied to an enterprise information system, and the method includes:

[0006] Synchronize data from a first database to a second database, the enterprise information system includes the first database and the second database, the second database and the first database correspond to different query scenarios, and the first database and the second database are compatible with at least one same database communication protocol;

[0007] Get the query scenario in the data query request;

[0008] Determine a target database corresponding to the query scenario, where the target database is the first database or the second database;

[0009] In the target database, a data query operation of the data query request is executed.

[0010] The first aspect provides a data query method, in which a database for data query is determined according to a query scenario in a data query request, thereby optimizing the data query and improving the data query efficiency.

[0011] In a possible implementation of the first aspect, after obtaining the query scenario in the data query request, the method further includes: determining a database name corresponding to the query scenario according to a scenario-database name mapping relationship; and storing the database name in ThreadLocal;

[0012] Determine a target database corresponding to the query scenario, including: determining that the database corresponding to the database name stored in ThreadLocal is the target database.

[0013] In this implementation, a preset scenario-database name mapping relationship is used to determine the database name corresponding to the query scenario, and the database name is stored in ThreadLocal (i.e., thread context or thread local variable). Before executing the data query operation later, it is only necessary to obtain the database name from ThreadLocal to determine the target database, without passing the database name in the entire method; especially when the data query request includes multiple data query operations, multiple data query operations can obtain the database name from ThreadLocal to determine the target database, and the method is simple and convenient.

[0014] In a possible implementation of the first aspect, the data query request includes multiple data query operations; at this time, in the target database, the data query operation of the data query request is executed, including: executing a first type of query operation in the target database, the first type of query operation includes at least one data query operation among the multiple data query operations, and the first type of query operation corresponds to the main business content of the data query request; the method also includes: executing a second type of query operation in the first database, the second type of query operation includes data query operations among the multiple data query operations except the first type of query operation, and the second type of query operation corresponds to the basic content of the data query request.

[0015] In this implementation, by dividing multiple data query operations in a data query request into two different types, only the first type of query operation corresponding to the main business content of the data query request is executed in the target database, and the second type of query operation corresponding to the basic content of the data query request is executed in the first database; that is, the first database is the default database for executing data query requests, and queries on the basic content of the data query request can be directly executed in the first database; only data queries related to the main business content will select and judge the target database, and there is no need to switch databases for the first type of query operations, thereby improving the efficiency of data queries.

[0016] In a possible implementation of the first aspect, the method further includes: using a preset AOP aspect to intercept multiple data query operations; using the AOP aspect to determine the query operation including the first identifier in the multiple data query operations as a first type of query operation; using the AOP aspect to determine the query operation not including the first identifier in the multiple data query operations as a second type of query operation. In this implementation, the AOP aspect is used to intercept all data query operations of the data query request, and the AOP aspect is used to determine whether each data query operation includes the first identifier to determine which data query operations are the first type of query operations and which are the second type of query operations. By introducing the AOP aspect, the invasiveness of the development process can be reduced, and only one set of query code needs to be written for a data query operation in each data query request. When the data query operation needs to be executed in different databases, only the database needs to be switched.

[0017] In a possible implementation of the first aspect, the method further includes: using a preset AOP aspect to intercept a data query operation including a first identifier among multiple data query operations; using the AOP aspect to determine the intercepted data query operation as a first type of query operation; and determining the query operation that does not include the first identifier among the multiple data query operations as a second type of query operation. In this implementation, the AOP aspect only intercepts the data query operation with the first identifier among the multiple data query operations, which reduces the number of intercepted data query operations and also reduces the process of using AOP for judgment, thereby improving the execution efficiency of the data query method.

[0018] In a possible implementation of the first aspect, the first database includes: at least one of a MySQL database, a SqlServer database, a DB2 database, and an Oracle database, and the second database includes an MPP database and / or a TiDB database. In this implementation, both the first database and the second database are compatible with the MySQL protocol and SQL statements, which facilitates data synchronization between databases and database switching; and the performance of the second database in this implementation is higher than that of the first database, so the first database can be used to query simple query scenarios, and the second database can be used to query complex query scenarios, thereby improving data query efficiency.

[0019] In a possible implementation of the first aspect, the MPP database includes a starRocks database and / or an AnalyticDB database. In this implementation, both the starRocks database and the AnalyticDB database can handle complex query scenarios. The starRocks database can efficiently support a variety of data analysis scenarios such as multidimensional analysis, real-time analysis, and high-concurrency analysis of large amounts of data; while the AnalyticDB database is a real-time analysis database that can perform instant multidimensional analysis and perspective analysis on hundreds of billions of data in milliseconds.

[0020] In a possible implementation of the first aspect, the first database is a MySQL database, and synchronizing the data of the first database to the second database includes: opening Binlog in the first database, recording the data update status of the first database in Binlog; using Canal to monitor and parse Binlog to obtain the updated data of the first database; using Canal to push the updated data to Kafka; using Flink SQL to aggregate the updated data from Kafka to the second database. In this implementation, the updated data in the first database can be synchronized to the second database in real time to ensure the consistency of the data in the first database and the second database, thereby ensuring the accuracy of the data query results.

[0021] In a possible implementation of the first aspect, the first database includes a MySQL database, the second database includes a starRocks database and an AnalyticDB database, and the scene-database name mapping relationship includes:

[0022] If the query scenario is a query of data related to the current user, the database name corresponding to the query scenario is MySQL, the database corresponding to MySQL is the MySQL database, and the current user is the user who inputs a data query request to the enterprise information system;

[0023] If the query scenario is a query of business opportunity team-related data, the database name corresponding to the query scenario is MySQL;

[0024] If the query scenario is a query of regional related data, it is determined that the database name corresponding to the query scenario is starRocks, and the database corresponding to starRocks is the starRocks database;

[0025] If the query scenario is to query the data related to the subordinate teams of the current user, the database name corresponding to the query scenario is starRocks;

[0026] If the query scenario is a query of relevant data of subordinates of the current user, the database name corresponding to the query scenario is adb, and the database corresponding to adb is the AnalyticDB database.

[0027] In this implementation, different databases are adapted for querying scenarios of different query dimensions to improve query efficiency.

[0028] In a second aspect, an embodiment of the present application provides a data query device, which includes: a unit for executing each step of the method described in any implementation manner of the first aspect above.

[0029] In a third aspect, an embodiment of the present application provides a computer 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 steps of the method described in any one of the embodiments of the first aspect above are implemented.

[0030] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When a computer reads and executes the computer program or instructions, the computer executes the steps of the method described in any embodiment of the first aspect above.

[0031] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a server, enables the server to execute the steps of the method described in any one of the embodiments of the first aspect above.

[0032] In a sixth aspect, an embodiment of the present application provides a chip, comprising: a processor, configured to call and run a computer program from a memory, so that a computer device equipped with the chip executes a method as described in any one of the embodiments of the first aspect above.

[0033] It can be understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0035] Figure 1 It is a flowchart of a data query method provided by an embodiment of the present application;

[0036] Figure 2 It is an interaction diagram of a data synchronization process between a first database and a second database in a data query method provided in an embodiment of the present application;

[0037] Figure 3 is a schematic diagram of a business opportunity column in a CRM system provided in an embodiment of the present application;

[0038] Figure 4 is a structural block diagram of a data query device provided by an embodiment of the present application;

[0039] Figure 5 It is a schematic diagram of the internal structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0040] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0041] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0042] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0043] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0044] In addition, in the description of the specification of this application and the attached claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0045] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0046] In order to make the present application easier to understand, some terms involved in the present application are explained below.

[0047] Binlog: Binlog is a binary file that records changes to the database within MySQL and only records changes to the data.

[0048] Canal: It is an open source framework developed by Alibaba. It is mainly used to implement the analysis of incremental log Binlog based on MySQL database and provide subscription and consumption of incremental data.

[0049] Kafka: is an open source stream processing platform developed by the Apache Software Foundation. Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action stream data of consumers in the website.

[0050] Flink: generally refers to Apache Flink, which is an open source stream processing framework developed by the Apache Software Foundation. Its core is a distributed stream data flow engine written in Java and Scala. Flink executes any stream data program in a data-parallel and pipelined manner. Flink's pipeline runtime system can execute batch and stream processing programs.

[0051] Flink SQL: It is a development language that conforms to standard SQL semantics and is designed by Flink real-time computing to simplify computing models and lower the threshold for users to use real-time computing.

[0052] ThreadLocal: It can be translated as thread local variable, or it can also be translated as thread context. It is used to compile multi-threaded programs and has a certain enlightenment effect on solving concurrency problems of multi-threaded programs.

[0053] AOP: Aspect Oriented Programming, which is a technology that achieves unified maintenance of program functions through pre-compilation and dynamic proxy during runtime. AOP can be used to isolate various parts of business logic, thereby reducing the coupling between the various parts of business logic, improving the reusability of the program, and improving development efficiency.

[0054] As the needs of corporate business development grow, enterprise information systems are increasingly being used in enterprises. However, with the increase in data volume and the complexity of query scenarios, enterprise information systems generally have the problem of slow data query speeds.

[0055] The following uses the CRM system as an example to illustrate the problem of slow data query speed.

[0056] First, let's briefly introduce the CRM system. The full name of the CRM system is Customer Relationship Management, which is generally translated as a customer relationship management system. The CRM system is a software system that helps companies manage customer information and interactions. The CRM system can store customer information, such as contact information, customer orders, and customer preferences. Companies can use this data to carry out personalized marketing activities, improve customer service, and make smarter business decisions.

[0057] It should be understood that business opportunities can also be called sales opportunities, which refer to opportunities for a company to achieve certain profits. For example, when a salesperson is communicating with a customer, he or she may discover the customer's purchase intention, which can be a business opportunity. The CRM system is equipped with a business opportunity management module. The business opportunity list displays business opportunities in the form of a list on the page, and users can select a query scenario to display the required business opportunity data.

[0058] When querying the opportunity list data in the CRM system, there will be different query scenarios, such as region, team, subordinate, organization, sales, etc. When the CRM system is based on the MySQL database, when the query scenario involves a large amount of data, there are many SQL join tables that need to be queried, resulting in a slow query speed.

[0059] After the technical problem is clearly explained, the technical solution of this application based on the above technical problem is described below.

[0060] In response to the above technical problems, the present application provides a data query method, which is applied to an enterprise information system, and the enterprise information system includes a first database and a second database. In the data query method, the data of the first database is first synchronized to the second database, and the query scenarios corresponding to the second database and the first database are different; then the query scenario in the data query request is obtained; then the target database corresponding to the query scenario is determined, and the target database is the first database or the second database, and the data query operation of the data query request is performed in the target database. By synchronizing the data of the first database to the second database, and using different databases for data query for different query scenarios, the characteristics of different databases can be fully utilized to improve data query efficiency. For example, a database with lower performance can be used to handle simpler query scenarios, and a database with higher performance can be used to handle complex query scenarios. Since the data of the first database and the second database are synchronized, the consistency and accuracy of the data query results are guaranteed.

[0061] The data query method in the embodiment of the present application is exemplarily described below with reference to the accompanying drawings.

[0062] Figure 1 Schematic diagram of a data query method provided in an embodiment of the present application. Figure 1 The data query method in the embodiment shown is applied to an enterprise information system, which includes a first database and a second database. Figure 1 As shown, the method may include S101 to S104. Each step is described below.

[0063] S101: Synchronize data from a first database to a second database, where the second database and the first database correspond to different query scenarios.

[0064] In an embodiment of the present application, the enterprise information system includes a first database and a second database, wherein the data stored in the first database and the second database may be the same, but the performance of the first database and the second database are different, so that databases with different performances correspond to different query scenarios, and the first database and the second database are compatible with at least one identical database communication protocol.

[0065] It is understandable that the first database may include one database or multiple databases, and the second database may also include one database or multiple databases. The present application does not impose any specific limitation on the number of databases included in the first database and the second database.

[0066] It should be understood that the first database and the second database are both compatible with at least one identical database communication protocol, for example, they can both be compatible with the MySQL protocol, that is, the first database and the second database can both be compatible with the same data query statements, for example, they can both use SQL statements for data query.

[0067] Exemplarily, the first database includes: at least one of a MySQL database, a SqlServer database, a DB2 database, and an Oracle database. The second database includes an MPP database and / or a TiDB database. Among them, the MySQL database, the SqlServer database, the DB2 database, and the Oracle database are all databases with relatively general performance. MPP stands for Massively Parallel Processing. The MPP database is a database optimized for analytical workloads. It can aggregate and process large data sets. Therefore, the MPP database is an analytical query scenario; TiDB is a fusion distributed database product that supports both online transaction processing and online analytical processing. It is suitable for various application scenarios such as high availability, strong consistency requirements, and large data scale. Therefore, the TiDB database is suitable for query scenarios with large data volumes.

[0068] In some embodiments, the MPP database includes a starRocks database, or an AnalyticDB database, or includes both a starRocks database and an AnalyticDB database.

[0069] In some other embodiments, the data in the first database may be partially synchronized to the second database, that is, the first database includes all the data in the enterprise information system, and the second database includes part of the data in the enterprise information system.

[0070] For example, the first database may be a MySQL database, and the second database includes a starRocks database and an AnalyticDB database, wherein the first database is a default database of the enterprise information system, and the second database is a database added to improve data query efficiency.

[0071] It should be understood that those skilled in the art can select a suitable database as the second database according to the characteristics of the data in the enterprise information system, and this application does not impose any specific limitation on this.

[0072] S102: Obtain a query scenario in a data query request.

[0073] It is understandable that data query generally starts based on the user's data query request. For example, on a computer device equipped with an enterprise information system, a user logs in to the enterprise information system account and enters query conditions. The computing device generates a data query request based on the query conditions entered by the user. The data query request includes a query scenario, and the query scenario is generated based on the query conditions entered by the user. It is understandable that the user's operation of entering query conditions can be a text input process or a selection process, and this application does not limit this.

[0074] Exemplarily, the query scenario may be a query of data related to the current user, a query of data related to the current user's subordinate team, a query of data related to the current user's subordinates, a query of data related to the business opportunity team, a query of data related to a region (which may be a specific region), etc.

[0075] It should be understood that the query scenario is to limit the data to be queried through some specific conditions, so as to obtain the data most needed by the user. Specifically, it can be a process of data screening and analysis. Generally speaking, the more specific conditions there are, the more complex the query scenario is, and the fewer specific conditions there are, the simpler the query scenario is.

[0076] S103: Determine a target database corresponding to the query scenario, where the target database is the first database or the second database.

[0077] In the embodiment of the present application, it is necessary to determine a corresponding target database for each query scenario, and the target database refers to the most preferred database for the query scenario. Therefore, the target database is one of the first database and the second database.

[0078] It is understandable that a data query request may include multiple data query operations, that is, a data query request requires multiple data query operations to be completed. At this time, the target database may be a database corresponding to the main business content of the data query request.

[0079] Exemplarily, when the first database (or the second database) includes multiple databases, the target database is one of the multiple databases.

[0080] S104: Execute a data query operation of the data query request in the target database.

[0081] In the embodiment of the present application, after the target database is determined, data is queried in the target database to complete the data query request.

[0082] In the above data query method, by synchronizing the data in the second database with the data in the first database and determining the database for data query according to the query scenario in the data query request, data query optimization is achieved, and the characteristics of different data are fully utilized to realize data query in different query scenarios, thereby improving data query efficiency.

[0083] To facilitate understanding, the database synchronization process is exemplarily described below with reference to the accompanying drawings. Figure 2 FIG. 1 is an interactive diagram of the data synchronization process between the first database and the second database in the data query method in one embodiment of the present application. In this embodiment, the enterprise information system includes a first database, a second database and a data synchronization unit. Figure 2 As shown, the database synchronization process includes: S201 to S204. Each step is described below.

[0084] S201. A first database starts Binlog, and the Binlog records data update status of the first database.

[0085] S202. The data synchronization unit uses Canal to monitor and parse Binlog to obtain updated data of the first database.

[0086] S203. The data synchronization unit uses Canal to push the updated data to Kafka.

[0087] S204. The data synchronization unit aggregates the updated data from Kafka to the second database using Flink SQL.

[0088] S205: The second database receives and stores the updated data.

[0089] In some embodiments, when the first database is a MySQL database, the second database may be at least one of a starRocks database, an AnalyticDB database, and a TiDB database. This application does not impose specific restrictions on this. In this embodiment, both the first database and the second database are compatible with the MySQL protocol and SQL statements, which facilitates data synchronization between databases and database switching; and the performance of the second database in this embodiment is higher than that of the first database, so the first database can be used for simple query scenarios, and the second database can be used for complex query scenarios, thereby improving data query efficiency.

[0090] After introducing the data synchronization process, the process of determining the target database is exemplarily described below.

[0091] In some embodiments, after obtaining the query scenario of the data query request, first determine the database name corresponding to the query scenario according to the scenario-database name mapping relationship, and then store the database name in ThreadLocal. When determining the target database, specifically, the database corresponding to the database name stored in ThreadLocal can be determined as the target database.

[0092] It should be understood that the scenario-database name mapping relationship is preset, for example, it can be set in the enterprise information system in the form of a configuration file. In the scenario-database name mapping relationship, multiple different query scenarios are included, each query scenario corresponds to a database name, and the database names corresponding to different query scenarios may be the same or different.

[0093] The following uses the CRM system as an example to illustrate the scene-database name mapping relationship. Table 1 is a scene-database name mapping relationship table in the data query method in an embodiment of the present application.

[0094] Table 1

[0095] Query scenario Database name mine MySQL Regional starRocks Subordinate adb Business Opportunity Team MySQL Subordinate team starRocks

[0096] As shown in Table 1, if the query scenario is a query of data related to the current user (such as "My" in Table 1), it is determined that the database name corresponding to the query scenario is MySQL, and the database corresponding to MySQL is the MySQL database.

[0097] If the query scenario is a query of business opportunity team related data (such as "business opportunity team" in Table 1), it is determined that the database name corresponding to the query scenario is MySQL.

[0098] If the query scenario is a query of region-related data (such as "region" in Table 1), it is determined that the database name corresponding to the query scenario is starRocks, and the database corresponding to starRocks is the starRocks database.

[0099] If the query scenario is a query of data related to the subordinate teams of the current user (such as "subordinate teams" in Table 1), the database name corresponding to the query scenario is determined to be starRocks.

[0100] If the query scenario is a query of relevant data of subordinates of the current user (such as "subordinates" in Table 1), it is determined that the database name corresponding to the query scenario is adb, and the database corresponding to adb is the AnalyticDB database.

[0101] Figure 3 This is a schematic diagram of a business opportunity list in a CRM system provided in an embodiment of the present application. Figure 3 As shown, the query scenarios involved in the business opportunity list in this embodiment include the query scenarios in Table 1. Figure 3 As shown, the business opportunity list displays six query condition columns 301 to 306 , a first control 307 , a second control 308 , a third control 309 and a list 310 .

[0102] Among them, the query condition column 301 corresponds to the selection of the query scenario, such as Figure 3 In this embodiment, five query scenarios are displayed, namely: "My", "Regional", "Subordinates", "Opportunity Team" and "Subordinate Team". The business opportunity list displayed on the current display page is the list under the "My" query scenario. When the user clicks on the query scenario "Regional", the display interface expands the region, such as Figure 3 As shown, in the query scenario "regional", there are sub-scenarios "headquarters", "Guangzhou District", "Shenzhen District" and "South China Region", and the sub-scenarios can be further expanded. The user can select any sub-scenario under the query scenario "regional".

[0103] Among them, query condition column 302 corresponds to the selection of "business opportunity type", the first query condition column 303 corresponds to the selection of "promotion stage", query condition column 304 corresponds to the selection of "business opportunity win rate", query condition column 305 corresponds to the selection of "customer stratification", and query condition column 306 corresponds to the selection or input of "customer name".

[0104] like Figure 3As shown, in the display interface, the corresponding options of query condition bar 302 to query condition bar 305 are all "all", that is, in query condition bar 302 to query condition bar 305, the user has not selected a specific condition. The user can select each query condition by clicking the drop-down triangle space in each query condition bar, and this application will not go into details. In addition, the query condition bar 306 can also search for the customer name by inputting, and the customer name is not entered in the display interface.

[0105] After the user determines the content in the query condition columns 301 to 306, he clicks the first control 307 to start the business opportunity query; clicking the second control 308 will restore the content in the query condition columns 301 to 306 to the original state, making it easier for the user to reselect the query conditions.

[0106] like Figure 3 As shown, in the display interface, a list 310 displays multiple business opportunities corresponding to the query scenario. The user can edit each business opportunity. In addition, the user can also create a new business opportunity by clicking the third control 309.

[0107] In the above embodiment, since the query complexity of different query scenarios is different, corresponding to different databases, the characteristics of the database can be fully utilized to further improve the data query efficiency.

[0108] It should be understood that the ThreadLocal in the embodiment of the present application can dynamically switch the database. For example, taking the first database as the MySQL database and the second database as the starRocks database as an example, the MySQL database can be set as the default database: when it is determined that the database name stored in ThreadLocal is the name of the MySQL database, the database is not switched, and the data query operation is performed directly in the MySQL database; when it is determined that the database name stored in ThreadLocal is the name of the starRocks database, the data query operation is switched to the starRocks database. The specific process of switching is not described here.

[0109] In some embodiments, the data query request includes multiple data query operations, and the multiple data query operations are divided into a first type of query operation and a second type of query operation, wherein: the first type of query operation corresponds to the main business content of the data query request; the second type of query operation corresponds to the basic content of the data query request. In the target database, executing the data query operation of the data query request specifically includes: executing the first type of query operation in the target database; and the method also includes: executing the second type of query operation in the first database.

[0110] It can be understood that the first database is the default database, that is, data query operations for some basic content can be performed in the default first database, and data query operations for main business content can be performed in the first database or the second database according to the complexity of the data query operation.

[0111] For example, a data query operation with higher complexity (such as an operation that requires calling data from multiple tables) can be executed in a second database with higher performance, while a data query operation with lower complexity can be executed in a first database with relatively lower performance.

[0112] For example, taking the CRM system as an example, the first database is a MySQL database, and the second database includes: a starRocks database and an AnalyticDB database.

[0113] When the user's data query request is "query of business opportunity list in the region", the two data query operations corresponding to the data query request are: "query operation of current logged-in user information" and "query operation of business opportunity list information". Among them, the content queried by the "query operation of current operation user information" can include some user data, such as: user's work number, name, authority, etc., and this query operation is a first-type query operation. The content queried by the "business opportunity list information" is some list information related to business opportunities. This query operation is related to the main business content, and this data query operation is a second-type query operation.

[0114] In addition, the scenario corresponding to the data query request "regional business opportunity list query" is "regional". According to the scenario-database name mapping relationship table in Table 1, the database name corresponding to this scenario is "starRocks", that is, the target database is the starRocks database.

[0115] Therefore, the "currently logged-in user information query operation" is executed in the first database (ie, the MySQL database); and the "business opportunity list information query operation" is executed in the target database (ie, the starRocks database).

[0116] In some embodiments, when the first database includes all the data of the enterprise information system and the second database includes part of the data of the enterprise information system, the first database includes all the data of the enterprise information system and the second database includes part of the data of the enterprise information system. That is, part of the data in the first database is synchronized to the second database. For example, the data related to the main business content of multiple data query requests can be synchronized in the second database, and the data related to the basic content of multiple data query requests is only stored in the first database. The first type of query operation can be performed in the target database (i.e., the first database or the second database), while the second type of query operation is performed in the first database. In this way, while reducing the number of data synchronization operations, it can also be ensured that all data query operations can obtain query results, avoiding the situation where no data can be queried due to the second database not fully synchronizing the data.

[0117] For ease of understanding, the process of determining which of the multiple data queries are first-type query operations and which are second-type query operations is described below. In order to reduce the intrusion into the enterprise information system, the process of determining the first-type query operation and / or the second-type query operation is implemented through the AOP aspect.

[0118] In some embodiments, a preset AOP aspect can be used to intercept multiple data query operations; then the AOP aspect is used to determine whether each data query operation is a first type query operation or a second type query operation based on whether each data query operation includes a first identifier. The first identifier can be an annotation, such as "@Transactional": the query operation including the first identifier in the multiple data query operations is determined as the first type query operation, and the query operation not including the first identifier in the multiple data query operations is determined as the second type query operation.

[0119] In this embodiment, by introducing the AOP aspect, the invasiveness of the development process can be reduced, and only one set of query code needs to be written for a data query operation in each data query request. When the data query operation needs to be executed in different databases, only the database needs to be switched. If the AOP aspect is not introduced, for each data query operation in each data query request, a set of code needs to be set for each database, so as to implement the data query operation in different databases. Therefore, by introducing the AOP aspect, the amount of code can be greatly reduced.

[0120] In some other embodiments, a preset AOP aspect is used to intercept data query operations that include a first identifier among multiple data query operations; the AOP aspect is used to determine the intercepted data query operations as first type query operations; and query operations that do not include the first identifier among the multiple data query operations are determined as second type query operations.

[0121] In this embodiment, the AOP aspect only intercepts data query operations with the first identifier among multiple data query operations, reducing the amount of data query operations that the AOP aspect needs to intercept, while reducing the process of using AOP for judgment and improving the execution efficiency of the data query method.

[0122] It should be understood that the enterprise information system in the embodiment of the present application can be obtained by improving the original enterprise information system. Taking the CRM system as an example, assuming that the original CRM system only includes a first database (for example, a MySQL database), in order to improve the data query efficiency of the CRM system, a second database can be added to the CRM system, and the data of the first database can be synchronized to the second database (for example, a starRocks database and / or an AnalyticDB database), and then the scene-database name mapping relationship is configured in the CRM system to generate a new CRM system. When a user performs a data query in the new CRM system, the target database is determined from the first database and the second database according to the query scenario in the data query request input by the user, and the data query operation of the data query request is executed in the target database. The improved CRM system has higher data query efficiency than the original CRM system.

[0123] It is understandable that a data query request generally includes multiple data query operations. The data query operations related to the main business content are executed in the target database, and other data query operations related to the basic content can be executed in the default first database. A data query request can correspond to a target database. If the target database is the first database, all data query operations in the data query request are executed in the first database; if the target database is the second database, some data query operations in the data query request are executed in the first database, and some data query operations are executed in the second database.

[0124] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0125] Corresponding to the data query method in the above embodiment, an embodiment of the present application further provides a data query device, which includes a unit for executing each step executed by the server in the data query method in any of the above embodiments.

[0126] The data query device in the embodiment of the present application is exemplarily described below with reference to the accompanying drawings.

[0127] like Figure 4 FIG. 1 is a block diagram of a data query device provided by an embodiment of the present application. For the sake of convenience, only the part related to the embodiment of the present application is shown. Figure 4 The data query device 400 includes: a data synchronization unit 410, a query scenario acquisition unit 420, a target database determination unit 430 and a data query unit 440: wherein:

[0128] A data synchronization unit 410 is used to synchronize data from a first database to a second database, wherein the enterprise information system includes a first database and a second database, wherein the second database and the first database correspond to different query scenarios, and the first database and the second database are compatible with at least one same database communication protocol;

[0129] A query scenario acquisition unit 420, used to acquire a query scenario in a data query request;

[0130] A target database determining unit 430 is used to determine a target database corresponding to the query scenario, where the target database is the first database or the second database;

[0131] The data query unit 440 is used to execute the data query operation of the data query request in the target database.

[0132] Optionally, the data query device 400 further includes: a first determining unit and a storage unit, wherein:

[0133] A first determining unit, configured to determine a database name corresponding to a query scenario according to a scenario-database name mapping relationship;

[0134] Storage unit, used to store the database name in ThreadLocal;

[0135] When the target database determination unit 430 is used to determine the target database corresponding to the query scenario, it includes: determining the database corresponding to the database name stored in ThreadLocal as the target database

[0136] Optionally, the data query request includes multiple data query operations, and the data query device 400 further includes: a second data query unit, wherein:

[0137] The data query unit 440 is used to execute the data query operation of the data query request in the target database, including: executing a first type of query operation in the target database, the first type of query operation including at least one data query operation among the plurality of data query operations, the first type of query operation corresponding to the main business content of the data query request;

[0138] The second data query unit is used to execute a second type query operation in the first database, the second type query operation includes data query operations other than the first type query operation in multiple data query operations, and the second type query operation corresponds to the basic content of the data query request.

[0139] Optionally, the data query device 400 further includes: a first interception unit, a second determination unit and a third determination unit, wherein:

[0140] A first interception unit is used to intercept multiple data query operations using a preset AOP aspect;

[0141] A second determining unit is used to determine, by using the AOP aspect, a query operation including the first identifier among the multiple data query operations as a first type query operation;

[0142] The third determining unit is used to use the AOP aspect to determine the query operation that does not include the first identifier among the multiple data query operations as a second type of query operation.

[0143] Optionally, the data query device 400 further includes: a second interception unit, a fourth determination unit and a fifth determination unit, wherein:

[0144] A second interception unit, configured to intercept the data query operation including the first identifier among the multiple data query operations using a preset AOP aspect;

[0145] A fourth determining unit, configured to determine the intercepted data query operation as a first type query operation by using the AOP aspect;

[0146] The fifth determining unit is configured to determine a query operation that does not include the first identifier among the multiple data query operations as a second type query operation.

[0147] Optionally, the first database includes: at least one of: a MySQL database, a SqlServer database, a DB2 database, and an Oracle database, and the second database includes an MPP database and / or a TiDB database.

[0148] Optionally, the MPP database includes a starRocks database and / or an AnalyticDB database.

[0149] Optionally, the first database is a MySQL database, and the data synchronization unit 410 is used to synchronize the data of the first database to the second database, including:

[0150] Binlog is enabled in the first database, and data updates in the first database are recorded in Binlog;

[0151] Use Canal to monitor and parse Binlog to obtain the updated data of the first database;

[0152] Use Canal to push updated data to Kafka;

[0153] Use Flink SQL to aggregate the updated data from Kafka to the second database.

[0154] Optionally, the first database includes a MySQL database, and the second database includes a starRocks database and an AnalyticDB database, and the mapping relationship between the scenario and the database name includes:

[0155] If the query scenario is a query of data related to the current user, it is determined that the database name corresponding to the query scenario is MySQL, the database corresponding to MySQL is the MySQL database, and the current user is the user who inputs a data query request to the enterprise information system;

[0156] If the query scenario is a query of business opportunity team-related data, the database name corresponding to the query scenario is MySQL;

[0157] If the query scenario is a query of regional related data, the database name corresponding to the query scenario is starRocks, and the database corresponding to starRocks is the starRocks database;

[0158] If the query scenario is to query the data related to the subordinate teams of the current user, the database name corresponding to the query scenario is starRocks;

[0159] If the query scenario is a query of relevant data of subordinates of the current user, the database name corresponding to the query scenario is adb, and the database corresponding to adb is the AnalyticDB database.

[0160] It should be understood that the specific process of each unit in the data query device 400 executing the above corresponding steps can be found in the description of the data query method in the previous text, and for the sake of brevity, it is not repeated here.

[0161] An embodiment of the present application also provides a computer device 500. Figure 5As shown, the computer device 500 of this embodiment includes: a processor 501, a memory 502, and a computer program 504 stored in the memory 502 and executable on the processor 501. The computer program 504 can be executed by the processor 501 to generate instructions 503, and the processor 501 can implement the steps in the above-mentioned various data query method embodiments according to the instructions 503. Alternatively, when the processor 501 executes the computer program 504, the functions of each module / unit in the above-mentioned various device embodiments are implemented, such as Figure 4 The functions of the data synchronization unit 410 to the data query unit 440 are shown.

[0162] Exemplarily, the computer program 504 may be divided into one or more modules / units, one or more modules / units are stored in the memory 502, and are executed by the processor 501 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 504 in the computer device 500.

[0163] Those skilled in the art will understand that Figure 5 This is only an example of the computer device 500 and does not constitute a limitation of the computer device 500. The computer device 500 may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the computer device 500 may also include input and output devices, network access devices, buses, etc.

[0164] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.

[0165] The memory 502 may be an internal storage unit of the computer device 500, such as a hard disk or memory of the computer device 500. The memory 502 may also be an external storage device of the computer device 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 500. Further, the memory 502 may also include both an internal storage unit of the computer device 500 and an external storage device. The memory 502 is used to store computer programs and other programs and data required by the computer device 500. The memory 502 may also be used to temporarily store data that has been output or is to be output.

[0166] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0167] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program or instruction is stored, and when the computer reads and executes the computer program or instruction, the computer executes the steps in the above-mentioned various method embodiments. The readable medium can be a read-only memory (ROM) or a random access memory (RAM), which is not limited in the embodiment of the present application.

[0168] Exemplarily, the computer program or instructions in the computer-readable storage medium are implemented using aspect-oriented programming techniques.

[0169] An embodiment of the present application provides a computer program product. When the computer program product runs on a server, the server can implement the steps in the above-mentioned method embodiments when executing the server.

[0170] The embodiment of the present application also provides a chip, which includes: a processing unit and a communication unit, the processing unit, for example, may be a processor, and the communication unit, for example, may be an input / output interface, a pin or a circuit, etc. The processing unit may execute computer instructions to enable a computer device to execute any of the data query methods provided in the above embodiment of the present application.

[0171] Optionally, the computer instructions are stored in a storage unit.

[0172] Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the terminal, such as a ROM or other types of static storage devices that can store static information and instructions, random RAM, etc. Among them, the processor mentioned in any of the above can be a CPU, a microprocessor, an ASIC, or one or more integrated circuits for controlling the display of the above-mentioned electronic device and the execution of the program of the control method. The processing unit and the storage unit can be decoupled and respectively set on different physical devices, and connected by wired or wireless means to realize the respective functions of the processing unit and the storage unit, so as to support the system chip to realize the various functions in the above-mentioned embodiments. Alternatively, the processing unit and the memory can also be coupled on the same device.

[0173] It is understandable that the chip provided in the embodiment of the present application can be an integrated circuit for implementing any of the above-mentioned data query methods, and the main function of the chip is to execute the steps or processes defined in the data query method in the embodiment of the present application, that is, to implement the data query method in the embodiment of the present application by hardware. The computer-readable storage medium provided in the embodiment of the present application is mainly used to store a computer program, which, when executed, implements the steps or processes defined in any of the above-mentioned data query methods, that is, to implement the data query method in the embodiment of the present application in the form of computer software.

[0174] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0175] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0176] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are merely schematic, for example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0177] 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 on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0178] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0179] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / server, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0180] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A data query method, applied to an enterprise information system, characterized in that: The method comprises: Synchronize data from a first database to a second database, the enterprise information system including the first database and the second database, the second database and the first database corresponding to different query scenarios, and the first database and the second database are compatible with at least one same database communication protocol; Get the query scenario in the data query request; Determine a target database corresponding to the query scenario, the target database being the first database or the second database; In the target database, a data query operation of the data query request is executed.

2. The method according to claim 1, characterized in that After obtaining the query scenario in the data query request, the method further includes: Determine the database name corresponding to the query scenario according to the scenario-database name mapping relationship; Store the database name in ThreadLocal; The determining of a target database corresponding to the query scenario includes: Determine that the database corresponding to the database name stored in the ThreadLocal is the target database.

3. The method according to claim 2, characterized in that The data query request includes multiple data query operations, and the data query operations of the data query request are executed in the target database, including: executing a first type of query operation in the target database, the first type of query operation including at least one data query operation among the multiple data query operations, the first type of query operation corresponding to a main business content of the data query request; The method further comprises: A second type of query operation is performed in the first database, where the second type of query operation includes data query operations other than the first type of query operation in the multiple data query operations, and the second type of query operation corresponds to basic content of the data query request.

4. The method according to claim 3, characterized in that The method further comprises: Use the preset AOP aspect to intercept the multiple data query operations; Using the AOP aspect, determining the query operation including the first identifier among the multiple data query operations as the first type of query operation; The AOP aspect is used to determine the query operations among the multiple data query operations that do not include the first identifier as the second type query operations.

5. The method according to claim 3, characterized in that: The method further comprises: Using a preset AOP aspect to intercept the data query operation including the first identifier among the multiple data query operations; Using the AOP aspect, determining the intercepted data query operation as the first type of query operation; The query operations that do not include the first identifier among the multiple data query operations are determined as the second type query operations.

6. The method according to any one of claims 2 to 5, characterized in that: The first database includes a MySQL database, the second database includes a starRocks database and an AnalyticDB database, and the scene-database name mapping relationship includes: If the query scenario is a query of data related to the current user, the database name corresponding to the query scenario is MySQL, the database corresponding to MySQL is a MySQL database, and the current user is the user who inputs the data query request to the enterprise information system; If the query scenario is a query of business opportunity team related data, the database name corresponding to the query scenario is MySQL; If the query scenario is a query of area-related data, the database name corresponding to the query scenario is starRocks, and the database corresponding to starRocks is the starRocks database; If the query scenario is a query of data related to the subordinate teams of the current user, the database name corresponding to the query scenario is starRocks; If the query scenario is a query of relevant data of subordinates of the current user, the name of the database corresponding to the query scenario is adb, and the database corresponding to adb is the AnalyticDB database.

7. A data query device, characterized in that: The device comprises means for executing the steps of the method according to any one of claims 1 to 6.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or instructions. When a computer reads and executes the computer program or instructions, the computer executes the method according to any one of claims 1 to 6.

10. A chip, characterized in that: include: A processor, configured to call and run a computer program from a memory, so that a computer device equipped with the chip executes a method as claimed in any one of claims 1 to 6.