Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Monday, 1 September 2014

how to filter the table status output from mysql

show table status is a handy command to get the table status, but you can't filter the fields you want as normal select statement. Here is the alternative way to get the output
SELECT table_name,Engine,Version,Row_format,table_rows,Avg_row_length,
  Data_length,Max_data_length,Index_length,Data_free,Auto_increment,
  Create_time,Update_time,Check_time,table_collation,Checksum,
  Create_options,table_comment
FROM information_schema.tables
WHERE Table_Schema='MyTableName';
you can replace 'MyTableName' with the table you want.

Wednesday, 20 August 2014

some tips about MySQL query Optimization

1. use the index: for every SQL, use the explain statement to verify the execution plan.
2. dont use index for computing substatement
3. fine the search critieria as much as possible
4. create hash index on fields for min/max/count
5. do manual calculation on some nequalities