| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Unsorted tips for faster systems:
thread_cache_size variable. See section 7.5.2 Tuning Server Parameters.
EXPLAIN
command. See section Explain.
SELECT queries on MyISAM tables that are
updated a lot. This is to avoid problems with table locking.
MyISAM tables that have no deleted rows, you can insert rows
at the same time another query is reading from it. If this is important
for you, you should consider methods where you don't have to delete rows
or run OPTIMIZE TABLE after you have deleted a lot of rows.
ALTER TABLE ... ORDER BY expr1,expr2... if you mostly
retrieve rows in expr1,expr2... order. By using this option after big
changes to the table, you may be able to get higher performance.
SELECT * FROM table_name WHERE hash=MD5(CONCAT(col1,col2))
AND col_1='constant' AND col_2='constant'
VARCHAR
or BLOB columns. You will get dynamic row length as soon as you
are using a single VARCHAR or BLOB column. See section 14. MySQL Table Types.
UPDATE table SET count=count+1 WHERE index_column=constant
is very fast!
This is really important when you use MySQL table types like MyISAM and ISAM that only have table locking (multiple readers / single writers). This will also give better performance with most databases, as the row locking manager in this case will have less to do.
INSERT /*! DELAYED */ when you do not need to know when your
data is written. This speeds things up because many records can be written
with a single disk write.
INSERT /*! LOW_PRIORITY */ when you want your selects to be
more important.
SELECT /*! HIGH_PRIORITY */ to get selects that jump the
queue. That is, the select is done even if there is somebody waiting to
do a write.
INSERT statement to store many rows with one
SQL command (many SQL servers supports this).
LOAD DATA INFILE to load bigger amounts of data. This is
faster than normal inserts and will be even faster when myisamchk
is integrated in mysqld.
AUTO_INCREMENT columns to make unique values.
OPTIMIZE TABLE once in a while to avoid fragmentation when
using a dynamic table format. See section OPTIMIZE TABLE.
HEAP tables to get more speed when possible. See section 14. MySQL Table Types.
Try to keep the names simple (use name instead of
customer_name in the customer table). To make your names portable
to other SQL servers you should keep them shorter than 18 characters.
MyISAM directly, you could
get a speed increase of 2-5 times compared to using the SQL interface.
To be able to do this the data must be on the same server as
the application, and usually it should only be accessed by one process
(because external file locking is really slow). One could eliminate the
above problems by introducing low-level MyISAM commands in the
MySQL server (this could be one easy way to get more
performance if needed). By carefully designing the database interface,
it should be quite easy to support this types of optimization.
DELAY_KEY_WRITE=1 will make the updating of
indexes faster, as these are not logged to disk until the file is closed.
The downside is that you should run myisamchk on these tables before
you start mysqld to ensure that they are okay if something killed
mysqld in the middle. As the key information can always be generated
from the data, you should not lose anything by using DELAY_KEY_WRITE.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |