Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've found denormalization to be helpful for such performance issues in that it reduces the number of joins. It can also be useful for debugging if you want to keep track of values from other tables at the time that data was processed within the primary table.


A certain amount of denormalization can be helpful, but often there's a trade-off in terms of maintainability.


Not who you replied to.

But yes,

As an example, we keep our data normalized and add extra tables to do the operations we need. It’s expensive since we have to precompute, etc. But then on lookups it’s quicker.

Like everything, it depends on what you want to optimize for.


Yep, in my case we wanted to make user-facing queries fast (i.e. a reports page). The extra complexity (not much; we just have to remember when to update certain values in other tables when they change) is definitely worth it since load time dropped from 30 seconds sometimes to almost instant.

Denormalizing everything is definitely a pain; keeping data in sync in mongodb (which lacks traditional joins) on a previous project was not fun; now using postgresql.


denormalization should only be seen as a last resort


denormalization aka memoization aka "dynamic programming of SQL" :-) - all three provide speed-up because they compute value once and reuse it later


Except that your source of truth aka your raw data is now memoized, hardly a win. This is not a goal of memoization or dynamic programming at all.

Perfect for a reporting database though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: