smo table script generation performance problem

  • Hello,

    I'm currently working on program for database compare. In this program I need to create scripts for databse objects. i found out that script generation is too slow but generating scripts using SSMS it's pretty fast. In one thread I have found, that SSMS uses for script generation SMO, but I couldn't find any suggestions for performance improvement.

    Collapse

    Server srv = new Server(new ServerConnection("SERVER", "USERID", "PASSWORD"));

    srv.SetDefaultInitFields(typeof(Table), true);

    Database db = srv.Databases[database];

    ScriptingOptions so = new ScriptingOptions();

    so.AllowSystemObjects = false;

    .

    .

    .

    db.PrefetchObjects(typeof(Table),so);

    .

    .

    .

    foreach(Table tb in db.Tables)

    {

    StringCollection sc = tb.Script();

    .

    .

    .

    }

    Interesting is that db.PrefetchObjects(typeof(Table),so) has almost no effect for script generatino of tables, but is rapidly

    increases script generation of stored procedures.

    Can someone explain me, what kind of mechnizm SSMS uses for script generation, or is top secret informacion? 😛

    Regards

    Robert

  • Hi kanasz.robert,

    What you are tolking about puzzles me for a long time. :crying:

    keep watching.

    tks

  • Hello,

    According http://msdn.microsoft.com/en-us/library/ms210376(v=SQL.100).aspx , i have seen

    "You can use this method to adjust which properties are initialized for an object when it is first created to further optimize performance". I think that SetDefaultInitFields is useful only when we create a new object like Table, StoredProcedure but it is useless to access an existing object like in your case ( you cannot generate a generation script versus an not existing object ).

    I have to do some tests as my last ones were versus SQL Server 2005 .

    Have a nice day

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply