1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Page Generation Takes 1.9 seconds? Is it ok?

Discussion in 'PHP' started by olddocks, Aug 21, 2007.

  1. #1
    I implement complex algorithm with PHP and mysql. I noticed that to display main page, it takes about 1.8sec or more...

    Is it too slow?
     
    olddocks, Aug 21, 2007 IP
  2. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #2
    It depends upon your mysql queries. You can run each query in phpmyadmin, note the time and add it up. This way you will also know which query is taking longer and needs optimisation
     
    Kuldeep1952, Aug 21, 2007 IP
  3. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #3
    actually i run about 100 queries to generate the results.
     
    olddocks, Aug 22, 2007 IP
  4. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #4
    The queries are time consuming. Try minimizing their number or maybe using Ajax so that you can load the page first and load the data second.
     
    NoamBarz, Aug 22, 2007 IP
  5. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #5
    Thanks NoamBarz, Actually i am worried about this site: quick-name-generator.com. I takes about 1.5s to load main page as it is algorithmically intensive. Until now i havent found a way, although i have tried my best to optimize.
     
    olddocks, Aug 22, 2007 IP
  6. codesome

    codesome Peon

    Messages:
    98
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    olddocks, are all names pregenerated and stores in database? Or you generate Markov chains in real time?
     
    codesome, Aug 22, 2007 IP
  7. HuggyCT2

    HuggyCT2 Guest

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Try and use left joins etc to speed it up rather then many querys.
     
    HuggyCT2, Aug 22, 2007 IP
  8. l0gic

    l0gic Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Tweak the code to debug SQL queries; dump them all to file for a single page load. Then, go over each one and see how it can be optimized and/or combined with others.
     
    l0gic, Aug 22, 2007 IP
  9. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #9
    yeah! i generate Markov chains in real time. Thatshow output is generated. Should i worry?
     
    olddocks, Aug 22, 2007 IP
  10. codesome

    codesome Peon

    Messages:
    98
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #10
    So, if you will pregenerate a some chains, your page will generates more faster. But i think it is not what you want to hear.
     
    codesome, Aug 22, 2007 IP
    olddocks likes this.
  11. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #11
    very good idea indeed.

    The problem is if i pre-generate the outcomes, there will be a large no of random words stored in database. Again if i want to pick randomly rand() in mysql would drastically face slowdowns. Further the pre-generated ones may occur frequently in outcomes.

    I will see what i can do. +rep added :D:D
     
    olddocks, Aug 22, 2007 IP
  12. codesome

    codesome Peon

    Messages:
    98
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hm. Generete random number via php ($rand=mt_rand(1,$max)) and make select query like:

    select * from table where `id`='$rand';

    And if `ID` is primary key it will work very fast. If you need another field in 'where' build index with it.
     
    codesome, Aug 22, 2007 IP
  13. ssanders82

    ssanders82 Peon

    Messages:
    77
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Agree with you that "order by Rand()" is pretty slow in MySQL. One thing I saw on your page for baby's first name: popular name was "Sage" and randomly twisted was "Sage". You might want to check that these are not equal.

    Cool site though
     
    ssanders82, Aug 23, 2007 IP