WO2020259391A1 - 一种数据库脚本性能测试的方法及装置 - Google Patents

一种数据库脚本性能测试的方法及装置 Download PDF

Info

Publication number
WO2020259391A1
WO2020259391A1 PCT/CN2020/096905 CN2020096905W WO2020259391A1 WO 2020259391 A1 WO2020259391 A1 WO 2020259391A1 CN 2020096905 W CN2020096905 W CN 2020096905W WO 2020259391 A1 WO2020259391 A1 WO 2020259391A1
Authority
WO
WIPO (PCT)
Prior art keywords
information
database
abstract
table information
sentence
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2020/096905
Other languages
English (en)
French (fr)
Inventor
谢锐杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Publication of WO2020259391A1 publication Critical patent/WO2020259391A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/217Database tuning

Definitions

  • the embodiment of the present invention relates to the field of financial technology (Fintech), and in particular to a method and device for testing database script performance.
  • the first one is for banks/financial institutions to simulate actual online production database data by calculating numbers in the test environment.
  • the disadvantage of this scheme lies in the time cost of the number creation process, and it will inevitably increase the resource requirements of the test environment.
  • the second is for banks/financial institutions to build a set of quasi-production environment database for performance testing through online production database data copies.
  • the shortcomings of this solution are related to resource requirements.
  • the database resource requirements of banks/financial institutions will double, resulting in a shortage of resources.
  • the embodiment of the present invention provides a method and device for testing database script performance, which is used to save the manpower and resource expenses of manufacturing a test environment or preparing a quasi-production environment.
  • an embodiment of the present invention provides a method for testing database script performance, including:
  • the performance index of the database script is determined.
  • the performance index of the database script is obtained, which is used to indicate the priority of determining the script optimization, which can save testing Human resources for environmental construction and reduction of resource expenditure for preparing quasi-production environment.
  • the preprocessing of the statements in the database script information includes:
  • the information related to the actual business in the sentence of the database script information is deleted.
  • the consumption of the abstract sentence includes current consumption and estimated consumption
  • the table information of the production database includes data volume information, index information, index discrimination information, and data growth trend
  • table information of the test database Including data volume information, index information, index discrimination information, and data growth trends
  • Determining the consumption of the abstracted statement according to the table information of the production database and/or the table information of the test database, the abstracted statement corresponding to the database script information, and the execution plan of the abstracted statement include:
  • the plan is to determine the current consumption of abstract sentences in the table information of the production database; and combine the data growth trend in the table information of the production database to substitute estimated recent data statistics into the table information of the production database
  • the execution plan of the abstraction statement determines the estimated consumption of the abstraction statement that exists in the table information of the production database
  • the data volume information and/or index information and/or index discrimination degree in the table information of the test database corresponding to the abstract sentences in the table information of the production database are not present
  • the information is converted according to a preset ratio, and the converted data volume information and/or index information and/or index discrimination information are substituted into the execution plan of the abstract statement that does not exist in the table information of the production database, and the non-existence is determined.
  • the current consumption of abstract sentences that exist in the table information of the production database; and the data growth trend in the table information of the test database corresponding to the abstract sentences that do not exist in the table information of the production database is substituted into the estimated recent data statistics information
  • the execution plan of the abstract sentence without the table information of the production database determines the estimated consumption of the abstract sentence without the table information of the production database.
  • the determining the performance index of the database script according to the consumption of the abstraction sentence and the execution frequency of the abstraction sentence includes:
  • a four-quadrant classification is performed to obtain the abstract sentence Performance.
  • the method further includes:
  • an embodiment of the present invention provides an apparatus for testing database script performance, including:
  • the obtaining unit is used to obtain table information of the online production database, table information of the test database, and database script information in the test database test process;
  • the processing unit is used to preprocess the sentences in the database script information to obtain the abstract sentences corresponding to the database script information; and determine the execution frequency of the abstract sentences; according to the table information of the production database And/or the table information of the test database, the abstraction sentence corresponding to the database script information, and the execution plan of the abstraction sentence, determine the consumption of the abstraction sentence;
  • the execution frequency of the abstract statement determines the performance index of the database script.
  • processing unit is specifically configured to:
  • the information related to the actual business in the sentence of the database script information is deleted.
  • the consumption of the abstract sentence includes current consumption and estimated consumption
  • the table information of the production database includes data volume information, index information, index discrimination information, and data growth trend
  • table information of the test database Including data volume information, index information, index discrimination information, and data growth trends
  • the processing unit is specifically used for:
  • the plan is to determine the current consumption of abstract sentences in the table information of the production database; and combine the data growth trend in the table information of the production database to substitute estimated recent data statistics into the table information of the production database
  • the execution plan of the abstraction statement determines the estimated consumption of the abstraction statement that exists in the table information of the production database
  • the data volume information and/or index information and/or index discrimination degree in the table information of the test database corresponding to the abstract sentences in the table information of the production database are not present
  • the information is converted according to a preset ratio, and the converted data volume information and/or index information and/or index discrimination information are substituted into the execution plan of the abstract statement that does not exist in the table information of the production database, and the non-existence is determined.
  • the current consumption of abstract sentences that exist in the table information of the production database; and the data growth trend in the table information of the test database corresponding to the abstract sentences that do not exist in the table information of the production database is substituted into the estimated recent data statistics information
  • the execution plan of the abstract sentence without the table information of the production database determines the estimated consumption of the abstract sentence without the table information of the production database.
  • processing unit is specifically configured to:
  • a four-quadrant classification is performed to obtain the abstract sentence Performance.
  • processing unit is further configured to:
  • the execution frequency of the database script determines the optimization plan of the database script.
  • an embodiment of the present invention also provides a computing device, including:
  • Memory used to store program instructions
  • the processor is configured to call the program instructions stored in the memory, and execute the above-mentioned database script performance test method according to the obtained program.
  • embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions, which when the computer reads and executes the computer-readable instructions, cause the computer to execute the aforementioned database script performance Method of testing.
  • FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a method for testing database script performance according to an embodiment of the present invention
  • Figure 3 is a schematic diagram of a four-quadrant distribution provided by an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of an apparatus for testing database script performance provided by an embodiment of the present invention.
  • FIG. 1 exemplarily shows a system architecture to which the embodiment of the present invention is applicable.
  • the system architecture may be a server 100 used by a bank/financial institution for database script testing.
  • the server 100 may include a database statistical information collection module 110, The script sentence capture module 120, the sentence analysis module 130, and the report management module 140.
  • the database statistical information collection module 110 can collect database statistical information of banks/financial institutions, that is, table information, including table field information, data volume information, index information, index discrimination information, and data growth trends.
  • the database statistical information collection module 110 can collect table information of an online production database of a bank/financial institution and table information of a test database.
  • the script sentence capturing module 120 can capture the sentence information executed during the database test of the bank/financial institution in the test environment, abstract the captured sentences, classify and count the frequency.
  • the sentence analysis module 130 can calculate sentence consumption in combination with the sentence execution plan and the database statistics of the bank/financial institution.
  • the report management module 140 can perform four-quadrant classification based on the sentence frequency information and sentence consumption. And generate related statement performance test report.
  • FIG. 1 is only an example, which is not limited in the embodiment of the present invention.
  • FIG. 2 exemplarily shows the process of a method for testing database script performance provided by an embodiment of the present invention.
  • the process can be executed by a database script performance testing device, which can be located in the above-mentioned bank/financial institution.
  • the server 100 of the bank/financial institution may also be the server 100.
  • the SQL database will be taken as an example, and the statements involved are SQL statements.
  • the embodiment of the present invention is only an example, and is not limited to the SQL database.
  • the process specifically includes:
  • Step 201 Obtain table information of the online production database, table information of the test database, and database script information in the test database test process.
  • the database statistical information collection module 110 can be used to collect table information of the online production database and collect table information of the test database.
  • the script sentence capturing module 120 is used to capture the database script information during the test database test, and the script information includes a large amount of sentence information. It should be noted that when collecting the table information of the online generation database, the table information of the standby database of the production database can be collected.
  • the table information may include table field information, data volume information, index information, index discrimination information, and data growth trends.
  • Step 202 Preprocess the sentences in the database script information to obtain abstract sentences corresponding to the database script information; and determine the execution frequency of the abstract sentences.
  • the script statement capturing module 120 After the script statement capturing module 120 captures the script information of the database, it can delete the information related to the actual business in the statement of the database script information, and retain the main information required for execution plan analysis, which is equivalent to abstracting the statement. For example, you can delete the numerical information in the where condition, so that the script only retains the main information needed for execution plan analysis, and the rest are abstract statements.
  • the SQL script information captured by the script statement capturing module 120 may be as shown in Table 1.
  • the elements that affect the execution plan of the SQL statement include the table name (or subquery) after the From keyword, the field information after the where condition and the order of the fields, and the simple after the Select keyword The field name (the most commonly used), the constant data after the set keyword in the Update statement and the constant data after the where keyword in the Update statement do not affect the execution plan. Then the data in Table 1 above is abstracted and preprocessed, The obtained SQL abstraction statement can be shown in Figure 4.
  • the five abstract sentences shown in Table 2 can be grouped into one category, as shown in Table 3. After completing the SQL abstraction sentence classification, the execution frequency of the SQL abstraction sentence is counted according to the number of occurrences, and the SQL abstraction sentence and its execution frequency are registered in the table.
  • Step 203 Determine the consumption of the abstract sentence according to the table information of the production database and/or the table information of the test database, the abstraction sentence corresponding to the database script information, and the execution plan of the abstraction sentence .
  • the consumption of abstract sentences includes current consumption and estimated consumption.
  • determining the consumption of the abstract sentence it can be specifically: for the abstract sentence that exists in the table information of the production database, substituting the data volume information and/or index information and/or index discrimination information in the table information of the production database into There is an execution plan for the abstract statement of the table information of the production database, and the current consumption of the abstract statement of the table information of the production database is determined. And combined with the data growth trend in the table information of the production database, the estimated recent data statistics information is substituted into the execution plan of the abstract statement of the table information of the production database, and the estimation of the abstract statement of the table information of the production database is determined. Consumption.
  • the data volume information and/or index information and/or index discrimination information in the table information of the test database corresponding to the abstract statements in the table information of the production database are Perform conversion at a preset ratio, and substitute the converted data volume information and/or index information and/or index discrimination information into the execution plan of the abstract statement that does not exist in the production database table information, and determine that there is no production database table information The current consumption of abstract statements.
  • the statement analysis module 130 can be used to analyze the execution plan of the SQL abstract statement, and execute the Explain command that comes with the SQL database on the SQL abstract statement in the test environment to obtain the execution plan of the SQL abstract statement running in the test environment. .
  • the statistical information collected by the production database (content included in the table information) is substituted into the execution plan to calculate SQL consumption.
  • the number of scanned rows in the execution plan is taken as the statistical latitude. SQL consumption statistics.
  • the current consumption of the SQL abstraction statement can be calculated, combined with the data growth trend, the estimated recent data statistics are substituted into the execution plan, and the calculation Estimated consumption of SQL abstraction statements.
  • the estimated recent data is based on the data in the historical table combined with data growth trends.
  • the data volume information of the entire table substituted into the statistical data is used for consumption statistics.
  • the data volume information of the entire table and the index discrimination information are converted into index data volume information for consumption statistics.
  • the statistical data in the table information of the production database is as follows:
  • the data volume in table a is 20000, and the growth trend is linear growth, with a periodical growth step of 3000;
  • the data volume in the statistics of table b is 50000, because table b is a primary key index, the amount of scanned data is 1;
  • the data volume of table c is 10000, and the increasing trend is that the statistical average value of the index discrimination degree of the first 8 bits of the tmpsno field is 1000, and the scanned data volume obtained by combining conversion is 10000/1000 about 10.
  • the growth trend is a curve growth, and the slope change of the last few cycles is +0.15.
  • SQL consumption is 20000+(1*3000)+(10000+10000*0.15)/1000, which is about 23012.
  • the SQL consumption is 20000+(3*3000)+(10000*(1+0.15) ⁇ 3/1000) about 29015.
  • the table information of the test database If there is no data in production, according to the table information of the test database, it is converted according to a certain preset ratio and substituted into the calculation of the consumption of the SQL abstraction statement (including current consumption and estimated consumption).
  • the preset ratio can be set based on experience.
  • Step 204 Determine the performance index of the database script according to the consumption of the abstract sentence and the execution frequency of the abstract sentence.
  • the post-conversion consumption of abstract sentences can be determined according to the consumption and consumption threshold of abstract sentences, and the post-conversion consumption of abstract sentences can be determined according to the execution frequency and frequency threshold of abstract sentences. frequency.
  • the four-quadrant classification is performed to obtain the performance indicators of abstract sentences.
  • the performance index of abstract sentences is the content after four-quadrant classification. Among them, the current consumption and estimated consumption of abstract sentences are classified into four quadrants respectively.
  • the consumption threshold and frequency threshold can be set based on experience.
  • the SQL consumption in Table 2 is the consumption of SQL abstract statements.
  • the four-quadrant classification of the data in Table 2 above can obtain the four-quadrant distribution of SQL consumption as shown in Figure 3.
  • the SQL consumption value is a positive number that needs to be optimized, and the higher the frequency, the higher the optimization priority.
  • an optimization plan for the database script can be determined based on the performance indicators of the database script, the characteristics of the database, the table information of the production database, the table information of the test database, and the execution frequency of the abstract statement.
  • the report management module 140 is mainly used to provide the SQL script statement adjustment and optimization plan.
  • the SQL script statement optimization has mature optimization implementation plans in the industry, and the optimization plan and business logic are relatively related.
  • the embodiment of the present invention is based on the original optimization plan. On the basis of this, some special points related to the MYSQL database and the script sentence optimization proposal combined with statistical information are proposed.
  • the field order of SQL database query conditions will affect the execution consumption of SQL statements.
  • traverse the different sorting combinations in the query respectively count the consumption of SQL abstract statements, and select the lowest cost sorting method Mark as the best sort.
  • Mark the involved non-optimal sorted SQL abstraction statement as a sorted optimized SQL statement.
  • the index information in the basic statistical information of the database and the statistical information of the abstract sentence are obtained, and the secondary statistics are performed to obtain the fields in the query conditions corresponding to each table.
  • the number of occurrences to determine whether the field has an index, index type, and the position of the field in the joint index are Count the fields corresponding to the frequently occurring tables. If the field has no index, it is marked as the field information that may need to be optimized.
  • the report management module 140 can sort the analysis results and the SQL script sentence optimization plan, generate related SQL script sentence performance test reports, and submit it to the project team for SQL script sentence optimization.
  • the priority during optimization can be high frequency high consumption, low frequency high consumption.
  • the data growth trend information in the table information may not be collected, which can save the workload of the database statistical information collection module 110 and can only analyze the current consumption of the current current SQL statements. In this case, the estimated consumption of SQL statements cannot be achieved, and early warning cannot be given.
  • the execution frequency of the above abstract statements may not be counted. In this case, it is only necessary to perform full optimization on the SQL abstract statements analyzed as high consumption.
  • the embodiment of the present invention shows that by obtaining the table information of the online production database, the table information of the test database, and the database script information in the test process, the sentences in the database script information are preprocessed to obtain the abstract sentences corresponding to the database script information , And determine the execution frequency of the abstract statement, and determine the consumption of the abstract statement according to the table information of the production database and/or the table information of the test database, the abstract statement corresponding to the database script information, and the execution plan of the abstract statement.
  • the consumption of abstract sentences and the execution frequency of the abstract sentences determine the performance index of the database script. Because the table information of the online production database and the table information of the test database are combined to perform the performance test of the database script, it can save the manpower and resource expenses of the test environment or the preparation of the quasi-production environment.
  • database script performance test process in the embodiment of the present invention can be applied to various database script performance tests in banks/financial institutions.
  • FIG. 4 exemplarily shows the structure of a database script performance test device provided by an embodiment of the present invention.
  • the device can execute the process of database script performance test.
  • the device can be located in the server 100. , Or the server 100.
  • the device specifically includes:
  • the obtaining unit 401 is configured to obtain table information of the online production database, table information of the test database, and database script information during the test database test process;
  • the processing unit 402 is configured to preprocess the sentences in the database script information to obtain abstract sentences corresponding to the database script information; and determine the execution frequency of the abstract sentences; according to the table of the production database Information and/or the table information of the test database, the abstraction sentence corresponding to the database script information, and the execution plan of the abstraction sentence, determine the consumption of the abstraction sentence; according to the consumption sum of the abstraction sentence
  • the execution frequency of the abstract sentence determines the performance index of the database script.
  • processing unit 402 is specifically configured to:
  • the information related to the actual business in the sentence of the database script information is deleted.
  • the consumption of the abstract sentence includes current consumption and estimated consumption
  • the table information of the production database includes data volume information, index information, index discrimination information, and data growth trend
  • table information of the test database Including data volume information, index information, index discrimination information, and data growth trends
  • the processing unit 402 is specifically configured to:
  • the plan is to determine the current consumption of abstract sentences in the table information of the production database; and combine the data growth trend in the table information of the production database to substitute estimated recent data statistics into the table information of the production database
  • the execution plan of the abstraction statement determines the estimated consumption of the abstraction statement that exists in the table information of the production database
  • the data volume information and/or index information and/or index discrimination degree in the table information of the test database corresponding to the abstract sentences in the table information of the production database are not present
  • the information is converted according to a preset ratio, and the converted data volume information and/or index information and/or index discrimination information are substituted into the execution plan of the abstract statement that does not exist in the table information of the production database, and the non-existence is determined.
  • the current consumption of abstract sentences that exist in the table information of the production database; and the data growth trend in the table information of the test database corresponding to the abstract sentences that do not exist in the table information of the production database is substituted into the estimated recent data statistics information
  • the execution plan of the abstract sentence without the table information of the production database determines the estimated consumption of the abstract sentence without the table information of the production database.
  • processing unit 402 is specifically configured to:
  • a four-quadrant classification is performed to obtain the abstract sentence Performance.
  • processing unit 402 is further configured to:
  • the execution frequency of the database script determines the optimization plan of the database script.
  • an embodiment of the present invention also provides a computing device, including:
  • Memory used to store program instructions
  • the processor is configured to call the program instructions stored in the memory, and execute the above-mentioned database script performance test method according to the obtained program.
  • the embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions.
  • the computer reads and executes the computer-readable instructions, the computer executes the above-mentioned database. Script performance testing method.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据库脚本性能测试的方法及装置,该方法包括:获取线上生产数据库的表信息、测试数据库的表信息、以及测试过程中的数据库脚本信息(201);对数据库脚本信息中的语句进行预处理,得到数据库脚本信息对应的抽象化语句,并确定出抽象化语句的执行频次(202);根据生产数据库的表信息和/或测试数据库的表信息、数据库脚本信息对应的抽象化语句及抽象化语句的执行计划,确定抽象化语句的消耗(203);根据抽象化语句的消耗和抽象化语句的执行频次,确定出数据库脚本的性能指标(204)。由于结合了线上生产数据库的表信息和测试数据库的表信息来进行数据库脚本的性能测试,可以节省测试环境造数或准备准生产环境的人力及资源开销。

Description

一种数据库脚本性能测试的方法及装置
相关申请的交叉引用
本申请要求在2019年06月26日提交中国专利局、申请号为201910562575.5、申请名称为“一种数据库脚本性能测试的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明实施例涉及金融科技(Fintech)领域,尤其涉及一种数据库脚本性能测试的方法及装置。
背景技术
随着计算机技术的发展,越来越多的技术(如大数据、分布式、区块链(Blockchain)、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,性能测试技术也不例外,但由于金融、支付行业的安全性、实时性要求,也对技术提出的更高的要求。
目前,银行/金融机构在进行数据库脚本性能测试时,通常有以下两种形式:第一种为银行/金融机构通过在测试环境造数的方式来模拟实际的线上生产数据库的数据。这种方案的缺点在于造数过程的时间开销,同时也必然加大测试环境的资源需求,数据量大了测试资源就需要扩充,数据量小了可能无法达到性能测试的数据需求。第二种为银行/金融机构通过线上生产数据库的数据副本,搭建一套准生产环境数据库用作性能测试使用。这种方案的缺点在与资源的需求上,对银行/金融机构的数据库资源需求会产生翻倍,造成资源紧缺。
发明内容
本发明实施例提供一种数据库脚本性能测试的方法及装置,用以节约测 试环境造数或准备准生产环境的人力及资源开销。
第一方面,本发明实施例提供的一种数据库脚本性能测试的方法,包括:
获取线上生产数据库的表信息、测试数据库的表信息以及所述测试数据库测试过程中的数据库脚本信息;
对所述数据库脚本信息中的语句进行预处理,得到所述数据库脚本信息对应的抽象化语句;并确定出所述抽象化语句的执行频次;
根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗;
根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标。
上述技术方案中,由于结合了线上生产数据库的表信息和测试数据库的表信息来进行数据库脚本的性能测试,从而得到数据库脚本的性能指标,用于指示判别脚本优化的优先级,可以节省测试环境造数的人力资源以及降低准备准生产环境的资源开销。
可选的,所述对所述数据库脚本信息中的语句进行预处理,包括:
将所述数据库脚本信息的语句中的与实际业务相关的信息删除。
可选的,所述抽象化语句的消耗包括当前消耗和预估消耗;所述生产数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;所述测试数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;
所述根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗,包括:
对于存在生产数据库的表信息的抽象化语句,将生产数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的 抽象化语句的当前消耗;以及结合生产数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的预估消耗;
对于不存在生产数据库的表信息的抽象化语句,将所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息按照预设比例进行转换,将转换后的数据量信息和/或索引信息和/或索引区分度信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的当前消耗;以及结合所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的预估消耗。
可选的,所述根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标,包括:
根据所述抽象化语句的消耗和消耗阈值,确定出所述抽象化语句的转换后消耗;
根据所述抽象化语句的执行频次和频次阈值,确定出所述抽象化语句的转换后频次;
根据所述抽象化语句的消耗、所述抽象化语句的执行频次、所述抽象化语句的转换后消耗和所述抽象化语句的转换后频次,进行四象限分类,得到所述抽象化语句的性能指标。
可选的,在所述确定出所述数据库脚本的性能指标之后,还包括:
若还存在数据核对状态为核对失败的同步信息,则根据所述数据核对状态为核对失败的同步信息中的时间分片信息,重新从所述联机处理系统的数据库中读取数据,插入到所述批量处理系统的数据库中,并更新所述补充处理状态根据所述数据库脚本的性能指标、所述数据库的特征、所述生产数据库的表信息、所述测试数据库的表信息和所述抽象化语句的执行频次,确定 出所述数据库脚本的优化方案。
第二方面,本发明实施例提供一种数据库脚本性能测试的装置,包括:
获取单元,用于获取线上生产数据库的表信息、测试数据库的表信息以及所述测试数据库测试过程中的数据库脚本信息;
处理单元,用于对所述数据库脚本信息中的语句进行预处理,得到所述数据库脚本信息对应的抽象化语句;并确定出所述抽象化语句的执行频次;根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗;根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标。
可选的,所述处理单元具体用于:
将所述数据库脚本信息的语句中的与实际业务相关的信息删除。
可选的,所述抽象化语句的消耗包括当前消耗和预估消耗;所述生产数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;所述测试数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;
所述处理单元具体用于:
对于存在生产数据库的表信息的抽象化语句,将生产数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的当前消耗;以及结合生产数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的预估消耗;
对于不存在生产数据库的表信息的抽象化语句,将所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息按照预设比例进行转换,将转换后的数据量信息和/或索引信息和/或索引区分度信息代入所述不存在生产数据库的表信息的 抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的当前消耗;以及结合所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的预估消耗。
可选的,所述处理单元具体用于:
根据所述抽象化语句的消耗和消耗阈值,确定出所述抽象化语句的转换后消耗;
根据所述抽象化语句的执行频次和频次阈值,确定出所述抽象化语句的转换后频次;
根据所述抽象化语句的消耗、所述抽象化语句的执行频次、所述抽象化语句的转换后消耗和所述抽象化语句的转换后频次,进行四象限分类,得到所述抽象化语句的性能指标。
可选的,所述处理单元还用于:
在所述确定出所述数据库脚本的性能指标之后,根据所述数据库脚本的性能指标、所述数据库的特征、所述生产数据库的表信息、所述测试数据库的表信息和所述抽象化语句的执行频次,确定出所述数据库脚本的优化方案。
第三方面,本发明实施例还提供了一种计算设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述数据库脚本性能测试的方法。
第四方面,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述数据库脚本性能测试的方法。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中 所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种系统架构的示意图;
图2为本发明实施例提供的一种数据库脚本性能测试的方法的流程示意图;
图3为本发明实施例提供的一种四象限分布的示意图;
图4为本发明实施例提供的一种数据库脚本性能测试的装置的结构示意图。
具体实施方式
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
图1示例性的示出了本发明实施例所适用的一种系统架构,该系统架构可以为银行/金融机构用于数据库脚本测试的服务器100,该服务器100可以包括数据库统计信息采集模块110、脚本语句捕获模块120、语句分析模块130和报表管理模块140。
其中,数据库统计信息采集模块110可以采集银行/金融机构的数据库统计信息,也就是表信息,包括表字段信息、数据量信息、索引信息、索引区分度信息和数据增长趋势等。例如,数据库统计信息采集模块110可以采集银行/金融机构的线上生产数据库的表信息和测试数据库的表信息。
脚本语句捕获模块120可以捕获测试环境下银行/金融机构的数据库测试过程中执行的语句信息,对捕获的语句进行抽象化,归类并统计频次。
语句分析模块130可以结合语句执行计划及银行/金融机构的数据库统计 信息来计算语句的消耗。
报表管理模块140可以结合语句频次信息和语句的消耗,进行四象限分类。并生成相关语句性能测试报表。
需要说明的是,上述图1所示的结构仅是一种示例,本发明实施例对此不做限定。
基于上述描述,图2示例性的示出了本发明实施例提供的一种数据库脚本性能测试的方法的流程,该流程可以由数据库脚本性能测试的装置执行,该装置可以位于上述银行/金融机构的服务器100内,也可以是该银行/金融机构的服务器100。
需要说明的是,下面在描述数据库脚本性能测试的流程中,将以SQL数据库为例,涉及的语句为SQL语句。本发明实施例仅是示例作用,并不限于该SQL数据库。
如图2所示,该流程具体包括:
步骤201,获取线上生产数据库的表信息、测试数据库的表信息以及所述测试数据库测试过程中的数据库脚本信息。
在具体应用时,可以通过数据库统计信息采集模块110来采集线上生产数据库的表信息,以及采集测试数据库的表信息。通过脚本语句捕获模块120来捕获测试数据库测试过程中的数据库脚本信息,脚本信息包括大量的语句信息。需要说明的是,采集线上生成数据库的表信息时,可以采集生产数据库的备库的表信息。在本发明实施例中,表信息可以包括表字段信息、数据量信息、索引信息、索引区分度信息和数据增长趋势等信息。
步骤202,对所述数据库脚本信息中的语句进行预处理,得到所述数据库脚本信息对应的抽象化语句;并确定出所述抽象化语句的执行频次。
当脚本语句捕获模块120捕获到数据库的脚本信息之后,就可以将数据库脚本信息的语句中的与实际业务相关的信息删除,保留执行计划分析需要的主干信息,相当于对语句进行抽象化处理。例如可以删除where条件中的数值信息,使得脚本只保留执行计划分析需要的主干信息,剩下的就是抽象 化语句。
举例来说,通过脚本语句捕获模块120捕获的SQL脚本信息可以如表1所示。在表1中,SQL语句的组成中,影响SQL语句执行计划的要素包括From关键字后的表名(或子查询),where条件后的字段信息及字段的先后排序,Select关键字后的简单的字段名(最常用的),Update语句中set关键词后常量数据及where关键字后的常量数据这块是不影响执行计划的,那么将上面表1中的数据进行抽象化预处理后,得到的SQL抽象化语句可以如图4所示。
表1
select*from student where class=’103’and name=’Tom’;
select name,score from student where class=’103’and name=’Tom’;
select name,score from student where class=’104’and name=’Juily’;
delete from student where class=’103’and name=’Tom’;
update student set score=’100’where class=’103’and name=’Tom’;
然后将图2所示的SQL抽象化语句进行分类,按照执行计划依赖因素来统计。
表2
Figure PCTCN2020096905-appb-000001
可以将表2所示的5个抽象化语句同一为1类,如表3所示。完成SQL抽象化语句分类之后,按照出现的次数统计出SQL抽象化语句的执行频次,并将该SQL抽象化语句及其执行频次登记在表中。
表3
Figure PCTCN2020096905-appb-000002
步骤203,根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗。
本发明实施例中,抽象化语句的消耗包括当前消耗和预估消耗。在确定该抽象化语句的消耗时,具体可以为:对于存在生产数据库的表信息的抽象化语句,将生产数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息代入存在生产数据库的表信息的抽象化语句的执行计划,确定出存在生产数据库的表信息的抽象化语句的当前消耗。以及结合生产数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入存在生产数据库的表信息的抽象化语句的执行计划,确定出存在生产数据库的表信息的抽象化语句的预估消耗。
对于不存在生产数据库的表信息的抽象化语句,将不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息按照预设比例进行转换,将转换后的数据量信息和/或索引信息和/或索引区分度信息代入不存在生产数据库的表信息的抽象化语句的执行计划,确定出不存在生产数据库的表信息的抽象化语句的当前消耗。以及结合不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入不存在生产数据库的表信息的抽象化语句的执行计划,确定出不存在生产数据库的表信息的抽象化语句的预估消耗。
举例来说,可以通过语句分析模块130,就SQL抽象化语句进行执行计划分析,在测试环境中对SQL抽象化语句执行SQL数据库自带的Explain命令得到SQL抽象化语句在测试环境运行的执行计划。
对于存在产数据库的表信息的SQL抽象化语句,在执行计划中代入生产数据库采集的统计信息(表信息中包括的内容),计算SQL消耗,这里以执行计划中的扫描行数为统计纬度进行SQL消耗统计。
根据统计的当前正在统计的SQL抽象化语句对应的生产数据库的表的数据量信息可以计算出SQL抽象化语句的当前消耗,结合数据增长趋势,将预估的近期数据统计信息代入执行计划,计算出SQL抽象化语句的预估消耗。该预估的近期数据是依据历史的表中的数据结合数据增长趋势得到的。
对于执行计划中查询类型为“ALL”的,代入统计数据的全表的数据量信息进行消耗统计。对于查询类型为“range”和“index”的,结合全表的数据量信息及索引区分度信息,换算成索引数据量信息,进行消耗统计。
例如,如表4所示的SQL抽象化语句在测试环境中的执行计划。
表4
Figure PCTCN2020096905-appb-000003
生产数据库的表信息中统计数据如下:
a表统计信息中数据量20000,增长趋势为线性增长,一个周期增长步长为3000;
b表统计信息中数据量为50000,由于b表是主键索引,扫描数据量为1;
c表数据量为10000,增长趋势为tmpsno字段前8位的索引区分度统计均值为1000,则结合换算得到的扫描数据量为10000/1000约为10。增长趋势为曲线增长,上几个周期的斜率变化为+0.15。
将上述a、b、c三个表整体代入执行计划,可以得到SQL抽象化语句的当前消耗为:20000*1+10约为20010。
SQL抽象化语句的预估消耗为:
1周期后SQL消耗为20000+(1*3000)+(10000+10000*0.15)/1000约为23012。
3周期后SQL消耗为20000+(3*3000)+(10000*(1+0.15)^3/1000)约为29015。
对于生产上暂无数据的,根据测试数据库的表信息,按一定预设比例换算并代入计算SQL抽象化语句的消耗(包括当前消耗和预估消耗)。该预设比例可以依据经验设置。
步骤204,根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标。
当得到抽象化语句的消耗之后,就可以根据抽象化语句的消耗和消耗阈值,确定出抽象化语句的转换后消耗,根据抽象化语句的执行频次和频次阈值,确定出抽象化语句的转换后频次。然后根据抽象化语句的消耗、抽象化语句的执行频次、抽象化语句的转换后消耗和抽象化语句的转换后频次,进行四象限分类,得到抽象化语句的性能指标。抽象化语句的性能指标也就是四象限分类后的内容。其中,抽象化语句的当前消耗和预估消耗都分别进行四象限分类。该消耗阈值和频次阈值可以依据经验设置。
例如,假设现在有一组消耗信息如表2所示,其中,消耗阈值为20000,频次阈值为500。表2中的SQL消耗即为SQL抽象化语句的消耗。将上述表2中的数据进行四象限分类,可以得到如图3所示的SQL消耗四象限分布。其中,在对数据库脚本进行优化时,SQL消耗值为正数的是需要优化的,频次越高的优化优先级越高。
表5
SQL抽象化语句编号 执行频次 SQL消耗 转换后频次 转换后消耗
1 10 32000 -490 12000
2 150 30 -350 -19970
3 350 4000 -150 -16000
4 40 4001 -460 -15999
5 280 4002 -220 -15998
6 60 4003 -440 -15997
7 5 4004 -495 -15996
8 80 4005 -420 -15995
9 23 4006 -477 -15994
10 100 4007 -400 -15993
11 110 50000 -390 30000
12 730 48000 230 28000
13 750 5000 250 -15000
14 770 15000 270 -5000
15 770 3333 270 -16667
16 899 52000 399 32000
在得到抽象化语句的性能指标之后,还可以根据数据库脚本的性能指标、数据库的特征、生产数据库的表信息、测试数据库的表信息和抽象化语句的执行频次,确定出数据库脚本的优化方案。
这里主要是通过报表管理模块140,给出SQL脚本语句调整优化方案,SQL脚本语句优化现在业界已有成熟的优化实现方案,而且优化方案和业务逻辑关联较大,本发明实施例在原有优化方案的基础上,提出几点MYSQL数据库相关的特殊点及结合统计信息的脚本语句优化建议方案。
例如,1、SQL数据库查询条件的字段顺序会影响SQL语句执行消耗,根据SQL抽象化语句的主干信息,遍历查询中的不同排序组合,分别统计SQL抽象化语句的消耗,取消耗最低的排序方式标记为最优排序。并将涉及的非最优排序的SQL抽象化语句标记为待排序优化SQL语句。
2、结合生产数据库的表信息和测试数据库的表信息,得出的数据库基础统计信息中的索引信息及抽象化语句的统计信息,进行二次统计,得出每张表对应的查询条件中字段的出现次数,确定字段是否存在索引、索引类型、字段在联合索引中的位置。统计高频出现的表对应的字段,如该字段无索引, 标记为可能需要优化的字段信息。
然后报表管理模块140可以整理分析结果和SQL脚本语句优化方案,生成相关SQL脚本语句性能测试报表,提交项目组进行SQL脚本语句优化。进行优化时的优先级可以为高频高消耗、低频高消耗。
需要说明的是,在具体实施过程中,可以不采集表信息中的数据增长趋势信息,这样可以节约数据库统计信息采集模块110的工作量,可以只分析当前现状的SQL语句的当前消耗。这种情况下,无法实现SQL语句的预估消耗,无法进行提前预警。
可选的,上述抽象化语句的执行频次可以不做统计,这种情况下只需对分析为高消耗的SQL抽象化语句进行全量优化。
本发明实施例表明,通过获取线上生产数据库的表信息、测试数据库的表信息、测试过程中的数据库脚本信息,对数据库脚本信息中的语句进行预处理,得到数据库脚本信息对应的抽象化语句,并确定出抽象化语句的执行频次,根据生产数据库的表信息和/或测试数据库的表信息、数据库脚本信息对应的抽象化语句以及抽象化语句的执行计划,确定抽象化语句的消耗,根据抽象化语句的消耗和所述抽象化语句的执行频次,确定出数据库脚本的性能指标。由于结合了线上生产数据库的表信息和测试数据库的表信息来进行数据库脚本的性能测试,可以节省测试环境造数或准备准生产环境的人力及资源开销。
需要说明的是,本发明实施例中的数据库脚本性能测试的流程可以应用于银行/金融机构中的各种数据库脚本性能测试中。
基于相同的技术构思,图4示例性的示出了本发明实施例提供的一种数据库脚本性能测试的装置的结构,该装置可以执行数据库脚本性能测试的流程,该装置可以位于上述服务器100内,也可以是该服务器100。
如图4所示,该装置具体包括:
获取单元401,用于获取线上生产数据库的表信息、测试数据库的表信息以及所述测试数据库测试过程中的数据库脚本信息;
处理单元402,用于对所述数据库脚本信息中的语句进行预处理,得到所述数据库脚本信息对应的抽象化语句;并确定出所述抽象化语句的执行频次;根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗;根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标。
可选的,所述处理单元402具体用于:
将所述数据库脚本信息的语句中的与实际业务相关的信息删除。
可选的,所述抽象化语句的消耗包括当前消耗和预估消耗;所述生产数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;所述测试数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;
所述处理单元402具体用于:
对于存在生产数据库的表信息的抽象化语句,将生产数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的当前消耗;以及结合生产数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的预估消耗;
对于不存在生产数据库的表信息的抽象化语句,将所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息按照预设比例进行转换,将转换后的数据量信息和/或索引信息和/或索引区分度信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的当前消耗;以及结合所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在 生产数据库的表信息的抽象化语句的预估消耗。
可选的,所述处理单元402具体用于:
根据所述抽象化语句的消耗和消耗阈值,确定出所述抽象化语句的转换后消耗;
根据所述抽象化语句的执行频次和频次阈值,确定出所述抽象化语句的转换后频次;
根据所述抽象化语句的消耗、所述抽象化语句的执行频次、所述抽象化语句的转换后消耗和所述抽象化语句的转换后频次,进行四象限分类,得到所述抽象化语句的性能指标。
可选的,所述处理单元402还用于:
在所述确定出所述数据库脚本的性能指标之后,根据所述数据库脚本的性能指标、所述数据库的特征、所述生产数据库的表信息、所述测试数据库的表信息和所述抽象化语句的执行频次,确定出所述数据库脚本的优化方案。
基于相同的技术构思,本发明实施例还提供了一种计算设备,包括:
存储器,用于存储程序指令;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述数据库脚本性能测试的方法。
基于相同的技术构思,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述数据库脚本性能测试的方法。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流 程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (12)

  1. 一种数据库脚本性能测试的方法,其特征在于,包括:
    获取线上生产数据库的表信息、测试数据库的表信息以及所述测试数据库测试过程中的数据库脚本信息;
    对所述数据库脚本信息中的语句进行预处理,得到所述数据库脚本信息对应的抽象化语句;并确定出所述抽象化语句的执行频次;
    根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗;
    根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标。
  2. 如权利要求1所述的方法,其特征在于,所述对所述数据库脚本信息中的语句进行预处理,包括:
    将所述数据库脚本信息的语句中的与实际业务相关的信息删除。
  3. 如权利要求1所述的方法,其特征在于,所述抽象化语句的消耗包括当前消耗和预估消耗;所述生产数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;所述测试数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;
    所述根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗,包括:
    对于存在生产数据库的表信息的抽象化语句,将生产数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的当前消耗;以及结合生产数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述存在生产数据库的表信息的抽象化语句的 执行计划,确定出所述存在生产数据库的表信息的抽象化语句的预估消耗;
    对于不存在生产数据库的表信息的抽象化语句,将所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息按照预设比例进行转换,将转换后的数据量信息和/或索引信息和/或索引区分度信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的当前消耗;以及结合所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的预估消耗。
  4. 如权利要求1所述的方法,其特征在于,所述根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标,包括:
    根据所述抽象化语句的消耗和消耗阈值,确定出所述抽象化语句的转换后消耗;
    根据所述抽象化语句的执行频次和频次阈值,确定出所述抽象化语句的转换后频次;
    根据所述抽象化语句的消耗、所述抽象化语句的执行频次、所述抽象化语句的转换后消耗和所述抽象化语句的转换后频次,进行四象限分类,得到所述抽象化语句的性能指标。
  5. 如权利要求1至4任一项所述的方法,其特征在于,在所述确定出所述数据库脚本的性能指标之后,还包括:
    根据所述数据库脚本的性能指标、所述数据库的特征、所述生产数据库的表信息、所述测试数据库的表信息和所述抽象化语句的执行频次,确定出所述数据库脚本的优化方案。
  6. 一种数据库脚本性能测试的装置,其特征在于,包括:
    获取单元,用于获取线上生产数据库的表信息、测试数据库的表信息以 及所述测试数据库测试过程中的数据库脚本信息;
    处理单元,用于对所述数据库脚本信息中的语句进行预处理,得到所述数据库脚本信息对应的抽象化语句;并确定出所述抽象化语句的执行频次;根据所述生产数据库的表信息和/或所述测试数据库的表信息、所述数据库脚本信息对应的抽象化语句以及所述抽象化语句的执行计划,确定所述抽象化语句的消耗;根据所述抽象化语句的消耗和所述抽象化语句的执行频次,确定出所述数据库脚本的性能指标。
  7. 如权利要求6所述的装置,其特征在于,所述处理单元具体用于:
    将所述数据库脚本信息的语句中的与实际业务相关的信息删除。
  8. 如权利要求6所述的装置,其特征在于,所述抽象化语句的消耗包括当前消耗和预估消耗;所述生产数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;所述测试数据库的表信息包括数据量信息、索引信息、索引区分度信息、数据增长趋势;
    所述处理单元具体用于:
    对于存在生产数据库的表信息的抽象化语句,将生产数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的当前消耗;以及结合生产数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所述存在生产数据库的表信息的抽象化语句的执行计划,确定出所述存在生产数据库的表信息的抽象化语句的预估消耗;
    对于不存在生产数据库的表信息的抽象化语句,将所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据量信息和/或索引信息和/或索引区分度信息按照预设比例进行转换,将转换后的数据量信息和/或索引信息和/或索引区分度信息代入所述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的当前消耗;以及结合所述不存在生产数据库的表信息的抽象化语句对应的测试数据库的表信息中的数据增长趋势将预估的近期数据统计信息代入所 述不存在生产数据库的表信息的抽象化语句的执行计划,确定出所述不存在生产数据库的表信息的抽象化语句的预估消耗。
  9. 如权利要求6所述的装置,其特征在于,所述处理单元具体用于:
    根据所述抽象化语句的消耗和消耗阈值,确定出所述抽象化语句的转换后消耗;
    根据所述抽象化语句的执行频次和频次阈值,确定出所述抽象化语句的转换后频次;
    根据所述抽象化语句的消耗、所述抽象化语句的执行频次、所述抽象化语句的转换后消耗和所述抽象化语句的转换后频次,进行四象限分类,得到所述抽象化语句的性能指标。
  10. 如权利要求6至9任一项所述的装置,其特征在于,所述处理单元还用于:
    在所述确定出所述数据库脚本的性能指标之后,根据所述数据库脚本的性能指标、所述数据库的特征、所述生产数据库的表信息、所述测试数据库的表信息和所述抽象化语句的执行频次,确定出所述数据库脚本的优化方案。
  11. 一种计算设备,其特征在于,包括:
    存储器,用于存储程序指令;
    处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至5任一项所述的方法。
  12. 一种计算机可读非易失性存储介质,其特征在于,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如权利要求1至5任一项所述的方法。
PCT/CN2020/096905 2019-06-26 2020-06-18 一种数据库脚本性能测试的方法及装置 Ceased WO2020259391A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910562575.5 2019-06-26
CN201910562575.5A CN110287114B (zh) 2019-06-26 2019-06-26 一种数据库脚本性能测试的方法及装置

Publications (1)

Publication Number Publication Date
WO2020259391A1 true WO2020259391A1 (zh) 2020-12-30

Family

ID=68006171

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/096905 Ceased WO2020259391A1 (zh) 2019-06-26 2020-06-18 一种数据库脚本性能测试的方法及装置

Country Status (2)

Country Link
CN (1) CN110287114B (zh)
WO (1) WO2020259391A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287114B (zh) * 2019-06-26 2021-06-04 深圳前海微众银行股份有限公司 一种数据库脚本性能测试的方法及装置
CN112035513A (zh) * 2020-09-02 2020-12-04 中国平安人寿保险股份有限公司 Sql语句性能优化方法、装置、终端及存储介质
CN112181831B (zh) * 2020-09-28 2024-09-27 中国平安财产保险股份有限公司 基于关键词的脚本性能校验方法、装置、设备及存储介质
CN117290373B (zh) * 2022-06-17 2025-10-31 腾讯科技(深圳)有限公司 一种语句分析方法及相关设备
CN115687364B (zh) * 2022-11-16 2025-09-19 深圳前海微众银行股份有限公司 一种确定数据库命令的预测资源消耗量方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080250046A1 (en) * 2005-03-15 2008-10-09 International Business Machines Corporation Analysis of performance data from a relational database system for applications using stored procedures or sql
CN102486748A (zh) * 2010-12-02 2012-06-06 金蝶软件(中国)有限公司 一种性能测试的方法及装置
CN105760286A (zh) * 2016-02-17 2016-07-13 中国工商银行股份有限公司 应用数据库动态性能检测方法及检测装置
CN107844425A (zh) * 2017-11-16 2018-03-27 中国银行股份有限公司 一种数据库语句检查方法和装置
CN110287114A (zh) * 2019-06-26 2019-09-27 深圳前海微众银行股份有限公司 一种数据库脚本性能测试的方法及装置

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7860899B2 (en) * 2007-03-26 2010-12-28 Oracle International Corporation Automatically determining a database representation for an abstract datatype
US20100306591A1 (en) * 2009-06-01 2010-12-02 Murali Mallela Krishna Method and system for performing testing on a database system
CN103399851B (zh) * 2013-06-25 2017-02-08 上海携程商务有限公司 一种结构化查询语言(sql)脚本的性能分析与预测方法与系统
CN103390066B (zh) * 2013-08-08 2016-02-17 上海新炬网络信息技术有限公司 一种数据库全局性自动化优化预警装置及其处理方法
CN103617273B (zh) * 2013-12-05 2016-09-14 用友网络科技股份有限公司 Sql脚本对象化的方法及系统
CN103761080B (zh) * 2013-12-25 2017-02-15 中国农业大学 一种基于SQL的MapReduce作业生成方法及系统
CN108984374B (zh) * 2017-06-01 2021-05-07 腾讯科技(深圳)有限公司 一种数据库性能的测试方法和系统
CN108170775A (zh) * 2017-12-26 2018-06-15 上海新炬网络技术有限公司 一种数据库sql索引动态优化方法
CN108388626A (zh) * 2018-02-12 2018-08-10 平安科技(深圳)有限公司 Sql自动优化方法、装置、计算机设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080250046A1 (en) * 2005-03-15 2008-10-09 International Business Machines Corporation Analysis of performance data from a relational database system for applications using stored procedures or sql
CN102486748A (zh) * 2010-12-02 2012-06-06 金蝶软件(中国)有限公司 一种性能测试的方法及装置
CN105760286A (zh) * 2016-02-17 2016-07-13 中国工商银行股份有限公司 应用数据库动态性能检测方法及检测装置
CN107844425A (zh) * 2017-11-16 2018-03-27 中国银行股份有限公司 一种数据库语句检查方法和装置
CN110287114A (zh) * 2019-06-26 2019-09-27 深圳前海微众银行股份有限公司 一种数据库脚本性能测试的方法及装置

Also Published As

Publication number Publication date
CN110287114B (zh) 2021-06-04
CN110287114A (zh) 2019-09-27

Similar Documents

Publication Publication Date Title
WO2020259391A1 (zh) 一种数据库脚本性能测试的方法及装置
CN107633265B (zh) 用于优化信用评估模型的数据处理方法及装置
CN112508053A (zh) 基于集成学习框架的智能诊断方法、装置、设备及介质
CN108470022B (zh) 一种基于运维管理的智能工单质检方法
Zhang et al. Fast fine-grained air quality index level prediction using random forest algorithm on cluster computing of spark
CN110490229A (zh) 一种基于spark和聚类算法的电能表检定误差诊断方法
WO2021128523A1 (zh) 一种基于科技大数据的技术成熟度判断方法和系统
CN108229588A (zh) 一种基于深度学习的机器学习识别方法
CN102541736A (zh) 一种软件可靠性执行过程加速测试方法
CN109376247A (zh) 一种基于关联规则的软件缺陷自动分类方法
CN115080386B (zh) 基于自动驾驶功能要求的场景有效性分析方法与设备
WO2022143431A1 (zh) 一种反洗钱模型的训练方法及装置
CN115456695A (zh) 一种店铺选址的分析方法、装置、系统及介质
CN117421226A (zh) 一种基于生成式大语言模型的缺陷报告重构的方法及系统
WO2023082788A1 (zh) 烟气含氧量负荷预测方法、预测模型选择方法、烟气排放预测方法及装置
CN110310012B (zh) 数据分析方法、装置、设备及计算机可读存储介质
CN112085335A (zh) 一种用于配电网故障预测的改进随机森林算法
CN103207804B (zh) 基于集群作业日志的MapReduce负载模拟方法
CN105631465A (zh) 一种基于密度峰值的高效层次聚类方法
CN116823320A (zh) 一种营商环境数据分析处理方法、系统、设备及存储介质
CN115526501A (zh) 一种基于融合聚类的智能建筑节能评估方法
CN114331175A (zh) 一种城市安全绩效数据集中统计评估方法及系统
CN120653523A (zh) 一种基于机器学习的麒麟系统性能优化方法
CN107729942A (zh) 一种结构化视图缺失数据的分类方法
CN112052284A (zh) 一种大数据下的主数据管理方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20830942

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20830942

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 060422)

122 Ep: pct application non-entry in european phase

Ref document number: 20830942

Country of ref document: EP

Kind code of ref document: A1