Dapper EF and other ORM MySQL does not support transactional solutions

Source: Internet
Author: User

MySQL table type MyISAM and InnoDB differences

MyISAM: This is the default type, which is based on the traditional ISAM type, ISAM is an abbreviation for indexed sequential access method (indexed sequential access methods), which is the standard way to store records and files. Compared to other storage engines, MyISAM has most of the tools for checking and repairing tables. MyISAM tables can be compressed, and they support full-text search. They are not transaction-safe and do not support foreign keys. If the rollback of a thing causes incomplete rollback, it does not have atomicity. If executing a lot of select,myisam is a better choice.


InnoDB: This type is transaction-safe. It has the same characteristics as the BDB type, and they also support foreign keys. InnoDB tables are fast. Has a richer feature than BDB, so it is recommended if a transaction-safe storage engine is required. If your data performs a large number of inserts or update, for performance reasons, you should use the InnoDB table.

For INNODB types that support things, the main reason for the speed is that the AUTOCOMMIT default setting is open, and the program does not explicitly call begin to start a transaction, resulting in an automatic commit for each insert, which seriously affects the speed. You can call begin before you execute SQL, and multiple SQL forms a thing (even if the autocommit is open), which will greatly improve performance.
1. More than 4.0 mysqld support transactions, including non-max versions. 3.23 requires Max version mysqld to support transactions.

2. If you do not specify a type when creating a table, the default is MyISAM, and transactions are not supported.
You can use the Show CREATE TABLE tablename command to see the type of the table.

2.1 Doing a start/commit operation on a table that does not support transactions has no effect and has been committed before committing a commit, testing:
Perform a msyql:
Use test;
drop table if exists TN;
Create TABLE TN (a varchar (ten)) Type=myisam;
drop table if exists Ty;
Create table Ty (a varchar (ten)) Type=innodb;

Begin
Insert into TN values (' a ');
Insert into Ty values (' a ');
SELECT * from TN;
select * from Ty;
Can see a record.

To perform another MySQL:
Use test;
SELECT * from TN;
select * from Ty;
Only TN can see a record
And then on the other side
Commit
Can only see the record.

3. You can execute the following command to toggle non-transactional tables to transactions (data is not lost), and the InnoDB table is more secure than the MyISAM table:
ALTER TABLE TableName TYPE=INNODB;

3.1 InnoDB table cannot use Repair Table command and MYISAMCHK-R table_name
But you can use check table, and Mysqlcheck [OPTIONS] database [tables]

4. The following parameters have been added to the command line starting the MySQL database to make the newly published MySQL data table default to use transactions (
Only the CREATE statement is affected. )
–default-table-type=innodb

Test command:
Use test;
drop table if exists TN;
Create TABLE TN (a varchar (10));
Show CREATE TABLE TN;

5. Temporarily changing the default table type can be used:
Set Table_type=innodb;
Show variables like ' table_type ';
Or:
C:mysqlbinmysqld-max-nt–standalone–default-table-type=innodb

For MySQL, the most representative table storage engine is InnoDB and MyISAM. The main difference between the two is whether to perform a foreign key data integrity check.

The InnoDB storage engine supports check functions for foreign key constraints, including Delete,update,cascade (what is the specific meaning, left to be replenished later).

The benefits or advantages of FOREIGN KEY constraint checking (foreign key enhancement) are:

1 if the association is properly designed, it can make it more difficult for programmers to introduce data inconsistencies into the database

2 The database server has centralized constraint checking, so you can avoid having to check the data on one side of the application, so that different referencing programs use different ways to check constraints.

3 simplifies application code by using cascading updates and deletions

4 Designing a less-relevant association helps you document the relationships between tables by using documents

However, the above benefits require the database server to spend extra overhead to perform such checks, increasing the burden on the database server, which in turn affects the performance of the database.

If you do not need a foreign key in the table, and you want to avoid checking referential integrity, you can choose to use MyISAM storage

Engine. For applications that have only insert and select, choosing MyISAM will get better performance. However, if you have a foreign key association when using the MyISAM engine, you need to handle this kind of association at the application-level level so that the integrity of the data is guaranteed.

DBA (database administrator) to create a topology association, which can make it difficult to recover a single table (when loading tables that depend on other tables, MySQL allows you to temporarily disallow foreign key checks, which reduces the difficulty). For tables that have foreign keys, you need to be aware of this problem.

Dapper EF and other ORM MySQL does not support transactional solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.