Tuesday, June 28, 2011

Turn on or off color syntax highlighting in vi or vim editor

Vim or vi is a text editor. It can be used to edit all kinds of plain text. It is especially useful for editing programs or UNIX/Linux configuration files.

Turn on syntax highlighting:

Open file (for example test.sh):
$ vi test.sh
Now press ESC key to enter into command mode then type  ” : syntax on OR syn on”
:syntax on
:syn on
That’s it.. the color syntax highlighting will be enabled until you close that file (useful when you working on server where you can’t enable it permanently because of restriction and not having desired access of .vimrc file.)

Turn off syntax highlighting:

Press ESC key to enter into command mode then type “: syntax off OR syn off”
:syntax off
: syn off

Enable color syntax highlighting permanently:

You may need to add "syntax on" (or "syn on") in your $HOME/.vimrc file
$ vi HOME/.vimrc
Add "syntax on" (or "syn on")
Press ESC to enter into command mode then
Save and close the file.
:wq <enter>

Please note: .vimrc is a system file so it will be hidden and you can see it by using command “ls”

Any comment would be appreciated thanks J

Friday, June 24, 2011

mysql optimizer Index strategy

If the table has a multiple-column index, any leftmost prefix of the index can be used by the optimizer to find rows. For example, if you have a three-column index on (col1, col2, col3), you have indexed search capabilities on (col1), (col1, col2), and (col1, col2, col3).
MySQL cannot use an index if the columns do not form a leftmost prefix of the index. Suppose that you have the SELECT statements shown here:
SELECT * FROM tbl_name WHERE col1=val1;
SELECT * FROM tbl_name WHERE col1=val1 AND col2=val2;

SELECT * FROM tbl_name WHERE col2=val2;
SELECT * FROM tbl_name WHERE col2=val2 AND col3=val3;
If an index exists on (col1, col2, col3), only the first two queries use the index. The third and fourth queries do involve indexed columns, but (col2) and (col2, col3) are not leftmost prefixes of (col1, col2, col3).

For detail please visit
© Copyright 2010-2012 Learn MySQL All Rights Reserved.
Template powered by Blogger.com.