My Sql Page2 some optimization work

Q : how to optimize select statement  ?
Ans  :
first check with permission set up when you issue with grant statement enables MySQL to reduce
permission checking overhead when clients execute statement.
example  : table or column level privileges , server need to check table_priv and columns_priv tables.
if your problem with some specific MySQL expression or function , use BENCHMARK() function from mysql client  to perform timing test   .
Syntax  : select benchmark(100000,1=1) ;
result executed in some second .
so bench mark is a great tool to find out any problem with query .

Q : Difference between describe and explain  in MySQL
ans : Describe keyword is used for table structure while explain is used to obtain query execution                plan .explain works on select ,delete ,insert ,update or replace.


Q : how to analyze table ?
Ans :  analyze table table_name ;

Q : How to Optimize Table .
Ans : optimize table command is equal to mysqlcheck -with --optimize option  . Syntax for Optimize table is  Optimize table tablename1 ,tablename2 

Q; what is difference between mysqlcheck and myisam ;
Ans :
1:both command can check repair , and anlyze myisam tables , but mysqlcheck can optimize MyIsam table,Innodb and BDB tables  .

 2: Mysqlcheck can execute on as client program while myisam is  not ,this can only perform on the file that represent  myisam tables  .

3:  For using MyIsam you have to stop mysql server to working command properly ,other wise it may give error can not open file due to file may be used by some other 

4: Mysqlcheck command
   a:  for check all database :
            "mysqlcheck -u username  -p --autorepair --check --optimize --All-databases;"
  b:  for checking multiple database
 " mysqlcheck -u username  -p --autorepair --check --optimize --databases 1stdatbase 2ndatabase;"
  c: for single database you can use command : 
 mysqlcheck -u username  -p --autorepair --check --optimize database;
  d:  for table 
  mysqlcheck -u username  -p --autorepair --check --optimize database tablename ;
  e : for multiple table
  mysqlcheck -u username  -p --autorepair --check --optimize database tablename1 tablename2 
5:   first check out for all corrupted table using myisamchk 
 "myisamchk your path/*MYI"
       above command will provide you myisamchk result about corrupted table .. then repair table using command
    " myisamchk -r xyz.myi "

performing check and repair together for entire MySql 
   "myisamchk --silent --force --fast  --update-stat  yourpat/*.myi"
  --silent : prints only error .
  -- force  : restart myisamchk automatically  with repair option  -r , if there is any error in table 
  -- fast   : check only table that is not closde properly 
  -- update-state  : marked tables as crash ,when it finds any error .



Comments

Popular posts from this blog

Install Mysql from ZIP without MySQL Installer or Exe

Logging in Python .

Dictionary in Python