CN106844634B - Database transaction optimization method and system - Google Patents
Database transaction optimization method and system Download PDFInfo
- Publication number
- CN106844634B CN106844634B CN201710043446.6A CN201710043446A CN106844634B CN 106844634 B CN106844634 B CN 106844634B CN 201710043446 A CN201710043446 A CN 201710043446A CN 106844634 B CN106844634 B CN 106844634B
- Authority
- CN
- China
- Prior art keywords
- transaction
- program
- function
- transaction processing
- processing program
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/217—Database tuning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
Abstract
The invention relates to the field of data processing, in particular to a database transaction optimization method and a database transaction optimization system, which improve the transaction processing efficiency through the following steps: acquiring a first transaction processing program corresponding to a first transaction; annotating a start transaction function of the first transaction handler to obtain a first program; if the first program fails to operate, acquiring a first function causing the first program to fail to operate; judging whether a second transaction processing program corresponding to a second transaction comprises the first function or not; and if so, running the second transaction processing program. The invention improves the transaction processing efficiency and simultaneously ensures the correctness of data processing to a certain extent.
Description
Technical Field
The invention relates to the field of data processing, in particular to a database transaction optimization method and a database transaction optimization system.
Background
Database transactions (Database transactions) refer to a series of operations that are performed as a single logical unit of work, either performed completely or not performed at all. Transaction processing can ensure that data-oriented resources are not permanently updated unless all operations within a transactional unit are successfully completed. By combining a set of related operations into one unit that either all succeeds or all fails, error recovery can be simplified and the application can be made more reliable. To become a logical unit of work a transaction, the so-called ACID (atomicity, consistency, isolation, and durability) properties must be satisfied. The transaction is a logical work unit in database operation, and the transaction management subsystem in the database management system is responsible for processing the transaction.
At present, when a database is operated, some special situations need to be considered, and the transaction needs to be rolled back, but actually, the probability of really generating problems is very low, and the performance of the database is reduced because a transaction processing method is adopted every time.
The application numbers are: 201310414935.X, which is a chinese patent, discloses a database transaction processing method and apparatus for allowing transactions to work across threads, the database transaction processing method comprising: judging whether a user in the first transaction is in a working state or not to obtain a first judgment result; when the first judgment result is that the user is in a non-working state, controlling the first transaction to be in a suspended state, and giving the thread corresponding to the first transaction to other users for use; judging whether the user returns to a working state or not, and obtaining a second judgment result; and when the second judgment result is that the user returns to the working state, calling the first transaction, and executing the first transaction on any idle thread. When the transaction is in a non-working state, the transaction is controlled to be in a suspended state, and the thread corresponding to the first transaction is used by other users, so that the processing efficiency of the transaction can be improved on a certain program.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the method and the system for optimizing the database transaction improve the database transaction processing efficiency and ensure the correctness of data processing.
In order to solve the technical problem, the invention provides a database transaction optimization method, which comprises the following steps:
s1: acquiring a first transaction processing program corresponding to a first transaction;
s2: annotating a start transaction function of the first transaction handler to obtain a first program;
s3: if the first program fails to operate, acquiring a first function causing the first program to fail to operate;
s4: judging whether a second transaction processing program corresponding to a second transaction comprises the first function or not; and if so, running the second transaction processing program.
The invention also provides a database transaction optimization system, which comprises:
the system comprises a first acquisition module, a second acquisition module and a processing module, wherein the first acquisition module is used for acquiring a first transaction processing program corresponding to a first transaction;
the annotation module is used for annotating the transaction starting function of the first transaction processing program to obtain the first program;
the second obtaining module is used for obtaining a first function which causes the operation failure of the first program if the operation of the first program fails;
the first judging module is used for judging whether a second transaction processing program corresponding to a second transaction comprises the first function or not; and if so, running the second transaction processing program.
The invention has the beneficial effects that:
at present, when the database is transacted, the transaction processing function needs to be started, but the probability of actually having problems is very low, if the transactions are all started, the performance of the database is reduced, and the data processing efficiency is low; the method comprises the steps of obtaining a first program by annotating a transaction starting function of a first transaction processing program, operating the first program, and if the first program fails to operate, obtaining a first function which causes the first program to fail to operate; when a second transaction is operated, judging whether a second transaction processing program comprises the first function or not, if so, not annotating the second transaction processing program corresponding to the second transaction, and processing by adopting a normal transaction processing method; if not, annotating the opening transaction function of the second transaction processing program, and operating the annotated program; for other transactions which do not include the function causing the operation failure of the first program, the transaction processing function is not started, the program operation time is reduced, and the data processing efficiency is improved; the transaction starting transaction comprising the first function is processed, so that the accuracy of the transaction processing is ensured; therefore, the invention improves the data processing efficiency and ensures the correctness of data processing to a certain extent.
Drawings
FIG. 1 is a flow chart of the main steps of a database transaction optimization method according to an embodiment of the present invention;
FIG. 2 is a block diagram of a database transaction optimization system according to an embodiment of the present invention;
description of reference numerals:
1. a first acquisition module; 2. an annotation module; 3. a second acquisition module; 4. a first judging module.
Detailed Description
In order to explain technical contents, objects and effects of the present invention in detail, the following detailed description is given with reference to the accompanying drawings in conjunction with the embodiments.
The most key concept of the invention is as follows: by acquiring the first function of the first program which fails to operate, if the second transaction processing program comprises the first function, the second transaction processing program is operated, so that the transaction processing efficiency of the database can be improved, and meanwhile, the correctness of data processing is ensured.
Referring to fig. 1, the present invention provides a database transaction optimization method, which includes the following steps:
s1: acquiring a first transaction processing program corresponding to a first transaction;
s2: annotating a start transaction function of the first transaction handler to obtain a first program;
s3: if the first program fails to operate, acquiring a first function causing the first program to fail to operate;
s4: judging whether a second transaction processing program corresponding to a second transaction comprises the first function or not; and if so, running the second transaction processing program.
As can be seen from the above description, the present invention obtains a first program by annotating a transaction-opening function of a first transaction handler, runs the first program, and if the first program fails to run, obtains a first function that causes the first program to fail to run; when a second transaction is operated, judging whether a second transaction processing program comprises the first function or not, if so, not annotating the second transaction processing program corresponding to the second transaction, and processing by adopting a normal transaction processing method; if not, annotating the opening transaction function of the second transaction processing program, and operating the annotated program; for other transactions which do not include the function causing the operation failure of the first program, the transaction processing function is not started, the program operation time is reduced, and the data processing efficiency is improved; the transaction starting transaction comprising the first function is processed, so that the accuracy of the transaction processing is ensured; therefore, the invention improves the data processing efficiency and ensures the correctness of data processing to a certain extent.
Further, the S4 specifically includes:
determining whether the second transaction handler includes the first function;
if yes, judging whether a variable value of the first function in the second transaction processing program is different from a variable value of a variable corresponding to the first function in the first transaction processing program;
if yes, annotating the opening transaction function of the second transaction processing program to obtain a second program; running the second program;
otherwise, the second transaction processing program is operated.
As can be seen from the above description, if a variable value of a first function in a second transaction program is different from a variable value of a corresponding variable of the first function in the first transaction program, which indicates that the first function in the second transaction program is different from a first function processing object in the first transaction program, in order to improve efficiency, the second program is obtained by annotating a start transaction function of the second transaction program; running the second program; otherwise, running the second transaction processing program; according to the method, when the variable value of the second variable value set is different from the variable value of the variable corresponding to the first variable value set, the processing efficiency of the data is further improved by a method of not starting transaction processing.
Further, the method for optimizing database transactions further includes:
presetting a third transaction of the database;
if the second program fails to run, judging whether the third transaction comprises the first function;
if yes, a third transaction processing program corresponding to the third transaction is operated;
if the second program runs successfully, annotating the starting transaction function of the third transaction processing program to obtain a third program; and running the third program.
From the above description, if the second program fails to operate, it represents that the transaction including the first function fails to operate for multiple times, and in order to ensure the correctness of the transaction processing, the subsequent transaction processing including the first function adopts a normal transaction processing method, and no matter whether the parameters of the transaction processing program including the first function change, the accuracy of the transaction processing is improved.
Further, the S4 specifically includes:
if the second transaction processing program comprises the first function, operating the second transaction processing program in a physical memory;
otherwise, annotating the opening transaction function of the second transaction processing program to obtain a third program;
and running the third program in a preset virtual memory.
From the above description, it can be known that when too many transactions are processed simultaneously, an excessively large physical memory is occupied, and by using the method of processing the third program by using the virtual memory, the processing performance of the computer is improved, so that the transaction processing efficiency is improved.
Further, the method for optimizing database transactions further includes:
acquiring initial data of the first transaction;
and if the first program fails to run, replacing the data of the first transaction as the initial data.
It can be known from the above description that, since the transaction processing function is not started when the first program is run, rollback cannot occur when the first program fails to run.
Referring to fig. 2, a database transaction optimization system is provided, which includes:
a first obtaining module 1, configured to obtain a first transaction handler corresponding to a first transaction;
the annotation module 2 is used for annotating the transaction starting function of the first transaction processing program to obtain the first program;
a second obtaining module 3, configured to, if the first program fails to operate, obtain a first function that causes the first program to fail to operate;
a first judging module 4, configured to judge whether a second transaction handler corresponding to a second transaction includes the first function; and if so, running the second transaction processing program.
As can be seen from the above description, the present invention obtains a first program by annotating a transaction-opening function of a first transaction handler, runs the first program, and if the first program fails to run, obtains a first function that causes the first program to fail to run; when a second transaction is operated, judging whether a second transaction processing program comprises the first function or not, if so, not annotating the second transaction processing program corresponding to the second transaction, and processing by adopting a normal transaction processing method; if not, annotating the opening transaction function of the second transaction processing program, and operating the annotated program; for other transactions which do not include the function causing the operation failure of the first program, the transaction processing function is not started, the program operation time is reduced, and the data processing efficiency is improved; the transaction starting transaction comprising the first function is processed, so that the accuracy of the transaction processing is ensured; therefore, the invention improves the data processing efficiency and ensures the correctness of data processing to a certain extent.
Referring to fig. 1, a first embodiment of the present invention is:
acquiring a first transaction processing program corresponding to a first transaction;
annotating a start transaction function of the first transaction handler to obtain a first program;
if the first program fails to operate, acquiring a first function causing the first program to fail to operate;
judging whether a second transaction processing program corresponding to a second transaction comprises the first function or not;
if yes, obtaining a variable value of a first function in the first transaction processing program to obtain a first variable value set;
obtaining a variable value of a first function in the second transaction processing program to obtain a second variable value set;
if a variable value in the second variable value set is different from a variable value of a corresponding variable in the first variable value set, annotating a start transaction function of the second transaction processing program to obtain a second program; running the second program; otherwise, the second transaction processing program is operated.
From the above description, when the variable value of the second variable value set is different from the variable value of the variable corresponding to the first variable value set, the processing efficiency of the data is further improved by the method of not starting the transaction processing.
The second embodiment of the invention is as follows:
the second embodiment is different from the first embodiment in that a database transaction optimization method further includes:
presetting a third transaction of the database;
if the second program fails to run, judging whether the third transaction comprises the first function; if yes, a third transaction processing program corresponding to the third transaction is operated;
if the second program runs successfully, annotating the starting transaction function of the third transaction processing program to obtain a third program; and running the third program.
From the above description, if the second program fails to operate, it represents that the transaction including the first function fails to operate for multiple times, and in order to ensure the correctness of the transaction processing, the subsequent transaction processing including the first function adopts a normal transaction processing method, and no matter whether the parameters of the transaction processing program including the first function change, the accuracy of the transaction processing is improved.
The third embodiment of the invention is as follows:
acquiring a first transaction processing program corresponding to a first transaction;
acquiring initial data of the first transaction;
annotating a start transaction function of the first transaction handler to obtain a first program;
if the first program fails to operate, acquiring a first function causing the first program to fail to operate; replacing the data of the first transaction with the initial data;
if the second transaction processing program comprises the first function, operating the second transaction processing program in a physical memory;
otherwise, annotating the opening transaction function of the second transaction processing program to obtain a third program; and running the third program in a preset virtual memory.
From the above description, when too many transactions are processed simultaneously, an excessively large physical memory is occupied, and the processing performance of the computer is improved by the method of processing the third program by the virtual memory, so that the transaction processing efficiency is improved; by the method, when the first program fails to operate, the data of the first transaction can be restored to the initial state, so that data errors can not be caused when the transaction does not adopt the transaction processing function.
Referring to fig. 2, a fourth embodiment of the present invention is:
the system comprises a first acquisition module, a comment module and a second acquisition module, wherein the first acquisition module is used for acquiring a first transaction processing program corresponding to a first transaction and sending the first transaction processing program to the comment module; the annotation module is used for annotating the transaction starting function of the first transaction processing program to obtain a first program and sending the first program to the second acquisition module; the second obtaining module is used for obtaining a first function causing the operation failure of the first program if the operation of the first program fails, and sending the first function to the first judging unit; the first judging unit is used for judging whether the second transaction processing program comprises the first function or not and sending a judgment result to the second judging unit; the second judging unit is used for judging whether a variable value of the first function in the second transaction processing program is different from a variable value of a corresponding variable of the first function in the first transaction processing program if the first function in the second transaction processing program is included in the first transaction processing program, and sending a judgment result to the first operation unit; the first operation unit is used for annotating the starting transaction function of the second transaction processing program to obtain the second program if the starting transaction function exists; running the second program; otherwise, running the second transaction processing program;
the presetting module is used for presetting a third transaction of the database; the second judging module is used for judging whether the third transaction comprises the first function or not if the second program fails to operate and sending a judgment result to the first operating module; the first operation module is used for operating a third transaction processing program corresponding to the third transaction if the third transaction processing program is included in the first operation module; the second operation module is used for annotating the transaction starting function of the third transaction processing program to obtain a third program if the second program is successfully operated; and running the third program.
The fifth embodiment of the invention is as follows:
acquiring initial data of a first transaction corresponding to a purchased schoolbag from a database, acquiring a first transaction processing program corresponding to the first transaction, and annotating a starting transaction function of the first transaction processing program to obtain a first program; running a first program, if the first program fails to run, acquiring a first function causing the program to fail, and assuming that the buy function causes the first program to fail; simultaneously restoring the data of the first transaction into initial data; when a second transaction corresponding to the mobile phone is purchased in the operation database, detecting that a second transaction processing program corresponding to the second transaction comprises a buy function; judging whether a variable value of the buy function in the second transaction processing program is different from the variable value of the variable corresponding to the buy function in the first transaction processing program, and processing the second transaction by adopting a method of not starting the transaction because the second transaction processing is the transaction of purchasing the mobile phone; if the second transaction fails, the subsequent transactions including the buy function are processed by adopting a normal transaction processing method no matter what commodity is purchased.
In summary, the present invention obtains a first program by annotating a transaction-opening function of a first transaction handler, runs the first program, and if the first program fails to run, obtains a first function that causes the first program to fail to run; when a second transaction is operated, judging whether a second transaction processing program comprises the first function or not, if so, not annotating the second transaction processing program corresponding to the second transaction, and processing by adopting a normal transaction processing method; if not, annotating the opening transaction function of the second transaction processing program, and operating the annotated program; for other transactions which do not include the function causing the operation failure of the first program, the transaction processing function is not started, the program operation time is reduced, and the data processing efficiency is improved; the transaction starting transaction comprising the first function is processed, so that the accuracy of the transaction processing is ensured; therefore, the invention improves the data processing efficiency and ensures the correctness of data processing to a certain extent.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to other related technical fields, are included in the scope of the present invention.
Claims (8)
1. A method for database transaction optimization, comprising the steps of:
s1: acquiring a first transaction processing program corresponding to a first transaction;
s2: annotating a start transaction function of the first transaction handler to obtain a first program;
s3: if the first program fails to operate, acquiring a first function causing the first program to fail to operate;
s4: determining whether a second transaction handler includes the first function; the second transaction handler is a program corresponding to a second transaction;
if yes, judging whether a variable value of the first function in the second transaction processing program is different from a variable value of a variable corresponding to the first function in the first transaction processing program;
if yes, annotating the opening transaction function of the second transaction processing program to obtain a second program; running the second program;
and if not, running the second transaction processing program.
2. The database transaction optimization method according to claim 1, further comprising:
presetting a third transaction of the database;
if the second program fails to run, judging whether the third transaction comprises the first function;
if yes, a third transaction processing program corresponding to the third transaction is operated;
if the second program runs successfully, annotating the starting transaction function of the third transaction processing program to obtain a third program; and running the third program.
3. The method for optimizing database transactions according to claim 1, wherein said operating the second transaction handler in S4 specifically includes:
running the second transaction processing program in the physical memory;
the S4 further includes:
if the second transaction processing program does not comprise the first function, annotating the opening transaction function of the second transaction processing program to obtain a second program;
and running the second program in a preset virtual memory.
4. The database transaction optimization method according to claim 1, further comprising:
acquiring initial data of the first transaction;
and if the first program fails to run, replacing the data of the first transaction as the initial data.
5. A database transaction optimization system, comprising:
the system comprises a first acquisition module, a second acquisition module and a processing module, wherein the first acquisition module is used for acquiring a first transaction processing program corresponding to a first transaction;
the annotation module is used for annotating the transaction starting function of the first transaction processing program to obtain the first program;
the second obtaining module is used for obtaining a first function which causes the operation failure of the first program if the operation of the first program fails;
a first determining module, the determining module comprising:
a first judging unit, configured to judge whether a second transaction processing program includes the first function; the second transaction handler is a program corresponding to a second transaction;
a second determining unit, configured to determine whether a variable value of the first function in the second transaction program is different from a variable value of a variable corresponding to the first function in the first transaction program if the variable value of the first function in the second transaction program is included in the first transaction program;
the first operation unit is used for annotating the starting transaction function of the second transaction processing program to obtain the second program if the starting transaction function exists; running the second program; and if not, running the second transaction processing program.
6. The database transaction optimization system of claim 5, further comprising:
the presetting module is used for presetting a third transaction of the database;
a second determining module, configured to determine whether the third transaction includes the first function if the second program fails to operate;
the first operation module is used for operating a third transaction processing program corresponding to the third transaction if the third transaction processing program is included in the first operation module;
the second operation module is used for annotating the transaction starting function of the third transaction processing program to obtain a third program if the second program is successfully operated; and running the third program.
7. The database transaction optimization system of claim 5, wherein the first determining module further comprises:
a second operation unit, configured to operate the second transaction processing program in a physical memory;
the annotation unit is used for annotating the starting transaction function of the second transaction processing program to obtain a second program if the first function is not included in the second transaction;
and the third running unit is used for running the second program in a preset virtual memory.
8. The database transaction optimization system of claim 5, further comprising:
the third acquisition module is used for acquiring initial data of the first transaction;
and the replacing module is used for replacing the data of the first transaction as the initial data if the first program fails to operate.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710043446.6A CN106844634B (en) | 2017-01-19 | 2017-01-19 | Database transaction optimization method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710043446.6A CN106844634B (en) | 2017-01-19 | 2017-01-19 | Database transaction optimization method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106844634A CN106844634A (en) | 2017-06-13 |
CN106844634B true CN106844634B (en) | 2020-05-08 |
Family
ID=59119987
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710043446.6A Active CN106844634B (en) | 2017-01-19 | 2017-01-19 | Database transaction optimization method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106844634B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109558303B (en) * | 2017-09-25 | 2023-02-28 | 阿里巴巴集团控股有限公司 | Application behavior analysis method and device and electronic equipment |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103455368B (en) * | 2013-08-27 | 2016-12-28 | 华为技术有限公司 | A kind of deadlock detection method, node and system |
CN104462077A (en) * | 2013-09-12 | 2015-03-25 | 方正信息产业控股有限公司 | Method and device for processing database transaction |
US10445433B2 (en) * | 2014-04-28 | 2019-10-15 | Venkatachary Srinivasan | Methods and systems of query engines and secondary indexes implemented in a distributed database |
-
2017
- 2017-01-19 CN CN201710043446.6A patent/CN106844634B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN106844634A (en) | 2017-06-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8020041B2 (en) | Method and computer system for making a computer have high availability | |
US8924785B2 (en) | Power shutdown prediction for non-volatile storage devices | |
US10866866B2 (en) | Query fault processing method and processing apparatus | |
US20140380101A1 (en) | Apparatus and method for detecting concurrency error of parallel program for multicore | |
CN107798030B (en) | Splitting method and device of data table | |
EP2797013A1 (en) | Database update execution according to power management schemes | |
US10592235B2 (en) | Generating an idempotent workflow | |
US9720819B2 (en) | Concurrent, moving, garbage collector | |
CN107643904B (en) | Method, device and medium for detecting code submission log and electronic equipment | |
US20120059997A1 (en) | Apparatus and method for detecting data race | |
CN106844634B (en) | Database transaction optimization method and system | |
AU2015265599B2 (en) | System and method for the production of job level pre-processed backup of critical data and/or datasets in a mainframe computing environment | |
EP3869377A1 (en) | Method and apparatus for data processing based on smart contract, device and storage medium | |
CN104133763A (en) | Program debugging system and program debugging method | |
CN109324765A (en) | A kind of Disk State detection method, device, equipment and storage medium | |
CN105760283B (en) | A kind of log-output method and device | |
US20180246788A1 (en) | Method and apparatus for recovering in-memory data processing system | |
CN111026574A (en) | Method and device for diagnosing Elasticissearch cluster problems | |
US9898301B2 (en) | Framework to provide time bound execution of co-processor commands | |
US11036551B2 (en) | Durable program execution | |
US10592329B2 (en) | Method and electronic device for continuing executing procedure being aborted from physical address where error occurs | |
CN112749156A (en) | Data processing method, database management system and data processing equipment | |
CN104391763B (en) | Many-core processor fault-tolerance approach based on device view redundancy | |
CN116361084A (en) | Multi-core processor debugging method and device, debugging equipment and readable storage medium | |
US7853827B2 (en) | Isotropic processor |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |