nuodb / migration-tools

Migration tools for NuoDB
http://nuodb.github.com/migration-tools/
BSD 3-Clause "New" or "Revised" License
27 stars 10 forks source link

Exporting data from one table loops through all tables in schema #54

Open tgrginnuodb opened 4 years ago

tgrginnuodb commented 4 years ago

$ bin/nuodb-migration dump --source.driver=com.nuodb.jdbc.Driver \ --source.url=jdbc:com.nuodb://localhost/test \ --source.username= \ --source.schema=hockey --table=hockey --table.hockey.filter=id<>25 \ --output.path=/tmp/dump.cat --output.type=bson will go through ALL tables in hockey issuing metadata query before reaching table=hockey.

In my case (~50k atoms) migrator does not reach desired table not after hours of running because it is extracting structure for each table in schema rendering migrator useless.

Suggested fix: SKIP over tables with TABLENAME <> --table.

philip-stoev commented 4 years ago

The problem is that Migrator calls JDBC's getColumnInfo() for every table in the database, even for tables that you are not interested in exporting. For 50K tables, this query takes 15ms to run, so 806 seconds for 50K tables.

The following patch shows the location in the Migrator code where it is possible to short-cut the loop so that getColumnInfo() is called only for the table you are interested in (Note that the name of the table is hard-coded in the patch).

diff --git a/core/src/main/java/com/nuodb/migrator/backup/writer/BackupWriter.java b/core/src/main/java/com/nuodb/migrator/backup/writer/BackupWriter.java
index 59dc02d4..d84ec1e3 100644
--- a/core/src/main/java/com/nuodb/migrator/backup/writer/BackupWriter.java
+++ b/core/src/main/java/com/nuodb/migrator/backup/writer/BackupWriter.java
@@ -246,7 +246,7 @@ public class BackupWriter {
     }
     protected InspectionScope getInspectionScope() {
-        return new TableInspectionScope(sourceSpec.getCatalog(), sourceSpec.getSchema(), getTableTypes());
+        return new TableInspectionScope(sourceSpec.getCatalog(), sourceSpec.getSchema(), "T1");
     }
     protected BackupWriterManager createBackupWriterManager(BackupOps backupOps, Map context) throws Exception {