Why is the schema/structure dump so slow

dumporacle-11g-r2oracle-xerails

I'm using Rails 6 with activerecord-oracle_enhanced-adapter adapter for Oracle 11 XE database.
At the beginning of the project I was working with Postgres, but due to customer requirements I had to migrate to Oracle.

My question is very similar to https://stackoverflow.com/questions/592444/rails-rake-dbmigrate-very-slow-on-oracle, but it's from 11 years ago, i'm using the updated version of the adapter.

I know that after all migrations are applied to database then rake db:migrate calls db:schema:dump task to generate schema.rb file from current database schema. I only have one schema, with many tables (around 90)

The answer for the previous question was something like

One way how to debug this issue would be if you would put some debug
messages in oracle_enhanced_adapter.rb file so that you could identify
which method calls are taking so long time.

== 20200820164111 RemoveSemesterFromProject: migrated (0.1347s) ===============
real    13m26,038s
user    0m5,494s
sys 0m0,401s

All migrations finished in an reasonable time, so I think the error occurs in the following action "db: schema: dump" but i don't have oracle_enchaced_adapter.rb neither oracle_enhanced_adapter.rb, so i don't know where to look at.

What can i do for improve this behaviour?

Time that takes when i run db:schema:dump

real    9m44,074s
user    0m3,701s
sys 0m0,327s

and this is the time that takes when i run db:structure:dump

real    21m40,073s
user    0m5,046s
sys 0m0,413s

Best Answer

This may be a consequence of slow queries issued by activerecord-oracle_enhanced-adapter to determine the database structure, eg. issues/2004