This example has worked really well so far, but I thought I'd mention that I ran into few small things and made some changes.1) This is was minor. I wanted to be able to use the cache_regions on multiple databases from the same program so I made the CachingQuery class take a parameter with the regions dict it operates on -- simple enough, and similar to the Beaker example which takes a cache manager instance.
2) This was a little more interesting. I replaced an existing simplistic caching implementation that stored database results with the new dogpile.cache implementation and I saw my request times slow down from 16ms to 66ms. It kind of shocked me that it was so much slower, so I ran cProfile and gprof2dot against it to see what was happening. I found out that the key generation algorithm in _key_from_query -- specifically visitors.traverse -- was causing the slow-down. Once I added a small feature to use explicit cache keys, it was back to normal. Admittedly the tables I'm caching in this case are quite large; three preference tables that have 100+ columns each.
However, I think it does serve as a bit of a warning, since I imagine the traverse only gets slower as the query gets more complicated (although I haven't tested that). Automatic cache-key generation based on the query is nice, but there is certainly a price to be paid in some circumstances.
Anyway, thanks again for the example Mike. I imagine that some (maybe all) of these things could be due to the fact that it is just an example, but since it is new I thought I'd pass along my experience. It's simplicity certainly helped me to see where all the pieces fit and to start making these changes.
On Monday, September 24, 2012 4:15:29 PM UTC+2, Michael Bayer wrote:yes, the example in 0.8 should be changed to this, but I haven't done it yet. dogpile's usage is similar to Beaker as far as the general calling pattern. A tutorial format of the example using dogpile is attached.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/hO3TuPbT8AAJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Previously, I had it just using the "binds" that were in the Query, but we had cases where bound parameters were embedded in the statement too affecting things. So as a quick fix I changed it to just traverse the whole statement, but this can be optimized significantly more than it is. It's the way it is so that it "works" more completely on the first go-around.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/JvefOSuw1FwJ.