Oracle 5.0 Reference Manual page 710

Table of Contents

Advertisement

This is very important when you use MySQL storage engines such as
level locking (multiple readers with single writers). This also gives better performance with most
database systems, because the row locking manager in this case has less to do.
• If you need to collect statistics from large log tables, use summary tables instead of scanning the
entire log table. Maintaining the summaries should be much faster than trying to calculate statistics
"live." Regenerating new summary tables from the logs when things change (depending on business
decisions) is faster than changing the running application.
• If possible, you should classify reports as "live" or as "statistical," where data needed for statistical
reports is created only from summary tables that are generated periodically from the live data.
• Take advantage of the fact that columns have default values. Insert values explicitly only when the
value to be inserted differs from the default. This reduces the parsing that MySQL must do and
improves the insert speed.
• In some cases, it is convenient to pack and store data into a
provide code in your application to pack and unpack information, but this may save a lot of accesses
at some stage. This is practical when you have data that does not conform well to a rows-and-
columns table structure.
• Normally, you should try to keep all data nonredundant (observing what is referred to in database
theory as third normal form). However, there may be situations in which it can be advantageous to
duplicate information or create summary tables to gain more speed.
• Stored routines or UDFs (user-defined functions) may be a good way to gain performance for some
tasks. See
Section 18.2, "Using Stored Routines (Procedures and
"Adding New Functions to
• You can increase performance by caching queries or answers in your application and then executing
many inserts or updates together. If your database system supports table locks, this should help to
ensure that the index cache is only flushed once after all updates. You can also take advantage of
MySQL's query cache to achieve similar results; see
• Use
INSERT DELAYED
overall insertion impact because many rows can be written with a single disk write.
• Use
INSERT LOW_PRIORITY
inserts.
Use
SELECT HIGH_PRIORITY
executed even if there is another client waiting to do a write.
and
LOW_PRIORITY
level locking (such as MyISAM, MEMORY, and MERGE).
• Use multiple-row
INSERT
servers support this, including MySQL.
• Use
LOAD DATA INFILE
statements.
• Use
AUTO_INCREMENT
value. unique values.
• Use
OPTIMIZE TABLE
See
Section 14.1.3,
• Use
(HEAP) tables when possible to get more speed. See
MEMORY
(HEAP) Storage
Engine".
Other Optimization Tips
MySQL", for more information.
when you do not need to know when your data is written. This reduces the
when you want to give
to get retrievals that jump the queue. That is, the
have an effect only for storage engines that use only table-
HIGH_PRIORITY
statements to store many rows with one SQL statement. Many SQL
to load large amounts of data. This is faster than using
columns so that each row in a table can be identified by a single unique
once in a while to avoid fragmentation with dynamic-format
"MyISAM
Table Storage
tables are useful for noncritical data that is accessed often, such
MEMORY
690
column. In this case, you must
BLOB
Functions)", and
Section 8.6.3, "The MySQL Query
statements higher priority than your
SELECT
Formats".
Section 14.4, "The
that has only table-
MyISAM
Section 21.2,
Cache".
is
SELECT
INSERT
MyISAM
MEMORY
tables.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents