Sort an index Mysql
For sorting an index and data according to an index, use
(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.
- Kiran's blog
- Add new comment
- 692 reads
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.
- Kiran's blog
- Add new comment
- 808 reads
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.
- Kiran's blog
- 2 comments
- Read more
- 2144 reads
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.
- Kiran's blog
- Add new comment
- Read more
- 588 reads
Characteristics of Cursor MYSQL
Here is a brief characteristics of cursor in MYSQL
READ ONLY
NOT SCROLLABLE
ASENSITIVE
- Kiran's blog
- Add new comment
- Read more
- 643 reads
How To Retrieve Error Information
There are two functions that are useful for retrieving MySQL errors.
mysql_error()
string mysql_error ([resource link_id])
The above function returns the error message generated by the last MySQL function, or returns an
empty string if no error occurred. On using the optional link_id parameter, the most recently
occurring error generated from that identifier will be used; else, the most recently opened
server link is assumed.
- Kiran's blog
- Add new comment
- Read more
- 345 reads
SELECT INTO OUTFILE - MySQL
The SELECT INTO OUTFILE SQL statement is a type of the SELECT query. Generally used when you need to direct query output to some text file.
The syntax format:
SELECT [Your select options] INTO {OUTFILE | DUMPFILE} filename EXPORT_OPTIONS
FROM table_references [Your additional select options]
Using OUTFILE option causes the query result to be output to the text file. The formatting of the query result is dependent upon how the EXPORT OPTIONS. The EXPORT OPTIONS actually determine how the table fields and lines will be
delimited in the outfile.
- Kiran's blog
- 1 comment
- Read more
- 2333 reads













