Question

I'm using the Microsoft.Data.Schema.ScriptDom and Microsoft.Data.Schema.ScriptDom.Sql libraries to parse SQL and add "TOP #" to SQL select statements. We do this to limit the result set in certain situations.

I just getting started using the library and I've noticed that parsing the SQL is not exactly fast. I've not instrumented the code to actually measure the speed but it is noticeable, between half to a whole second. Which is not terrible but I would not call it fast either.

My code looks like this:

  var Parser = new TSql100Parser(true);      
  TextReader reader = new StringReader(sql);
  IList<ParseError> errors;
  var fragments = Parser.Parse(reader, out errors);

I've googled this and not found any complaints about speed so I'm wondering if I'm doing something wrong.

Was it helpful?

Solution

It seems that Microsoft's library is not what you would call fast. I've done some more google searches and I'm not the only one to see this issue. There are some alternatives out there if you really need to parse SQL. They don't have the features of Microsoft's library but they seem to perform well.

Gold Parsing System

Poor Man's T-SQL Formatter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top