[web2py] Re: Slow queries or how to determine if cache is working?
You only apply cache to your last query. You might need to cache the other two queries to gain full cache boost. Besides, you can add some profiling checkpoint inside your code to know which part is time consuming. Regards, Ray On Feb 25, 3:53 pm, pbreit pbreitenb...@gmail.com wrote: I'm struggling to figure out if caching is working. I insert a list of categories on pages where I show a bunch of items for sale. First, I only have 400 items in the DB and it takes quite a bit longer than I would expect to display the first time. Second, I am trying to cache the query and it doesn't appear to speed up at all. Does this mean my problem might be elsewhere? Is there any way to tell that caching is working? Here is my page:http://pricetack.com/items The component (I've tried cache.disk as well): def item_groupings(): seller = db(db.auth_user.name==request.vars.seller).select().first() if seller: groupings = db((db.item.status=='active') (db.item.seller==seller) (db.item.grouping!='test')).select(db.item.grouping, orderby=db.item.grouping, distinct=True) else: groupings = db((db.item.status=='active') (db.item.grouping!='test')).select(db.item.grouping, orderby=db.item.grouping, distinct=True, cache=(cache.ram, 360)) return dict(groupings=groupings) Maybe I should try to generate the HTML in the controller?
[web2py] Re: Slow queries or how to determine if cache is working?
Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony
[web2py] Re: Slow queries or how to determine if cache is working?
Ah, right, thanks. I missed it because I don't use the default layout. I do notice, however, that while the cache does appear to be working, Web2py is reporting the cache size as 0: Size of cache: *0* items, *0* bytes The performance seems really slow, though since it's only running through about 400 records total. I would expect that to return instantly. Here's the query as reported by Web2py: SELECT DISTINCT item.grouping FROM item WHERE ((item.status = 'active') AND (item.grouping 'test')) ORDER BY item.grouping; On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony
[web2py] Re: Slow queries or how to determine if cache is working?
Also, on the 3rd or 4th draw on the cache it seems to just stall indefinitely (the categories in the side bar never display, it just shows loading... indefinitely. ps: sorry about the excessive quoting. Google Groups interface is giving me all sorts of problems right now. On Saturday, February 25, 2012 7:33:33 PM UTC-8, pbreit wrote: Ah, right, thanks. I missed it because I don't use the default layout. I do notice, however, that while the cache does appear to be working, Web2py is reporting the cache size as 0: Size of cache: *0* items, *0* bytes The performance seems really slow, though since it's only running through about 400 records total. I would expect that to return instantly. Here's the query as reported by Web2py: SELECT DISTINCT item.grouping FROM item WHERE ((item.status = 'active') AND (item.grouping 'test')) ORDER BY item.grouping; On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 7:33:33 PM UTC-8, pbreit wrote: Ah, right, thanks. I missed it because I don't use the default layout. I do notice, however, that while the cache does appear to be working, Web2py is reporting the cache size as 0: Size of cache: *0* items, *0* bytes The performance seems really slow, though since it's only running through about 400 records total. I would expect that to return instantly. Here's the query as reported by Web2py: SELECT DISTINCT item.grouping FROM item WHERE ((item.status = 'active') AND (item.grouping 'test')) ORDER BY item.grouping; On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony On Saturday, February 25, 2012 6:44:46 AM UTC-8, Anthony wrote: Is there any way to tell that caching is working? appadmin should include a menu with design, db, state, and cache. The cache link leads to /appadmin/ccache, which shows objects currently in the ram and disk caches, cache hits, etc. Anthony
[web2py] Re: Slow queries or how to determine if cache is working?
Ah, right, thanks. I missed it because I don't use the default layout. I do notice, however, that while the cache does appear to be working, Web2py is reporting the cache size as 0: Size of cache: *0* items, *0* bytes Is it an older version of appadmin? In the current version, if you don't have the Python guppy library installed, you should get the following: Size of cache: not available (requires the Python guppy library) The performance seems really slow, though since it's only running through about 400 records total. I would expect that to return instantly. Here's the query as reported by Web2py: Have you tried including response.toolbar() and checking db stats for the query timings? Anthony
[web2py] Re: Slow queries or how to determine if cache is working?
OK, the problem is not query speed, it's that LOAD(...ajax=True) is really slow. I switched that to false and the page displays instantly now. But the appadmin/ccache page is still showing the cache at 0 even though it's recording hits (and db stats is not showing the query indicating that it is getting it from cache). And that's after just updating to a current appadmin.py.
[web2py] Re: Slow queries or how to determine if cache is working?
I realize that LOAD(ajax=True) could introduce a bit of a slow down but it seems much larger to me than I would expect. Does anyone else notice this? I originally used a bunch of ajax=True but I am switching to False and the pages are loading much faster. On Saturday, February 25, 2012 8:03:17 PM UTC-8, pbreit wrote: OK, the problem is not query speed, it's that LOAD(...ajax=True) is really slow. I switched that to false and the page displays instantly now. But the appadmin/ccache page is still showing the cache at 0 even though it's recording hits (and db stats is not showing the query indicating that it is getting it from cache). And that's after just updating to a current appadmin.py.
[web2py] Re: Slow queries or how to determine if cache is working?
On Saturday, February 25, 2012 11:04:30 PM UTC-5, pbreit wrote: I realize that LOAD(ajax=True) could introduce a bit of a slow down but it seems much larger to me than I would expect. Does anyone else notice this? I originally used a bunch of ajax=True but I am switching to False and the pages are loading much faster. Have you tried session.forget(response) in your LOAD functions? Requests that come in for the same session block each other because each request locks the session file until it has completed -- so Ajax requests will happen synchronously instead of asynchronously if (file-based) sessions are enabled for each request. Still, even with synchronous Ajax requests, I wouldn't expect it to take too long, unless you've got lots of Ajax requests happening. Anthony
[web2py] Re: Slow queries or how to determine if cache is working?
But the appadmin/ccache page is still showing the cache at 0 even though it's recording hits (and db stats is not showing the query indicating that it is getting it from cache). And that's after just updating to a current appadmin.py. You might need to update /views/appadmin.html as well. Anthony