Best practice for huge table size on Ruby on Rails 4 / ActiveRecord

FBetter practice for huge table size on Ruby on Rails 4 / ActiveRecord

How can I split a big table in postgreSQL to Active Record in Rails 4

I prefer PostgreSQL or another DBMS because I tried this in MongoDB. It is really slow.

Is Rails 4 good solution for one large large table?

(my case: more than 50 billions records, size about 20TB )

Data Description

There is a User table containing the fields name, personal_data, year .

Data can be divided by year , and data will be divided evenly.

Ideas

I think it’s not practical to create several models like User_1950, User_2001,..., User_2015

I want partition integer data year

There are two approaches that I can come up with.

  • splits into different physical table in one database. (sharding?)
  • splits into different physical database into different databases. (can it work well with Rails).

I want the solution compatible with Active Record

he will act as

User.find(name: xxx, year: 1988) User.find(name: xxx, year: 2012)

So, it doesn't matter to me how to access partitioned tables.

As far as I know

I found a partitioned gem but that does not support Rails 4

+8
activerecord postgresql ruby-on-rails-4 rails-postgresql sharding
source share
1 answer

Since you store data by year, perhaps you can use data with deferred data based on years. I would suggest octopus for use with activerecord.

Your queries will become something like this:

 User.using(:year_2012).find(name: xxx) 
+3
source share

All Articles