ations back it was the only table type available in MySQL. MyISAM tables are
extremely fast and stable; however, they do not support transactions. They only
offer table-level locking of data.
MyISAM tables are optimized for speed in retrieving data with select state-
ments. Because of the optimization and lack of transaction support, MyISAM tables
are best for tables that are going to run select operations far more frequently than
they run update or delete operations.
For example, if you are creating a shopping cart (as we do in Chapter 14) you
likely have a table or two dedicated to the product catalog and other tables dedi-
cated to recording user information and orders. The tables that hold catalog infor-
mation (the items available in your store) probably won’t change all that
frequently—at most a couple of times a day. And if your store is doing well, these
data will be queried frequently, as users browse the items you have available.
MyISAM tables are perfect for tables that serve this purpose. The tables that store
shopping-cart data and record sales information are going to be subject of insert
and update queries far more frequently than they will be subject of select queries.
For these sorts of tables you’re much better off using one of the transactional table
types: InnoDB, Gemini, or BerkeleyDB.
On almost all systems, MyISAM will be the default table type. You’ll be able to
run any valid create statement, and MySQL will create a MyISAM table, even if
you don’t include a type attribute in your create statement. If you want to be extra
careful, however, you can include type=myisam in your statement, like so:
create table mytable(
col1 int,
col2 text
) type=myisam;
0 comments:
Post a Comment