transaction when operating in two tables

Hello,

I'm reading from a table in the database to fetch some path to files
to
import.

I do a loop for each path, and for each .csv file, I update another
table.

All works perfect, but it takes lot of time, 90 files and aprox.
2.000.000 rows.

After adding transactions, the speed has been great, 400% faster.

Now, as I see I have to specify the table for wich the transaction
occur, where I have to use, the firsst table (where I fetch the path
to
files) or from the other one ?

In your case, it doesn't matter. In theory, different models can be
using different connections, so Master.trasaction means 'start a
transaction on the connection that Master users'
Since you're not using different dbs, it doesn't matter. However you
should note that rails doesn't allow you to write transactions that
cover multiple databases. In your particular case the speed game
probably comes from not having to flush to disk after each row update,
so if all you care about is the speed then putting the transaction on
Master would be the write thing since that's where all the writes are.

Fred