How to optimize database for mysql?

Discussion in 'MySQL' started by gmchun83, Apr 9, 2009.

  1. #1
    I was having problem with database overload.My hosting provider saying that my website having heavy SQL query.

    So,how to optimize the database?
     
    gmchun83, Apr 9, 2009 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Your question by itself is endless to discuss. How did your provider proof his assertion(the answer must be there)? Maybe optimization must be performed on queries, not only on database.
    Regards.
     
    koko5, Apr 9, 2009 IP
  3. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #3
    Check your SQL queries and optimize then.
    If necessary then optimize the table structures also
    Delete unnecessary data and tables.
     
    MayurGondaliya, Apr 9, 2009 IP
  4. karli

    karli Guest

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Correct. Check your SQL queries
     
    karli, Apr 9, 2009 IP
  5. BlackhatVault

    BlackhatVault Banned

    Messages:
    262
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Waht kind a script are you running?
    If it's a self made script you should try to delete whatever you don't need, or try to use the same information two or three times.
    Let's say you store the same names and phone numbers three times, you could delete two of the tables to optimize it!
     
    BlackhatVault, Apr 10, 2009 IP
  6. nirajkum

    nirajkum Active Member

    Messages:
    815
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #6
    nirajkum, Apr 10, 2009 IP
  7. T.Guru

    T.Guru Peon

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Check all of your queries on the database to try to find a solution. Thats how you are going to optimise your database.
     
    T.Guru, Apr 10, 2009 IP
  8. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #8
    mwasif, Apr 11, 2009 IP
  9. tera

    tera Peon

    Messages:
    159
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Making some indexes and ajusting sql queries will see a big difference.Although if a query still is hard and painfull :D consider making smart tables as i refer to them.
    Example:

    if you have 1 million items and you have a 2000 items additions per day but you only want to show 100 most wanted from lasts week additions you can limit the query to select from 7x2000=14000 latest id's.If these is heavy too,insert these ids to another table every week (deleting the old ofcourse) and do your queries there,this is an example more sofisticated things can be done if background scripts make selections and update tables for often use.Mysql is getting slower if has a lot of rows to check so small ammount of rows faster results,indexes are for this purpose but sometimes cannot be used for our needs so small tricks will give us what we want.
     
    tera, Apr 14, 2009 IP