Site slow loading because of mysql?

Discussion in 'MySQL' started by olddocks, Oct 16, 2011.

  1. #1
    i have a website, and it takes about 5-6 seconds to load the homepage.
    i suspect mysql is causing the problem. my mysql database consists of approx 200k records and i am querying the database using select to retrieve rows between two dates.

    what could be causing this?

    i am hosting on a dedicated celeron server, with 1GB ram and cpanel.

    does creating index would speed up everything?
     
    olddocks, Oct 16, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Doing a linear search (a search on a field that's not indexed) is about as slow an operation as you can do on a database. Indexing the field(s) you're searching on will speed things up. (One page I wrote initially did a linear search on about 90 million records - in a database that's a lot faster than MySQL. It took about 18 minutes. Indexing the search fields brought that down to about 25 seconds.)

    Index all the fields in that query's WHERE clause as a single index. 200k records in MySQL on that computer should be very fast. (Transferring 200k records, or even a few thousand records, over the internet may take a while. Displaying them in IE6 in Javascript may mean that your grand children will be debugging the site.)
     
    Rukbat, Oct 16, 2011 IP
  3. supportex

    supportex Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Enable slow log, after try optimize your "bad" queries. Also 1Gb memory small for normal work for this database.
     
    supportex, Oct 17, 2011 IP
  4. contentmegaguru

    contentmegaguru Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use free optimizing software, it can check to see if there are slow loading elements on your page...
     
    contentmegaguru, Oct 17, 2011 IP
  5. freshdevelopment

    freshdevelopment Notable Member

    Messages:
    1,303
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    240
    #5
    Do an:

    echo date('Y-m-d H:i:s');
    PHP:
    directly before and after the query. That will show how long the query is taking in the output on your page, and you can then index etc. as said above if it is this query.
     
    freshdevelopment, Oct 18, 2011 IP