ruby - How to store a list of small numbers in Postgres -


i have long list of small numbers, of them < 16 there can more 10000 of them in unique list.

i values comma separated list, like:

6,12,10,2,2,2,6,12,8,2,2,6,10,2,4,12,14,10,2, .... lots , lots of numbers 

and need store values in database in efficient way in order read , processed again ... string, comma separated values.

i thinking of sort of storing them in big text field ... find adding commas in there waste of space.

i wondering if there best practice scenario.

for more technical details:

for database have use postgres (and sort of beginner in field), , programming language ruby (also beginner :) )

numbers = "6,12,10,2,2,2,6,12,8,2,2,6,10,2,4,12,14,10,2"  numbers.split(',')        .map { |n| n.to_i.to_s(2).rjust(4, '0') }        .join        .to_i(2)        .to_s(36) #⇒ "57ymwcgbl1umt2a"  "57ymwcgbl1umt2a".to_i(36)                  .to_s(2)                  .tap { |e| e.prepend('0') until (e.length % 4).zero? }                  .scan(/.{4}/)                  .map { |e| e.to_i(2).to_s }                  .join(',') #⇒ "6,12,10,2,2,2,6,12,8,2,2,6,10,2,4,12,14,10,2" 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -