Data query method, data query device, electronic equipment and storage medium

By determining the query partition in the materialized view's query partition, the problem of SQL statements taking up too long when a large amount of data is queried is solved, and the effect of fast query results is achieved and the cost is reduced.

CN120045588APending Publication Date: 2025-05-27RICHFIT INFORMATION TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311586293.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-24
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

When processing large amounts of data, the structured query statement SQL takes too long, resulting in the dimensional analysis and crystal reports being unable to produce results for a long time. The existing solutions rely on third-party tools and are costly.

Method used

By determining the query partition corresponding to the query statement, data query is carried out in the query partition of the materialized view, and no third-party tools are required to quickly obtain query results.

Benefits of technology

While ensuring cost, data query efficiency is improved, query time is reduced, and data processing performance is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045588A_ABST
    Figure CN120045588A_ABST
Patent Text Reader

Abstract

The invention provides a data query method, a data query device, electronic equipment and a storage medium. The data query method comprises the steps of obtaining a query statement; determining whether an original data table to be queried in the query statement has a materialized view or not; and if the materialized view has the query statement, determining a query partition corresponding to the query statement, and obtaining a query result corresponding to the query statement in the query partition of the materialized view. By adopting the technical scheme provided by the invention, the query result corresponding to the query statement can be quickly obtained without a third-party tool, and the data query efficiency is improved under the condition of ensuring the cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and in particular, to a data query method, a data query device, an electronic device, and a storage medium. Background Art

[0002] The geometric explosion of data volume has brought higher challenges to enterprises. Most companies have to face data at the terabyte level when establishing a data analysis system (BI system). The more data there is, the longer it takes for the structured query language SQL to occupy in dimensional analysis, resulting in the inability to obtain results from Crystal Reports for a long time.

[0003] Currently, when performing a large amount of data synchronization, a third-party tool can be used to solve the above problems. However, this method not only consumes the financial resources of the enterprise, but also occupies the company's manpower to maintain the third-party tool, resulting in high costs. Therefore, how to improve data query efficiency in a large amount of data while ensuring costs has become an urgent problem to be solved. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a data query method, a data query device, an electronic device, and a storage medium, which can determine the query partition corresponding to the query statement, perform data query in the query partition of the corresponding materialized view, and quickly obtain the query result corresponding to the query statement without a third-party tool, thereby improving data query efficiency while ensuring costs.

[0005] This application mainly includes the following aspects:

[0006] In a first aspect, an embodiment of this application provides a data query method, and the data query method includes:

[0007] Obtain a query statement;

[0008] Determine whether the original data table to be queried in the query statement has a materialized view;

[0009] If it has, determine the query partition corresponding to the query statement, and obtain the query result corresponding to the query statement in the query partition of the materialized view.

[0010] Further, the data query method further includes:

[0011] Obtain the data in the original data table by remote extraction in the original database;

[0012] Create an operation account in the target database and grant operation permissions to the operation account;

[0013] Establish a network connection between the original database and the target database through the operation account with operation permissions;

[0014] After the successful establishment of the network connection, the data in the original data table extracted remotely is used to create a materialized view corresponding to the original data table in the target database, so as to synchronize the data in the original data table to the materialized view corresponding to the target database.

[0015] Further, the materialized view corresponding to the original data table is created in the target database through the following steps:

[0016] In the target database, obtain the partitioning range of the materialized view corresponding to the original data table to be constructed;

[0017] Partition the materialized view corresponding to the original data table to be constructed according to the partitioning range to obtain a plurality of query partitions;

[0018] Partition the data in the original data table according to the partitioning range to obtain the partitioned data for each partition;

[0019] Store the partitioned data for each partition in the corresponding query partition to obtain the materialized view corresponding to the original data table.

[0020] Further, the data query method further includes:

[0021] Create a materialized view log for the original data table;

[0022] In response to an update operation on the original data table, record the update operation in the materialized view log;

[0023] Update the materialized view based on the update operation in the materialized view log.

[0024] Further, the materialized view is updated through the following steps:

[0025] Obtain an update strategy; wherein, the update strategy includes any one of incremental refresh and full refresh;

[0026] If the update strategy is incremental refresh, obtain the updated fields corresponding to the update operation and the updated parameter values corresponding to the updated fields;

[0027] In the materialized view corresponding to the target database, update the data corresponding to the updated fields to the updated parameter values to obtain the updated materialized view.

[0028] Further, the data query method further includes:

[0029] If the update strategy is full refresh, obtain the data in the original data table corresponding to the update operation;

[0030] In the materialized view corresponding to the target database, synchronize the data in the original data table to the materialized view to obtain an updated materialized view.

[0031] Further, determine whether the original data table to be queried in the query statement has a materialized view through the following steps:

[0032] In response to a query operation for a materialized view, obtain a list of materialized views;

[0033] In the list of materialized views, determine whether there is a view name of the materialized view corresponding to the original data table;

[0034] If not, determine that the original data table to be queried in the query statement does not have a materialized view;

[0035] If so, determine that the original data table to be queried in the query statement has a materialized view.

[0036] In a second aspect, an embodiment of the present application further provides a data query device, where the data query device includes:

[0037] An acquisition module, configured to acquire a query statement;

[0038] A determination module, configured to determine whether the original data table to be queried in the query statement has a materialized view;

[0039] A query module, configured to determine a query partition corresponding to the query statement when it is determined that the original data table to be queried in the query statement has a materialized view, and obtain a query result corresponding to the query statement in the query partition of the materialized view.

[0040] In a third aspect, an embodiment of the present application further provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the memory through the bus. When the machine-readable instructions are executed by the processor, the steps of the data query method as described above are executed.

[0041] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of the data query method as described above are executed.

[0042] A data query method, a data query device, an electronic device, and a storage medium provided by an embodiment of the present application. The data query method includes: obtaining a query statement; determining whether the original data table to be queried in the query statement has a materialized view; if so, determining the query partition corresponding to the query statement, and obtaining the query result corresponding to the query statement in the query partition of the materialized view.

[0043] In this way, by using the technical solution provided by the present application, it is possible to perform data query in the query partition of the corresponding materialized view by determining the query partition corresponding to the query statement, and quickly obtain the query result corresponding to the query statement without a third-party tool, thereby improving the data query efficiency while ensuring the cost.

[0044] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specific preferred embodiments are given and described in detail in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0046] Figure 1 Shows a flowchart of a data query method provided by an embodiment of the present application;

[0047] Figure 2 Shows a flowchart of another data query method provided by an embodiment of the present application;

[0048] Figure 3 Shows a schematic structural diagram of a data query device provided by an embodiment of the present application;

[0049] Figure 4 Shows a schematic structural diagram of a data query device provided by an embodiment of the present application;

[0050] Figure 5 Shows a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0051] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application. It should be understood that the accompanying drawings in this application are only for the purposes of illustration and description, and are not used to limit the protection scope of this application. In addition, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate the operations implemented according to some embodiments of this application. It should be understood that the operations in the flowchart may not be implemented in sequence, and steps without a logical context relationship may be reversed or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowchart or remove one or more operations from the flowchart under the guidance of the content of this application.

[0052] In addition, the described embodiments are only some embodiments of this application, rather than all of the embodiments. The components of the embodiments of this application generally described and illustrated in the accompanying drawings here may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of this application that is required to be protected, but merely represents the selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative efforts fall within the protection scope of this application.

[0053] To enable those skilled in the art to use the content of this application, the following implementation manners are given in combination with a specific application scenario "data query". For those skilled in the art, without departing from the spirit and scope of this application, the general principles defined here can be applied to other embodiments and application scenarios.

[0054] The following methods, devices, electronic devices, or computer-readable storage media in the embodiments of this application can be applied to any scenario that requires data query. The embodiments of this application do not limit the specific application scenario. Any solution that uses a data query method, a data query device, an electronic device, and a storage media provided by the embodiments of this application falls within the protection scope of this application.

[0055] Based on this, this application proposes a data query method, a data query device, an electronic device, and a storage media. The data query method includes: obtaining a query statement; determining whether the original data table to be queried in the query statement has a materialized view; if so, determining the query partition corresponding to the query statement, and obtaining the query result corresponding to the query statement in the query partition of the materialized view.

[0056] In this way, by adopting the technical solution provided by this application, it is possible to determine the query partition corresponding to the query statement, perform data query in the query partition of the corresponding materialized view, and quickly obtain the query result corresponding to the query statement without a third-party tool, thereby improving the data query efficiency while ensuring the cost.

[0057] To facilitate the understanding of the embodiments of this application, a data query method disclosed in the embodiments of this application will be introduced in detail first.

[0058] Please refer to Figure 1 , Figure 1 which is a flowchart of a data query method provided by an embodiment of this application. As shown in Figure 1 , the data query method includes:

[0059] S101. Obtain a query statement;

[0060] In this step, the query statement SQL is obtained.

[0061] S102. Determine whether the original data table to be queried in the query statement has a materialized view;

[0062] In this step, the table name of the original data table to be queried is included in the SQL, and based on the table name, it is determined whether the original data table has a corresponding materialized view.

[0063] It should be noted that the following steps are used to determine whether the original data table to be queried in the query statement has a materialized view:

[0064] S1021. In response to a query operation of the materialized view, obtain a list of materialized views;

[0065] S1022. In the list of materialized views, determine whether there is a view name of the materialized view corresponding to the original data table;

[0066] S1023. If not, determine that the original data table to be queried in the query statement does not have a materialized view;

[0067] S1024. If so, determine that the original data table to be queried in the query statement has a materialized view.

[0068] In the above steps S1021 to S1024, the query operation may be that an operator writes a query code for the materialized view in the database and runs the query code to obtain a list of all materialized views with materialized view names. The materialized view name corresponds to the table name of the original data table. Therefore, it can be determined whether there is a materialized view name corresponding to the table name in the list of materialized views. If so, it means that the original data table has a materialized view; if not, it means that the original data table does not have a materialized view.

[0069] S103. If so, determine the query partition corresponding to the query statement, and obtain the query result corresponding to the query statement in the query partition of the materialized view.

[0070] In this step, when there is a materialized view in the original data table, determine the query partition in the materialized view where the query time is located through the query time in the query statement. Here, the query partition can be an area divided by time range, and query data in the determined query partition to obtain the query result of SQL.

[0071] It should be noted that please refer to Figure 2 , Figure 2 which is the flowchart of another data query method provided by the embodiment of the present application. As shown in Figure 2 , the data query method further includes:

[0072] S201. Obtain the data in the original data table by remote extraction in the original database;

[0073] In this step, usually in the original database (Database A) to be collected, there is an original data table, which may contain millions or even more data. The data in this table needs to be extracted to the DW side as basic data, and generally ROWID or primary key is used to ensure data consistency at both ends.

[0074] S202. Create an operation account in the target database and grant operation permissions to the operation account;

[0075] In this step, relevant accounts need to be created when extracting data from the original database, and corresponding database operation permissions are granted. Only an account with database operation permissions can operate on the database.

[0076] S203. Establish a network connection between the original database and the target database through the operation account with operation permissions;

[0077] In this step, establish a network connection between the two databases through the account with operation permissions, connect from the DW library (target database) to the original database through DB_link. When creating the network connection DB_link, the network connection descriptor needs to be set in advance. Here, the network connection descriptor is a combination of the username and password used when connecting to the database. Because only by providing the correct network connection descriptor can the operator access the database.

[0078] As an example, create DB_link through the following code:

[0079] create database link to_source

[0080] connect to_user identified by_user

[0081] using '192.168.0.6:1521 / ORCL'

[0082] The above code creates a database connection named to_source using the _user user and uses the network connection descriptor in the using field to establish a DB_link.

[0083] S204. After the network connection is successfully established, extract the data in the original data table remotely, and create a materialized view corresponding to the original data table in the target database to synchronize the data in the original data table to the materialized view corresponding to the target database.

[0084] In this step, a materialized view based on table partitioning is established at the DW end by remotely extracting data. The table partitioning can be divided according to the time range of the data. The materialized view can customize the rules for refreshing the view as needed, such as fast on demand or fast on commit. Incremental or full data can be used to refresh and synchronize the data during the business low period, and finally, according to the business requirements, the logical reads can be reduced and the execution speed of SQL statements can be accelerated.

[0085] In the above steps S201 to S204, it is the process of data synchronization. Usually, during the establishment of a data warehouse, that is, an analytical database OLAP, the data in the original database (A) needs to be extracted into a new database (B) to meet the hierarchical requirements in the data warehouse, so as to clarify the data structure, trace the data lineage, and reduce duplicate development.

[0086] It should be noted that the materialized view corresponding to the original data table is created in the target database through the following steps:

[0087] I. In the target database, obtain the partitioning range of the materialized view corresponding to the original data table to be constructed;

[0088] II. Partition the materialized view corresponding to the original data table to be constructed according to the partitioning range to obtain multiple query partitions;

[0089] III. Divide the data in the original data table according to the partitioning range to obtain the partitioning data for each partition;

[0090] IV. Store the partitioning data for each partition in the corresponding query partition to obtain the materialized view corresponding to the original data table.

[0091] In the above steps 1 to 4, a materialized view based on table partitioning is created. The partitioning range can be a time range, obtaining query partitions for multiple time ranges. Then, the data in the original data table is stored in the corresponding query partitions according to the time range, obtaining the materialized view corresponding to the original data table.

[0092] As an example, the operator writes code to create the materialized view corresponding to the original data table. For example, the name of the original data table is T_TSO_LINE, creating a materialized view named T_TSO_LINE_mv, and partitioning the materialized view into three parts. Each part is divided according to the range of the time field. Each partition is given a name, which can be named according to time (such as p_201211, p_201212, p_201301) and a corresponding date range. This materialized view is created and stored in the RTDATA tablespace, and parallel processing (parallel 4) is used, indicating that 4 threads can be used for operation simultaneously. compress in the code indicates using compressed storage to save space. refresh fast ondemand in the code means that the materialized view is updated only when needed, rather than being updated automatically regularly. enable queryrewrite in the code means that query rewrite is allowed for the materialized view, that is, if a query is made on the materialized view, the database can automatically attempt to convert the query into a query on the base table. Here, the data of the materialized view comes from the query of the to_source database (target database) connected to the original database (original database). It should be noted that if the specific date format 'SYYYY-MM-DD HH24:MI:SS' and 'NLS_CALENDAR=GREGORIAN' are used in the SQL statement, this is a specific date format of Oracle, where 'SYYYY-MM-DD HH24:MI:SS' is the format of date and time, and 'NLS_CALENDAR=GREGORIAN' is to specify the calendar type as Gregorian calendar.

[0093] It should be noted that the data query method further includes:

[0094] 1) Create a materialized view log for the original data table;

[0095] 2) In response to the update operation of the original data table, record the update operation in the materialized view log;

[0096] 3) Update the materialized view based on the update operation in the materialized view log.

[0097] In the above steps 1) to 3), it is the process of updating the materialized view. A materialized view log needs to be created in the original database. The specific code is as follows:

[0098] Create a materialized view log on the T_TSO_LINE table in the USERS tablespace with the primary key;

[0099] Here, a materialized view log is created using the primary key of the original data table T_TSO_LINE and stored in the USERS tablespace. To use fast refresh, i.e., incremental refresh, it is usually necessary to rely on the materialized view log of the original data table to record the data changes of the original data table, achieve the purpose of incremental refresh, and ensure the consistency of the values on both sides. After establishing the materialized view log, the changes in the original data table can be monitored, and whenever there are changes in the original data table, the changed data needs to be written into the corresponding materialized view log.

[0100] It should be noted that the materialized view is updated through the following steps:

[0101] (1) Obtain the update strategy; where the update strategy includes any one of incremental refresh and full refresh;

[0102] (2) If the update strategy is incremental refresh, obtain the updated fields corresponding to the update operation and the updated parameter values corresponding to the updated fields;

[0103] (3) In the materialized view corresponding to the target database, update the data corresponding to the updated fields to the updated parameter values to obtain the updated materialized view.

[0104] In the above steps (1) to (3), if it is incremental refresh, the updated fields corresponding to the update operation and the updated parameter values can be obtained from the materialized view log of the original data table, and the parameter values of the fields corresponding to the updated fields in the materialized view are updated to the updated parameter values, thereby achieving fast refresh of the materialized view.

[0105] It should be noted that the data query method further includes:

[0106] ① If the update strategy is full refresh, obtain the data in the original data table corresponding to the update operation;

[0107] ② In the materialized view corresponding to the target database, synchronize the data in the original data table to the materialized view to obtain the updated materialized view.

[0108] In the above steps ① to ②, if it is a full refresh, the entire materialized view needs to be recalculated in the target database and the original data needs to be replaced. Here, when performing a full refresh, it can be carried out during the business low period, which is mentioned in contrast to the business peak period. For example, usually after 9 pm, when the business volume is small, maintenance work can be carried out to avoid affecting the normal business execution during the peak period.

[0109] Since the materialized view pre-computes and stores the results of time-consuming operations such as table joins or aggregations, this can avoid performing these time-consuming operations when executing queries, thus quickly obtaining the results and improving query performance. As an example, a SQL execution comparison can be made by comparing the SQL execution without query rewrite enabled with the SQL execution after query rewrite is enabled. Here, enabling the query rewrite function means obtaining the query results from the materialized view. From the comparison results, it can be seen that although the same SQL statement is used, the execution path represented by the id column with a value of 2 has changed from a full table scan to a materialized view query rewrite scan. Due to the different execution paths, the execution effects are also different. By comparing the values of the parameters Rows, Bytes, Cost, and Time columns, it can be found that the parameter values after query rewrite are generally decreased. For example, the Rows column shows: a decrease from 112,000 rows read to 3 rows, the Bytes column shows: a decrease from 439,000 bytes read to 39 bytes, the Cost column shows: the optimizer's estimated resource usage decreased from 1570 to 3, and the Time column shows: the time decreased from 12 seconds to 1 second; it can be clearly seen that after query rewrite is enabled, the execution path has changed and the execution efficiency has been significantly improved. If combined with the corresponding SQL partition index function, the output speed of the Crystal Reports can be significantly improved.

[0110] In summary, this embodiment can copy remote data and replicate the data at the same time. It is mainly used to pre-compute and store the result sets of time-consuming SQL operations such as table joins or aggregations, and use the range function table partitioning to split the data according to different times, and enable the oracle database query rewrite function, so that when executing SQL queries, combined with the optimizer function, the upper-layer SQL execution plan is more inclined to use the materialized view, which can avoid performing time-consuming operations and thus quickly obtain the query results. Usually in a data warehouse, the query rewrite mechanism is also often used. In this way, without modifying the original SQL query statement, Oracle will automatically select the appropriate materialized view for query, which is completely transparent to the application. After enabling the query rewrite function, the database can pre-compute and store complex query operations in the materialized view. In this way, when executing a query, the results can be directly obtained from the materialized view without recalculation, thus greatly accelerating the query speed.

[0111] A data query method provided by an embodiment of the present application, the data query method includes: obtaining a query statement; determining whether the original data table to be queried in the query statement has a materialized view; if so, determining the query partition corresponding to the query statement, and obtaining the query result corresponding to the query statement in the query partition of the materialized view.

[0112] In this way, by adopting the technical solution provided by the present application, it is possible to perform data query in the query partition of the corresponding materialized view by determining the query partition corresponding to the query statement, and quickly obtain the query result corresponding to the query statement without a third-party tool, improving the data query efficiency while ensuring the cost.

[0113] Based on the same inventive concept, an embodiment of the present application also provides a data query device corresponding to the above-mentioned data query method. Since the principle of solving problems by the device in the embodiment of the present application is similar to that of the above method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be elaborated.

[0114] Please refer to Figure 3 、 Figure 4 , Figure 3 which is one of the structural schematic diagrams of a data query device provided by an embodiment of the present application, Figure 4 which is the second structural schematic diagram of a data query device provided by an embodiment of the present application. As shown in Figure 3 the data query device 310 includes:

[0115] An obtaining module 311, configured to obtain a query statement;

[0116] A determining module 312, configured to determine whether the original data table to be queried in the query statement has a materialized view;

[0117] A query module 313, configured to, when it is determined that the original data table to be queried in the query statement has a materialized view, determine the query partition corresponding to the query statement, and obtain the query result corresponding to the query statement in the query partition of the materialized view.

[0118] Optionally, as shown in Figure 4 the data query device 310 further includes a synchronization module 314, and the synchronization module 314 is configured to:

[0119] Obtain the data in the original data table by remote extraction in the original database;

[0120] Create an operation account in the target database and grant operation permissions to the operation account;

[0121] Establish a network connection between the original database and the target database through the operation account with operation permissions;

[0122] After the successful establishment of the network connection, data in the original data table extracted remotely is used to create a materialized view corresponding to the original data table in the target database, so as to synchronize the data in the original data table to the materialized view corresponding to the target database.

[0123] Optionally, when the synchronization module 314 is used to create a materialized view corresponding to the original data table in the target database, the synchronization module 314 specifically is used for:

[0124] In the target database, obtain the partitioning range of the materialized view corresponding to the original data table to be constructed;

[0125] Partition the materialized view corresponding to the original data table to be constructed according to the partitioning range to obtain a plurality of query partitions;

[0126] Partition the data in the original data table according to the partitioning range to obtain the partitioned data for each partition;

[0127] Store the partitioned data for each partition in the corresponding query partition to obtain the materialized view corresponding to the original data table.

[0128] Optionally, as Figure 4 shown, the data query device 310 further includes an update module 315, and the update module 315 is used for:

[0129] Create a materialized view log for the original data table;

[0130] In response to an update operation on the original data table, record the update operation in the materialized view log;

[0131] Update the materialized view based on the update operation in the materialized view log.

[0132] Optionally, when the update module 315 is used to update the materialized view, the update module 315 specifically is used for:

[0133] Obtain an update strategy; wherein, the update strategy includes any one of incremental refresh and full refresh;

[0134] If the update strategy is incremental refresh, obtain the updated fields corresponding to the update operation and the updated parameter values corresponding to the updated fields;

[0135] In the materialized view corresponding to the target database, update the data corresponding to the updated fields to the updated parameter values to obtain the updated materialized view.

[0136] Optionally, the update module 315 is further used for:

[0137] If the update policy is full refresh, obtain the data in the original data table corresponding to the update operation;

[0138] In the materialized view corresponding to the target database, synchronize the data in the original data table to the materialized view to obtain an updated materialized view.

[0139] Optionally, the determining module 312 is specifically configured to:

[0140] In response to a query operation on the materialized view, obtain a list of materialized views;

[0141] In the list of materialized views, determine whether there is a view name of the materialized view corresponding to the original data table;

[0142] If not, determine that the original data table to be queried in the query statement does not have a materialized view;

[0143] If so, determine that the original data table to be queried in the query statement has a materialized view.

[0144] A data query device provided by an embodiment of the present application, the data query device includes: an acquisition module, configured to acquire a query statement; a determination module, configured to determine whether the original data table to be queried in the query statement has a materialized view; a query module, configured to, when it is determined that the original data table to be queried in the query statement has a materialized view, determine a query partition corresponding to the query statement, and obtain a query result corresponding to the query statement in the query partition of the materialized view.

[0145] In this way, by adopting the technical solution provided by the present application, it is possible to quickly obtain the query result corresponding to the query statement by determining the query partition corresponding to the query statement and performing data query in the query partition of the corresponding materialized view, without the need for a third-party tool, thereby improving the data query efficiency while ensuring the cost.

[0146] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 5 shown in

[0147] The memory 520 stores machine-readable instructions executable by the processor 510. When the electronic device 500 runs, the processor 510 communicates with the memory 520 through the bus 530. When the machine-readable instructions are executed by the processor 510, they can execute as described above Figures 1 to 2The steps of the data query method in the method embodiment shown can be specifically implemented with reference to the method embodiment, which will not be elaborated here.

[0148] The embodiments of the present application also provide a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it can execute the steps of the data query method in the method embodiment shown above Figures 1 to 2 The steps of the data query method in the method embodiment shown can be specifically implemented with reference to the method embodiment, which will not be elaborated here.

[0149] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be elaborated here.

[0150] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For another example, 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 displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0151] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0152] In addition, in each embodiment of the present application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.

[0153] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The 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 application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.

[0154] Finally, it should be noted that the above-mentioned embodiments are only specific implementation manners of the present application, used to illustrate the technical solutions of the present application, rather than limiting them. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed in the present application can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be covered by the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A data query method, characterized in that, the data query method includes: obtaining a query statement; determining whether the original data table to be queried in the query statement has a materialized view; if it has, determining the query partition corresponding to the query statement, and obtaining the query result corresponding to the query statement in the query partition of the materialized view.

2. The data query method according to claim 1, characterized in that, the data query method further includes: obtaining the data in the original data table through remote extraction in the original database; creating an operation account in the target database and granting operation permissions to the operation account; establishing a network connection between the original database and the target database through the operation account with operation permissions; after the network connection is successfully established, creating a materialized view corresponding to the original data table in the target database with the data in the original data table obtained through remote extraction, so as to synchronize the data in the original data table to the materialized view corresponding to the target database.

3. The data query method according to claim 2, characterized in that, creating the materialized view corresponding to the original data table in the target database through the following steps: in the target database, obtaining the partitioning range of the materialized view corresponding to the original data table to be constructed; partitioning the materialized view corresponding to the original data table to be constructed according to the partitioning range to obtain a plurality of query partitions; partitioning the data in the original data table according to the partitioning range to obtain the partitioned data of each partition; storing the partitioned data of each partition in the corresponding query partition to obtain the materialized view corresponding to the original data table.

4. The data query method according to claim 2, characterized in that, the data query method further includes: creating a materialized view log for the original data table; in response to an update operation on the original data table, recording the update operation in the materialized view log; updating the materialized view based on the update operation in the materialized view log.

5. The data query method according to claim 4, characterized in that, updating the materialized view through the following steps: obtaining an update strategy; wherein, the update strategy includes any one of incremental refresh and full refresh; if the update strategy is incremental refresh, obtaining the updated fields corresponding to the update operation and the update parameter values corresponding to the updated fields; in the materialized view corresponding to the target database, updating the data corresponding to the updated fields to the update parameter values to obtain an updated materialized view.

6. The data query method according to claim 5, characterized in that, the data query method further includes: if the update strategy is full refresh, obtaining the data in the original data table corresponding to the update operation; in the materialized view corresponding to the target database, synchronizing the data in the original data table to the materialized view to obtain an updated materialized view.

7. The data query method according to claim 1, characterized in that, determining whether the original data table to be queried in the query statement has a materialized view through the following steps: In response to a query operation on a materialized view, obtain a list of materialized views; In the list of materialized views, determine whether there is a view name of the materialized view corresponding to the original data table; If not, determine that the original data table to be queried in the query statement does not have a materialized view; If so, determine that the original data table to be queried in the query statement has a materialized view.

8. A data query device, characterized in that, the data query device includes: an acquisition module for acquiring a query statement; a determination module for determining whether the original data table to be queried in the query statement has a materialized view; a query module for, when determining that the original data table to be queried in the query statement has a materialized view, determining a query partition corresponding to the query statement, and obtaining a query result corresponding to the query statement in the query partition of the materialized view.

9. An electronic device, characterized in that, it includes: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the memory through the bus. When the machine-readable instructions are run by the processor, the steps of the data query method according to any one of claims 1 to 7 are executed.

10. A computer-readable storage medium, characterized in that, a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the data query method according to any one of claims 1 to 7 are executed.