Tumblog archive for August
GenericForeignKeys with Less Queries
Horst Gutmann from Austria has published this fantastic blog post that gives a great performance boost to Django's generic relationships. In a situation where you have an 'Item' table that has a generic relationship to three sub-tables (eg BlogPost, Photo, Link) when you display details from the sub-tables in a for loop there will be n+1 queries - one query for every item shown.
Horst's trick is to first fetch the content-type ID's in one query, then use one query for each subtable - so 4 queries for the above example, regardless of the number of separate Link or BlogPost items you actually have.
This should do a marvellous job for most tumblog style websites, although I imagine if you had a massive number of items the memory usage would probably spike quite high and you'd be better off having duplicate database queries.
http://zerokspot.com/weblog/2008/08/13/genericforeignkeys-with-less-queries/Olympic Medals at the Athens Olympics by Population
Watching a few Olympic events over the weekend I was thinking "I wonder where Australia would be on the winners table at the Olympics if they counted medals by population" - and this morning, via Kottke, I've found a great chart showing just that.
What's cool for me is that Australia are the only top-10 medal winner who are still in the top-10 by population... in fact, we moved up two places. Aussie Aussie Aussie, Oi Oi Oi!
http://www.moreintelligentlife.com/story/an-olympic-gameEasily packaging and distributing Django apps with setuptools and easy_install
This fantastic blog posts shows how easy it is to list your Django applications in Pypi, a Python package registry. The major advantage to this is that future users of your software can just type easy_install mycoolpackage and have your software installed rather than having to download with SVN, move files to the PYTHONPATH, find out why it hasn't worked, etc.
Flash-based Guitar Tuner
I don't play guitar very well, and only pick up my guitar every few months to have a quick fool around with. Every time I touch it it's out of tune, and I spend longer chasing down a good tuning reference point than I do actually playing.
This looks promising... now to teach myself how to do something other than tune the thing and play scales.
http://www.howtotuneaguitar.org/