You can first split the file into several smaller files, then you can process multiple files in parallel.
It is likely that the user will be able to use a tool faster, such as split
split -l 1000000 ./test.txt ./out-files-
Then, while you are processing each of the files and assuming that you are inserting records, rather than pasting them one by one, you can combine them into batches and make voluminous inserts. Sort of:
INSERT INTO some_table VALUES (1,'data1'), (2, 'data2')
To improve performance, you need to create an SQL statement yourself and execute it:
ActiveRecord::Base.connection.execute('INSERT INTO <whatever you have built>')
Kamen source share