How to do basic MySQL optimization

MySQL – Intro


Pronounced “my ess cue el” (each letter separately).


MySQL is an open-source high-performance, multi-threaded, multi-user relational database management system (RDBMS) built around a client- server architecture.


It was designed specifically for speed and stability and has become one of the most popular RDBMS for database-driven Web application.


Information is stored in “Tables” which can be thought of as the equivalent of Excel spreadsheets. A single MySQL database can contain many tables at once and store thousands of individual records. It’s fast, reliable and flexible.



MySQL Variables


max_connections


MySQL is multi-threaded, so there may be many clients issuing queries to a single table simultaneously.


The number of simultaneous client connections allowed. By default, this is 100.



max_user_connections


The maximum number of simultaneous connections allowed to any given MySQL account. A value of 0 means “no limit”.



key_buffer_size


key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.



myisam_sort_buffer_size


The size of the buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE or when creating indexes with CREATE INDEX or ALTER TABLE.


join_buffer_size


The size of the buffer that is used for joins that do not use indexes and thus perform full table scans. Normally, the best way to get fast joins is to add indexes.


Increase the value of join_buffer_size to get a faster full join when adding indexes is not possible.


One join buffer is allocated for each full join between two tables.



read_buffer_size


Each request that performs a sequential scan of a table allocates a read buffer.



sort_buffer_size


Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster ORDER BY or GROUP BY operations.



table_cache


The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires.



thread_cache_size


How many threads the server should cache for reuse. When a client disconnects, the client’s threads are put in the cache if there are fewer than thread_cache_size threads there.


Requests for threads are satisfied by reusing threads taken from the cache if possible, and only when the cache is empty is a new thread created.


Increasing the value to improve performance if we have a lot of new connections.



wait_timeout


The number of seconds the server waits for activity on a non-interactive connection before closing it.


This timeout applies only to TCP/IP and Unix socket file connections, not to connections made via named pipes, or shared memory.



connect_timeout


The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake.



max_allowed_packet


The maximum size of one packet or any generated/intermediate string.



max_connect_errors


If there are more than this number of interrupted connections from a host, that host is blocked from further connections.


You can unblock blocked hosts with the FLUSH HOSTS statement.



query_cache_limit


Don’t cache results that are larger than this number of bytes. The default value is 1MB.



query_cache_size


The amount of memory allocated for caching query results. The default value is 0, which disables the query cache.


The allowable values are multiples of 1024; other values are rounded down to the nearest multiple.



open_files_limit


The number of files that the operating system allows mysqld to open.



Sample values for optimizing MySQL


[mysqld]



max_connections = 400
key_buffer = 128M (128MB for every 1GB of RAM)

myisam_sort_buffer_size = 64M
join_buffer_size = 2M
read_buffer_size = 2M (1MB for every 1GB of RAM)

sort_buffer_size = 3M (1MB for every 1GB of RAM)
table_cache = 1024
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 1800
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 16M (32MB for every 1GB of RAM)

query_cache_type = 1
tmp_table_size = 16M

thread_concurrency=2 (Number of CPUs x 2)




[mysqld_safe]
open_files_limit = 8192


[mysqldump]
quick
max_allowed_packet = 16M


[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

116 comments:

  • Thanks very much for this good article;this is the kind of thing that keeps me going through the day. I have been looking around for this site after I heard about them from a colleague and was pleased when I was able to find it after searching for awhile. Being a demanding blogger, I'm blessed to see others taking initivative and contributing to the community. I would like to comment to show my appreciation for your article as it's very energizing, and many writers do not get acceptance they deserve. I am sure I'll be back and will spread the word to my friends.

  • ladyboy-tube

    I possibly could undoubtedly make use of a version of those.

  • Hello. Wonderful job. I didn't expect this on the Wednesday. This is a good story. Thank you!

  • Bass Guitar Tabs

    thanks ! incredibly valuable submit!

  • Just killing some in between class time on Stumbleupon and I found your article . Not normally what I like to learn about, but it was absolutely worth my time. Thanks.

  • Lilliam Headlam

    As a Novice, I am typically looking on the net for articles which can guide me. Although do you know how come i just can't see all the pictures on your web page?

  • I checked out a little something similar to your "SERVERTECHS » Blog Archive » How to do basic MySQL optimization" post at another site I frequent... anyway, I believe apple is normally overrated but has some fantastic stuff as well.

  • Nice level of information right here. There is so very much data all around about this subject matter that sometimes you cannot see the wood for the trees but you might have pitched this at just the proper level to ensure that the lay person can understand - thank you!

  • harley davidson

    Nothing for nothing.

    -----------------------------------
    Ankara

  • Serina Roberg

    Hey how are you doing? I just wanted to stop by and say that it's been a pleasure reading your blog. I have bookmarked your website so that I can come back & read more in the future as well. plz do keep up the quality writing

  • tabletki na odchudzanie

    It is good too read your website again i see some interesting updates here..

  • Thanks for the article. I thought it was interesting.

  • free samples

    This is a exellent resource. Ill visit again.

  • Albina

    Finally, got what I was looking for!! I definitely enjoying every little bit of it. Glad I stumbled into this post! smile I have you bookmarked to check out new stuff you article. With regards, Albina.

  • resveratrol supplements

    Can you write another post about this subject due to the fact that this article was a bit tricky to fully grasp?

  • free tattoo designs

    Very cool blog, but you must improve your header graphics.

  • ohhh wonderful info

  • Earl Alden

    Hey your site looks a little bit weird in Firefox on my laptop with Linux .

  • beat at home pl

    Hi, i can write post to your site, if you are interested, please email me.

  • beat at home

    Awsome post Waiting for more info buddy !!

  • Staci Allard

    Just to let you know your site looks a little bit weird in Opera on computer with Linux .

  • luzne zwiazki pl

    Is this cms you use good for my first website ?? I want to start blogging soon and looking for good cms...

  • dallas

    Great thread. Enjoyed the posts..

  • preda

    Adding this to twitter great info.

  • Lizeth Goossens

    You have nice blog here. Not bad keep it up. Will great an article about that in my website. All the best

  • http://www.squidoo.com/isregcurescam

    You made various nice points there. I did a search on the theme and found most people will have the same opinion with your blog.

  • Travel Deals

    Hi I love this comment and it was so informational and I am gonna save it. I Have to say the Indepth analysis this article has is trully remarkable.Who goes that extra mile these days? Bravo :) Just one more suggestion you caninstall a Translator for your Worldwide Readers ...

  • find a good job

    Great post, bookmarked (at work!), will be back later

  • Roofing Philadelphia

    This blog is very cool! How did you make it !?

  • Closet organizer systems

    You are doing a great job at your web publication, guy. I have been constantly a reader of your weblog.

  • potenz

    This is so going into my next blog post. You'll get a backlink ofc.

  • Sporgelistics

    This actually answered my problem, thank you!

  • adderall

    Is it okay to post part of this on my website if I post a hyperlink back to this webpage?

  • cremation jewelry

    As soon as I discovered this website I went on reddit to share a few of the love together.

  • Breast enlargement without surgery

    Spot on with this write-up, I actually assume this website needs far more consideration. I?ll most likely be once more to learn far more, thanks for that info.

  • Cremation Jewelry

    Many of these comments dont make sense? Provide the guy a break and prevent posting crap

  • Singles

    Finde nette Singles ab 50

  • Man Bronson

    Awsome article and straight to the point. I don't know if this is actually the best place to ask but do you guys have any thoughts on where to hire some professional writers? Thanks in advance :)

  • unsecured loans with bad credit

    I wished to say that it's wonderful to know that somebody else also pointed out this as I had trouble finding the same information anywhere else. This was the first place that told me the answer. Appreciate it.

  • skateboard reviews

    This is third incident that we are reading anything about developing sites with the method. It looks that you are an super expert writer. Your method is an superb example of why I continue coming back to read your good quality content that is forever updated.

  • play casino slots online for money

    When I click your Feed it throws up a lot of strange characters, is the problem on my reader?

  • Shantay Bergenstock

    I really like this blog. Hopefully this comment works.

  • swissdent

    This theme was quite enlightening and properly written. I plan to complete some a lot more investigation on this. Many thanks for sharing this timely facts. We will need more this way. Lovely Greetings from Germany

  • waterproof boots guide

    Do the whole lot proper, think about every part you're making. All the time be able to have an answer as to why you probably did or did not do something. :) : Confucius

  • Julio Keever

    Really good stuff. Thank you for writing.

  • free premature ejaculation treatment

    I really find mtss is a interesting subject. Never looked at this subject in this manner. If you are going to create more articles relating to this subject, I will return in the near future!

  • Really cool blog. Thank you for writing.

  • ps3 repair

    I believed it was destined to be some boring outdated post, however it compensated for my time. I will post a link to this particular page on our blog. I am sure my own visitors will discover which very helpful.

  • mvc3

    hi all, I was just checkin' out this site and I really admire the foundation of the article, and have nothing to do, so if anyone would like to to have an enjoyable chat about it, please contact me on facebook, my name is clarissa zetila

  • Karina Hypolite

    Really cool post. Thank you for posting.

  • hostgator coupon site fatwallet.com

    Hey, great post, just one small question though, do you use wordpress? If you do, where can I get a template like you have for my blog, or did you make it yourself?

  • Shantay Harpin

    Wonderful website you have here.. Looks well organized and great content.

  • Hipolito M. Wiseman

    If you're still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you'll know which is right for you.

  • North Face Sale

    Like the l ist, believe that you had been spot on with th is 1. Fantastic work and ca notwait for a further yr of Brand new.

  • Hipolito M. Wiseman

    A great post, thanks for taking the time to share, continued success to your site in the future!

  • free auto insurance quotes

    I agreed to your feed! Will you post more about this theme? Exactly what I needed to get. Really very clear and valuable post. I am without a doubt a violator of numerous of those guidelines.

  • austin real estate

    Seriously that is precisely the advice that I have been hunting to obtain! You really reached appreciate Google simply for delivering us right to your website!

  • single mom scholarships

    Thanks, I've been seeking for information about this subject for ages and yours is the best I have discovered so far.

  • dollhouse bookcase

    I've been meaning to publish about something similar to this on my website which gave me a concept. Precisely the stuff I needed.

  • koszulki reklamowe

    Attractive section of content. I just stumbled upon your blog and in accession capital to assert that I acquire actually enjoyed account your blog posts. Anyway I will be subscribing to your feeds and even I achievement you access consistently quickly.

  • california health insurance

    The new Zune browser is surprisingly good, but not as good as the iPod's. It works well, but isn't as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that's not an issue, but if you're planning to browse the web alot from your PMP then the iPod's larger screen and better browser may be important.

  • calories burned

    For sure after 3 hours frantically searching for this domain I have finally here. On my opinion I shud bookmark this page so that annoying hours. Thanks to this great website. take care!

  • hard drive data recovery

    Great site here. Many websites like yours cover subjects that cant be found in print. I dont understand how we've got on Many years ago with just magazines and newspapers.

  • closet organization

    I generally dont announce in Blogs but your blog forced me to be able to, great work.. beautiful

  • Celestina Rauco

    It is your colourful blog that brings me a lot of konwledge about living. Thank you so much. And wish you better in the future.

  • Julie Kazabi

    Hi there, just spent a short break reading this site. I think I will frequent your blog from now on after going through at some of your posts. a lot to read, that's for sure.

  • Lula Klamert

    Absolutely indited subject material , Really enjoyed reading .

  • Shower Title Designs

    I like when you talk about this type of stuff in your posts. Perhaps could you continue this?

  • Watch family guy

    I'm really Glad i ran across this website.Added servertechs.co.cc to my bookmark!

  • girl nudes

    This is a well written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!

  • Raleigh Edrington

    Hi there, I’m at my job and was browsing on the web, goofing off, when I came across your web page. It is quite nicely accomplished, and I truly like your type of composing.

  • Sharonda Palombit

    This is a great post; it was very informative. I look forward in reading more of your work. Also, I made sure to bookmark your website so I can come back later. I enjoyed every moment of reading it.

  • ?????????

    Really nice post, thanks for a nice story.

  • Julianne Mickelsen

    Really cool blog. Thank you for posting.

  • luxury bedding

    I find myself coming to your site more often to the point where my visits are just about every day now!

  • Admin

    Thanks for recommendation... :)

  • cervical cancer symptoms

    Excellent website , I have discovered this insightful. Plenty of helpful tips within it. I'm really interested in the info on unhealthy weight. Maybe you have tried taking lipobind intended for saving fat ingestion? Or, do give it a try. It's effective to me. I've left a link to. Thanks.

  • Debbi Bratz

    I've been reading your blog for quite a while. Thanks for sharing your thoughts. I wish i had time and patience to make a informative post like yours. A ton of information on all the states. Bookmarked your blog.

  • ovarian cancer symptoms

    I noticed this webpage as someone used the phrase lipo bind in the recent article. My specialty is losing weight. As a result We're always interested in reading what exactly inspires successful individuals. blog.

  • Robot Unicorn Attack

    Can't wait to get this! I can feel a pretend stroke coming so I can stay home from Uni and waste time playing this.

  • wpolscemamymocneseo

    You made some decent points there. I looked on the internet for the issue and found most individuals will go along with with your website.

  • Mary Gordon

    Just thought I'd comment and say cool theme, did you create it by yourself? Its really really good! Straightforward and written well, appreciate the post.

  • Rashida Kesselman

    What’s Happening i am new to this, I stumbled upon this I've found It positively useful and it has helped me out loads. I hope to contribute & help other users like its aided me. Good job.

  • treatment for eczema

    Do you want to exchanging links beside me ? Please contact me if you would like

  • treatment for tinnitus

    Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The writing style is excellent and also the content is top-notch. Thanks for that insight you provide the readers!

  • cheap treadmills

    You completed some good points there. I did a search on the subject matter and found the majority of folks will consent with your blog.

  • Andrew Warnix

    Only wanna input that you have a very nice web site , I like the pattern it actually stands out.

  • Rapid Gigabitz

    i like it How to do basic MySQL optimization at this time im your rss reader

  • treatment for eczema

    Strange this post is totaly irrelevant towards the search query I entered in the search engines but it was on the first page. Man, I really loved reading your blogpost. You've convinced me a subscription for your blog, but where can I discover the Feed?

  • treatment for tinnitus

    After study a couple of the blog posts on your website now, and that i really like the right path of blogging. I added it to my favorites web page list and you will be checking back soon. Please visit my site also and tell me what you believe.

  • treatment for eczema

    Im truly grateful and really impressed. Thanks for making the effort to talk about this, Personally i think strongly about this and love reading more on this topic.

  • how to fix a xbox 360

    When I open your Feed it provides me with a bunch of garbled text, may be the issue on my end? Just thought I would comment and say cool theme, did you make it yourself? Looks great!

  • Admin

    :)

    http://www.facebook.com/profile.php?id=100001929683936

  • INTERNET MARKETING PLEASE SEND REPORT TO: ALLEN-JORDAN@FARPOINTALLIANCE.COM

    Very great post. the knowledge is second to none. i'll check back to examine if you post new stuff. Thanks

  • pizza coupons

    Thanks for another informative blog. Where else could I get that kind of information written in such a perfect way? I've a project that I am just now working on, and I have been on the look out for such information.

  • Felicia Lenihan

    hopefully this comment doesn't appear multiple times (it seems to freeze once i try to post my comment.. not sure if it's really posting), but all I truly wanted to say was fantastic post and thanks for sharing.

  • treatment for tinnitus

    Youre not the typical blog writer, man. You definitely have something powerful to add to the net. Your design is so strong that you could almost get away with being a bad writer, but youre even awesome at expressing that which you have to say. Continue the great work man!

  • hard disk data recovery

    Cheers concerning the post and that i find yourself being back to read much more! Just looking at some blogs, seems a fairly nice system you happen to be utilizing. I am currently using Wordpress for a few my blogs but I am not happy with it so far. Im searching to change 1 of these more than to a platform much like yours (BlogEngine) as a trial operate. Anything in particular you'd suggest?

  • desperate housewives online

    Thanks a lot, wonderful job! This was the thing I required to get. When I click your Feed it appears to be a lot of garbled text, is the malfunction on my side?

  • pozycjonowanie stron www

    Good article but it could be more accurate.

  • Epifania Arballo

    I really like the fresh perpective you did on the issue. Really was not expecting that when I started off studying. Your concepts had been simple to comprehend that I wondered why I never looked at it before. Glad to know that there's an individual out there that definitely understands what he's discussing. Great job

  • Ferdinand Paddock

    I went over this web site and I think you have a lot of great info , saved to my bookmarks (:.

  • portland oregon moving companies

    I believed it was gonna be some boring outdated post, however it compensated for time. I'll post a hyperlink to this particular page on our blog. I am sure my very own visitors will find of which very useful.

  • weight loss resources review

    I've been looking the web for such info and wanted to thank u with this post. BTW, just off topic, how can i download a version of the theme? – Many thanks

  • the magic of making up review

    I signed up to your feed! Are you going to post much more about this theme? Precisely what I needed to get. Really clear and valuable post. I am certainly a violator of many of those guidelines.

  • treatment for eczema

    Hello, I simply desired to take time to create a comment and say I have really enjoyed reading your site. Which was a really great article Please keep writing because I really like your style a lot.

  • PS3 repair

    Im truly grateful and really impressed. Thanks for making the effort to share this, I feel strongly about it and love reading more about this topic.

  • Ashley Ackerly

    Fantastic website you got here, best content yet!

  • medical terminology

    I noticed this webpage as someone used the idea of lipo bind inside of a recent article. My specialty is shedding weight. For this reason I am always concerned about reading precisely what inspires successful individuals. blog.

  • Ema Veater

    Bookmarked to read later today, Thank you...

  • watch the hills online

    Just wanted to let you know how much I enjoyed reading this ;D

  • Stephenie Rydel

    Hi - incredibly very good web site you could have built. I appreciated reading through the posting. I did desire to issue a short review to tell you that the actual design of this website is quite aesthetically delightful. I utilized to be a graphic designer, currently I'm a copy editor in chief for a marketing corporation. I've always enjoyed playing with information processing systems and am trying to learn computer code in my own free time (which there is never sufficient of lol).

  • Eli Philipose

    I’m happy to have found your exceptionally high quality article! I agree with some of your readers and will eagerly look forward to your coming updates.

  • government grants for women

    My sister saved this web page for me and I have been reading through it for the past several hrs. This is really going to benefit me and my friends for our class project. By the way, I enjoy the way you write.

  • Post a Comment