Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthortom
    • CommentTimeMar 13th 2008
     

    Hi,

    I've done some profiling in my application, and it seems that when doing multiple subsequent find()s to the same ActiveRecord class, there's a big performance penalty for the first call.

    I'm doing 15 find() calls, each with a record ID as single argument ($this->User->find( $some_ID) ), and the timings look like this:

    fast_listing_findUser_0_time=979.326 msec
    fast_listing_findUser_1_time=24.116 msec
    fast_listing_findUser_2_time=24.5121 msec
    fast_listing_findUser_3_time=24.1258 msec
    fast_listing_findUser_4_time=24.1451 msec
    fast_listing_findUser_5_time=24.122 msec
    fast_listing_findUser_6_time=25.4791 msec
    fast_listing_findUser_7_time=27.3218 msec
    fast_listing_findUser_8_time=32.3861 msec
    fast_listing_findUser_9_time=29.2711 msec
    fast_listing_findUser_10_time=25.63 msec
    fast_listing_findUser_11_time=24.539 msec
    fast_listing_findUser_12_time=24.673 msec
    fast_listing_findUser_13_time=29.3739 msec
    fast_listing_findUser_14_time=27.6229 msec
    

    So the first call takes about 30-40 times longer than the others.

    Any idea what could be the reason for this delay?

    How may I get rid of it?

    Cheers,

    Tom

    • CommentAuthorbjmg
    • CommentTimeMar 13th 2008
     
    Hi,

    I think this is due to the fact that MySQL (and many other database management systems) uses a technique that is called query caching. So subsequent calls to the same data are served to the client right from the cache. I think you can't do anything against it. Well there is a partial solution: you could use a clustered, memory based system like MySQL Cluster. But in most cases you can improve the query processing speed by creating some indices. In case of MySQL there is also a handy keyword named "EXPLAIN" to show how MySQL tries to fetch the data. Please read the documentation to get more information about that topic.

    Bernhard
    • CommentAuthortom
    • CommentTimeMar 13th 2008
     
    Hi Bernhard,

    thanks for the advice, I didn't know that EXPLAIN statement. :)

    ...but: Are you sure fetching a single database row may take a whole second? The id I'm using in the WHERE clause is the primary key, so there is an index on it. And, doing a similar query via the mysql commandline client takes "0.00 sec", even if the connection is newly created...

    Doesn't anyone else get such long delays with Akelos?

    Regards,

    Tom
    • CommentAuthorbjmg
    • CommentTimeMar 13th 2008
     
    Hi!

    Well then I would assume that akelos has to fill the cache (template cache) in the first run. This could take some time. But I am not sure. I just started to learn akelos.

    Bernhard
    •  
      CommentAuthorbermi
    • CommentTimeMar 13th 2008
     

    Akelos does not cache database column schema on development mode and that makes it slow when loading a model for the first time.

    On production mode (not on console apps) it will cache the schema to improve performance.

Add your comments
    Username Password
  • Format comments as