MySQL

Sort an index Mysql

For sorting an index and data according to an index, use

myisamchk --sort-index --sort-records=1
(assuming that you want to sort on index 1).

This is the best way to make queries faster if you have a unique index from which you want to read all rows in order according to the index.

However, the first time you sort a large table this way, it may take a long time.

Concurrent Inserts For MyISAM

MyISAM storage engine supports concurrent inserts. If there are multiple INSERT statements, they are queued and performed in sequence, concurrently with the SELECT statements.

The concurrent_insert system variable can be set to modify the concurrent-insert processing. This variable is set to 1 by default. To disable concurrent insert just set concurrent_insert variable to 0. If the variable is set to 2, concurrent inserts at the end of the table are allowed even for tables that have deleted rows. See also the description of the concurrent_insert system variable.

Refresh Index Statistics MySQL

If frequent changes happens on a table, it may develop some inefficiencies in its indexes. Fragmentation due to blocks moving around on disk and inaccurate index statistics are the two most common problems you're likely to see. However, one cay easily optimize index data for MyISAM tables.

For reindexing a table we can use OPTIMIZE TABLE command. In doing so, MySQL try reading the records again in the table and reconstruct all of its indexes. This will result in indexes with good statistics.

However, reindexing the table takes lot of time if the table size is huge. During that time, MySQL also has a write lock on the table, so data can't be updated.

For offline analysis you can try myisamchk command-line tool:

$ cd your-database-name

$ myisamchk table-name

You need to make sure that MySQL isn't running when you try this, or you run the risk of corrupting your indexes.

EXPLAIN statement MySQL

EXPLAIN statement can be used in two ways.

First, you can use EXPLAIN table;

This gives very similar output to DESCRIBE table or SHOW COLUMNS FROM table.

Characteristics of Cursor MYSQL

Here is a brief characteristics of cursor in MYSQL
READ ONLY
NOT SCROLLABLE
ASENSITIVE

Cumulus Tag Cloud

Kiran Says

I love work environment which is:

Informal yet professional
Demanding yet rewarding
Challenging yet inspiring
Mediocrity is not an option
Having fun is serious business
Making mistakes is human
Forgiveness is Company Policy

Travelling Sucks