Is there a way to speed up crawling SQL Server Management Objects on an existing database?

I am currently using SMO and C # to navigate databases to create a settings tree representing the various aspects of the two databases, and then compare these trees to see where and how they differ.

The problem is that for 2 databases with a reasonable size, it takes almost 10 minutes to go around them locally and collect the table / column / stored procedure information that I want to compare.

Is there a more convenient interface than SMO for accessing databases in this way? I would not want to include any additional dependencies, but I will take this pain to improve speed by 50%. The following is an example of how I list tables and columns.

        Microsoft.SqlServer.Management.Smo.Database db = db_in;
        foreach (Table t in db.Tables)
        {
            if (t.IsSystemObject == false)
            {

                foreach (Column c in t.Columns)
                {
                }                    
            }
        }
+3
3

SMO , . . .


EDIT: , archive.org. :

Server server = new Server();

// Force IsSystemObject to be returned by default.
server.SetDefaultInitFields(typeof(StoredProcedure), "IsSystemObject");

StoredProcedureCollection storedProcedures = server.Databases["AdventureWorks"].StoredProcedures;

foreach (StoredProcedure sp in storedProcedures) {
    if (!sp.IsSystemObject) {
        // We only want user stored procedures
    }
}
+4

, TSQL. , , .

0

All Articles