I just went through something similar where my rake tests kept getting slower. I am using Rails 2.0.2, Ruby 1.8.6, and Oracle 11.2.
The problem was that Oracle has a recycle bin, and that was filling up as the tables get dropped and recreated every time you run rake tests.
To keep the recycle bin from getting huge, I added a step to purge it after preparing the test database. Create a file lib/tasks/databases.rake
with the following:
namespace :db do
namespace :test do
task :prepare do
# The Oracle recycle bin fills up and slows down the test preparation.
ActiveRecord::Base.connection.execute("purge recyclebin")
end
end
end
You probably don't want to do this in your production database, but you aren't running db:test:prepare against your production database, are you?
I found the problem by noticing this query running for a long time:
SELECT lower(i.index_name) as index_name, i.uniqueness, lower(c.column_name) as column_name
FROM user_indexes i, user_ind_columns c
WHERE i.table_name = 'QCS_USERS'
AND c.index_name = i.index_name
AND i.index_name NOT IN (SELECT uc.index_name FROM user_constraints uc WHERE uc.constraint_type = 'P')
ORDER BY i.index_name, c.column_position
Looking at the user_constraints
table, I saw there were thousands of rows, even after I dropped all my tables, and that led me to some discussions of the recycle bin.