alvinsj / flatten_record

An ActiveRecord plugin that denormalizes your existing ActiveRecord models
MIT License
82 stars 9 forks source link

Unique benefits #20

Open sjmog opened 10 years ago

sjmog commented 10 years ago

Aside from simplifying relational structures for the server, what are the unique benefits of flattening records in this way? Are there any benchmarks?

supairish commented 10 years ago

I'm curious to this as well. What is your primary use case for this type of feature? Thanks!

alvinsj commented 10 years ago

I am using this primarily to create extra tables of denormalized records. Then I use them instead to perform SQL query to display some real time reports of the data. Currently I use some background queue to create the records.

sjmog commented 10 years ago

What is the benefit over just using SQL queries to grab records and relations?

Do you have any benchmarks for performance comparisons?

alvinsj commented 10 years ago

@sjmog, I guess it depends on the use case and the context. There are articles discussing about this, e.g. "normalize until it hurts, denormalize until it works". In my case, it reduces the SQL JOIN's query on large number of records and helped on the responsiveness when displaying data report. No benchmark built for this yet, but I guess you can find some related benchmarks on normalized vs. denormalized tables.

Yea, there is no one solution for all problems.