jeudi 26 mars 2015

DB space vs query complexity tradeoff


I have a dilemma - Right now I have a query that I do constantly - joining 5 tables on different columns, calculate stuff per row, distinct on that, and do that with offset and limit (pagination). I try to use result caching as much as I can so I wouldn't hit the DB too much.


But now I am thinking, to simplify all this, I can create another table which will ease the joining (since its already joined with the relevant data) and extracting rows for that should be simpler since there is only one table. However, that table will be as big as N x M where N and M are 2 of the largest tables in the above query. (right now, its about 50,000 and 600,000, which yields a 30 billion row table...)


In the long run, are complex queries that strain the DB (and how can I handle them with ease) better or would it be better to strive for simpler queries on larger tables?





Aucun commentaire:

Enregistrer un commentaire