ruby on rails - How to drop DB indices before bulk loading in seeds.rb? -


in rails app have seeds.rb script inserts lots of records. in fact i'm trying load 16 million of them. it's taking long time.

one thing wanted try speed up, drop table indices , re-add them afterwards. if sounds i'm doing insane, please let me know, seems 1 recommendation bulk loading postgres

i use add_index , remove_index commands in migrations, same syntax doesn't work in seeds.rb file. possible outside migration in fact? (i'm imagining might not best practice, because represents schema change)

rails v2.3.8, postgres v8.4.8

one possibility indulge in little raw sql within seeds.rb

activerecord::base.connection.execute("drop index myindex on mytable") 

at 16 million records, recommend managing whole thing via raw sql (contained within seeds.rb if like). 16 million records go single table? there ought postgresql magic bulk import file (in postgresql specific format) table.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -