4, December 2008

Some tips to optimize MySQL - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: Some tips to optimize MySQL
« previous next »
Pages: [1] Print

Author Topic: Some tips to optimize MySQL  (Read 12593 times)
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« on: Aug 26, 2005, 11:25:18 PM »

I would like to introduce you to some very simple techniques that can speed up your queries.


1) LIMIT:
    Using the limit statement is the first and most critical query statement, because the dbms ( database management system ) will stop searching when it will found the necessery records. It reduces query time specially in tables with lots of records.

examples : SELECT * FROM table WHERE field = 'value' LIMIT 10
                    UPDATE LOW_PRIORITY table SET field = 'value' WHERE field = 'value' LIMIT 1



2) UPDATE LOW_PRIORITY
    When you are making an update in tables that their data are not about to be used immediately, you can use update statements with LOW_PRIORITY. This way the query will be stored in a buffer, and it will be executed when the server is not busy. This type of query is perfect for statistics, session control and rate it types of tables.

example : UPDATE LOW_PRIORITY table SET field = 'value' WHERE field = 'value' LIMIT 1

3) Allways search indexed fields.
    When you are making SELECT statements try to insert indexed fields in the WHERE clause. To create an indexed field use this command:

ALTER TABLE `table` ADD INDEX ( `field` )

Well that's all for now, I will write more when I have more time....
« Last Edit: Nov 24, 2005, 05:39:06 PM by Nikolas »

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« Reply #1 on: Sep 20, 2005, 08:46:22 PM »

Let me continue this small tutorial :

4) INSERT DELAYED statement
    When you insert a record into a table, but you do not actually want it to be available in the exact moment, and you are not about to use the insert id of the record, you can use this statement. This way, the query will be puted to a buffer, and when the database is not busy, it will execute it. This way the server is not producing overhead, and the client get the requests faster.

Example : INSERT DELAYED INTO log_table VALUES ('1', '2', '3' )

Here is the full documentation for INSERT DELAYED Visit through proxy


Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Novice Spammer
***
Gender: Female
Posts: 101
0 credits
Members referred : 0



« Reply #2 on: Sep 21, 2005, 04:55:50 AM »

Wow, I'll be checking back more on this thread- I didnt know like, half of it :LOL: Glad you wrote it. Thanks!!
Cyberpunk Wannabe
*
Posts: 38
256 credits
Members referred : 0



« Reply #3 on: Nov 04, 2005, 07:29:54 PM »

Interesting, I didn't knew that you can do such things with mySql
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #4 on: Nov 24, 2005, 05:34:00 PM »

Shouldn't 2) be ... when the server is not busy. ?


Last blog : Site of the Month - August 2007
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« Reply #5 on: Nov 24, 2005, 05:39:37 PM »

Hehe. You are right.

I've just corrected it.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3
Tags : tutorials mysql databases Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: Some tips to optimize MySQL
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Dec 04, 2008, 06:30:38 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!





Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.