Any idea on how to increase speed of mySQL heavy page?

Discussion in 'MySQL' started by IAmEncore, Jan 4, 2008.

  1. #1
    There is a page on my clients website which he has asked me to make faster. It's a profile page and queries the db about 100 times to get user data (...!). I didn't code this page so it is a bit hard for me to work out if I can optimise it much.

    Are there any ways to increase the load time for mysql queries that do not require script/code modification?
     
    IAmEncore, Jan 4, 2008 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    WTF??? what on earth is it doing to do 100 queries on a single page load????

    Rewrite the page... at a minimum move to stored procedures but look at correcting the underlying problems (though of cause it may require other changes too - though if the DAL is separate as it should be then it shouldnt be too time consuming to do)
     
    AstarothSolutions, Jan 4, 2008 IP
  3. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #3
    100 queries to get the user data for one page is very excessive and should be the
    main target of optimisation. Other than that you can:

    - check that db has appropriate indexes.
    - Increase RAM
     
    Kuldeep1952, Jan 4, 2008 IP
  4. Robert Dinse

    Robert Dinse Guest

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If there is a way you can spread the load out across multiple servers, you can use database replication in MySQL to have several servers in sync with the same data so that queries can be spread across them.
     
    Robert Dinse, Jan 5, 2008 IP
  5. alemcherry

    alemcherry Guest

    Best Answers:
    0
    #5
    1. Indexing
    2. Rewriting the page. 100 queries in one page sounds so funny!
     
    alemcherry, Jan 8, 2008 IP
  6. bochgoch

    bochgoch Peon

    Messages:
    1,918
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You've got to rewrite it, anything else if just storing up problems for the future.

    The only alternative to that I'd consider would be to cache the page i.e. generate the page and store it then server that stored page to the users ... that will only work if the page is relatively static and the stored page doesn't need refreshing often.
     
    bochgoch, Jan 9, 2008 IP
  7. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    rewrite the code
     
    kendo1979, Jan 9, 2008 IP
  8. chrissyj

    chrissyj Peon

    Messages:
    56
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    While I agree that you should re-write the code, I would bet that you could fix the worst of the SPEED problem with the proper use of indexes.

    PM me if you would like further help.
     
    chrissyj, Jan 10, 2008 IP
  9. Kwaku

    Kwaku Well-Known Member

    Messages:
    1,217
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #9
    best speed fix with least work is writing caching for the pages; even with optimizing and removing most queries, under heavy load database backed pages are not really scalable without proper caching.
     
    Kwaku, Jan 12, 2008 IP
  10. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Unacceptable.

    You need to structure this db properly and have it carry ID' and indexed entries to pull the data.

    Having 10 mysql calls on a single page is just silly & embarassing.
     
    LittleJonSupportSite, Jan 12, 2008 IP