Florin Chiş

MySQL snippets, tips and tricks

  • Home
  • MySQL Tips
  • Quiz time ?
  • MySQL Tools
  • About me
RSS

MySQL Tips

Posted on 30/12/2011 by admin
No commentsLeave a comment

Some useful MySQL tips

Tip 1: Optimize table primary key

It is recommended to use at least one unique index for every table. I am doing this by creating an autoincrement integer column (named usually “id”). If your table won’t exceed 16M rows, you may consider using MEDIUMINT, but if you have a smaller table that does not exceed 65k rows, consider SMALLINT type for index column.Only if that table grows very much, you should use INT, or BIGINT types. There are very few situations when BIGINT should be used, because INT normally covers 4G rows.  These considerations keep performance on queries running on these table.

Tip 2: Signed or unsigned for integers ?

For integer type columns that contain positive numbers, always use UNSIGNED property for that type. For instance TINYINT [SIGNED] may use only 128 positive values, while TINYINT [UNSIGNED] doubles that range to 256. This principle is applicable to other integer types as well.

Tip 3: Run SQL file from command prompt in Windows

If you have to run a very large SQL query file, the most quick is to do it from command prompt, not from MySQL IDEs. Command to run a SQL file is: mysql -u user -p < full_path_to_sql_file, then insert the mysql user password.

 

Lasă un răspuns Anulează răspuns

Adresa ta de email nu va fi publicată. Câmpurile necesare sunt marcate *

*

*


question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

Poți folosi aceste etichete HTML și atribute: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Search

  • Recent posts

    • Convert UTF8 diacritics to ASCII in MySQL for use in website links
    • Generate table with random text from dictionary
    • Test
    • Repair (or optimize) all tables from a database
    • Padding a string with a char to complete fixed length width
  • What about you ?

    Do you create stored routines in MySQL ?

    View Results

    Loading ... Loading ...
    • Polls Archive
  • Categories

    • General
    • MySQL small projects
    • Mysql stored routines
  • Newsletter

    Want to receive articles in your mailbox ?

  • Meteo

    meteoblue.com
  • Legături

    • Cosmin Roman blog
    • Romania Maps
  • Tags

    article automatic char conversion database dictionary fixed generate latin length link mysql padding procedure random repair script tables text translation utf8 word

    WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

  • Archive

    • decembrie 2011
  • New comments

    • Parteneri

      Bloguri, Bloggeri si Cititori
      Blogarama - The Blog Directory
    Mysql tips, tricks and tests. Proudly Powered by WordPress | Nest Theme by YChong