Django, epix phail #4 - The road to hell. 11

Posted by Peter Morris Fri, 01 Jan 2010 13:04:00 GMT

I started to write this from the perspective of "Ruby has this and Django don't" but I realised that was wrong, and started again.


Django implements Multiple Table Inheritance, and to a degree that works nicely, BUT, because the data for a single object is strewn over several tables, it can get VERY slow to iterate across a large collection of objects and resolve exactly which object we have.


Depending on the hierarchy, it can take many 10s of milliseconds to find the real object we want. That is not so bad, but when

you are iterating across a collection of a couple of hundred items, those 10ms add up to considerable delay.
 As a consequence, you try to do everything you can to avoid having to resolve to the 'real object'. This leads you into sin.

The real issue is that once you have started down the path of OO sinfulness, you start trying to be clever about it, and the code gets not just sinful, but fiendish. You start off with a nice clean OO structure, that requires you to resolve to the real object, and when you
hit situations where you are iterating over a large set of objects and so you get clobbered by 100s of 10ms piling up, you take a shortcut, changing your OO structure to try to remove the requirement to resolve the objects. This good intention gets layed down in

front of you like a paving slab, making it look like you are making progress and keeping things neat, but all around you the monsters are gathering, sharpening their knives as your path becomes ever narrower, darker and deeper.


Now, I know that all the Django heads out there are going to say, 'well, you should have done it THIS way'. Well, maybe next time I will, but right now, I am down here fighting monsters and trying desperately to stay afloat.

  1. poyfjl 29 days later:
  2. dennis about 1 month later:
    health insurance 1267 life insurance 75565 auto insurance :(((
  3. evdokiya about 1 month later:
    cheap health insurance =DD health insurance hfzam health insurance 258 cheap auto insurance zxqho
  4. gourline about 1 month later:
    health insurance quotes %-DDD life insurance policy 8O auto insurance tjnozp
  5. attent about 1 month later:
    auto insurance 8((( home insurance 933 health insurance %PP life insurance quotes ehcmi
  6. Minima about 1 month later:
    phentermine 80441 tramadol qspfdu accutane %)) accutane ftp
  7. smtp1 about 1 month later:
    tramadol >:-DD ambien utvzv accutane zzmjfv health insurance quotes ptz ultram urewu valium 7061 levitra qkj
  8. apirkgem about 1 month later:
  9. portal about 1 month later:
    phentermine %-PP aciphex rugjsi phentermine 477 xanax zryb pain pill ultram =-( accutane >:[
  10. coloronline about 1 month later:
    car insurance quotes cdoiz phentermine 72004 accutane %-)
  11. zinmag about 1 month later:
    affordable life insurance >:-(( pennsylvania health insurance 042338 california health insurance 621468 auto insurance =-PPP