On Wed, 03 Mar 2010 20:39:35 +0100 mk <mrk...@gmail.com> wrote: > > If you denormalise the table, and update the first index to be on > > (client_id, project_id, date) it can end up running far more quickly -
Maybe. Don't start with denormalization. Write it properly and only consider changing if profiling suggests that that is your bottleneck. With a decent database engine and proper design it will hardly ever be. > From what you write further in the mail I conclude that you have not > eliminated the first table, just made table projects look like I wrote > above, right? (and used stored procedures to make sure that both tables > contain the relevant data for client_id and project_id columns in both > tables) Note that rather than speeding things up this could actually slow things down depending on your usage. If you do lots of updates and you have to write extra information every time then that's worse than a few extra reads, especially since read data can be cached but written data must be pushed to disk immediately in an ACID database. -- D'Arcy J.M. Cain <da...@druid.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list