Search This Blog

2023/04/17

MySQL - MyISAM vs InnoDb



MyISAM:
1) It is default storage Engine of mysql prior to 5.5
2) MyISAM does not support
3) MyISAM uses table-level locking, which can cause contention
and slow down write performance.
4) MyISAM does not support foreign key constraints
5) MyISAM does not support crash recovery, which can result in data loss.
6) MyISAM stores its tables, data and indexes in diskspace
using separate three different files.
(tablename.FRM, tablename.MYD, tablename.MYI)
7) In general, read operations are faster in MyISAM than in InnoDB.
MyISAM uses a simple table-locking mechanism, which means that it can
read data from the table
quickly without having to worry about row-level locking or transactional
consistency.In addition, MyISAM has a smaller overhead for indexes,
making it more efficient
for read-intensive operations.
8) It should be used when update & Delete are less while read operation
is more on the table

InnoDB
1)It is default storage Engine of mysql since 5.5
2) InnoDB supports transactions
3) InnoDB uses row-level locking, which allows multiple users to modify
different rows simultaneously.
4) InnoDB support foreign key constraints,Foreign key constraints ensure
that data in related tables remains consistent.
5) InnoDB supports crash recovery, which ensures that data is not lost in
the event of a system crash
6)InnoDB stores its tables and indexes in a tablespace
7)InnoDB has more overhead for read operations. InnoDB uses a row-level
locking echanism,
which ensures that multiple users can read and write to the same table
simultaneously without conflicting with each other. However, this also
means that there is more overhead involved in managing the transactions,
which can slow down read operations.
8)It should be used when table has frequent update & delete operation


The performance difference between InnoDB and MyISAM for read operations
may not be significant for smaller databases or applications with low
read volumes. In addition, InnoDB has other advantages
over MyISAM, such as better support for transactions, row-level locking,
and foreign key constraints.Transactions are essential for maintaining
data consistency in applications that involve multiple updates.It is
also generally considered to be a more reliable and robust storage engine.


How to convert a single MyISAM table to InnoDB

ALTER TABLE database_name.table_name ENGINE=InnoDB;

How to convert InnoDB to MyISAM
ALTER TABLE database_name.table_name ENGINE=MyISAM;


No comments:

Post a Comment