LessThanDot Site Logo

LessThanDot

A decade of helpful technical content

This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.

Hiding Outages is a Short Term Game

5:20 PM on Saturday night, looking for the correct size air filter at the local superstore. My phone dings and chirps, as I receive almost simultaneous email and twitter alerts; our production application can’t talk to it’s database. As a SaaS company, it rolls downhill. An unexpected outage with our application means an unexpected service outage for our customers. Time to head home and start troubleshooting. 5:45 PM. After logging into the service provider dashboard, I find that the database services tab is completely non-functional. Attempts to connect to the database from home also fails. Various other troubleshooting directions are followed and also meet in failure.

Read More...

I'm An Author! "Pro SQL Server 2012 Practices" Releases October 31

One of my bucket list items has always been “publish a book”. Little did I know that I would get to cross that off my list in 2012. I’m excited to announce that I have co-authored a book, Pro SQL Server 2012 Practices, and it will be available on October 31, 2012! "Pro SQL Server Practices 2012 Edition is an anthology of high-end wisdom from a group of accomplished database administrators who are quietly but relentlessly pushing the performance and feature envelope of Microsoft SQL Server 2012. With an emphasis upon performance—but also branching into release management, auditing, and other issues—the book helps you deliver the most value for your company's investment in Microsoft's flagship database system. "

Read More...

Cheers to Tech on Tap v1.3 PowerShell!

Tech on Tap v1.3 PowerShell was held on October 13. This was our third and final event for the year, and it was every bit as great as the first two. PowerShell The focus of this event was PowerShell. What is it? How can I use it? What do I need to know to get started? We got an overview of Powershell from Brian Lewis of Microsoft. Then Steve Murawski, PowerShell MVP, gave us practical everyday examples and scripts. Adam Driscoll from Quest showed off Powershell 3.0, which has some really neat enhancements.

Read More...

An update on the Piglet perfomance tests.

In my previous post I did [a few performance tests][1] with piglet. And with all performance related things, I was doing it wrong. I was mainly doing it wrong because I don’t really know how Piglet works. But the person who knows Piglet best came to the rescue. You shouldn’t really construct the parser anew for each parse. The parser is reusable, so build the parser from the grammar only once and you can then call Parse repeatedly. Building the parser is a very labour intensive task, especially compressing the parse tables takes quite a while. Running the parser is fast, it should run in near constant time per input character.

Read More...

Parsing text with Piglet: making all the tests pass

[Yesterday][1] I showed you how we made the first two tests pass. And I also told you that Per Dervall helped to solve the rest. I asked the question on [StackOverflow][2]. And I also pinged him about this on twitter. And the poor man made an effort to respond in VB.Net. And in short, this is the result. Public Class ParseLatinPlantName Public Function Parse(ByVal name As String) As Plant Dim config = ParserFactory.Fluent() Dim expr = config.Rule() Dim subSpecies = config.Rule() Dim hybridIndicator = config.Expression hybridIndicator.ThatMatches("x").AndReturns(Function(f) f) Dim sp = config.Expression() sp.ThatMatches("sp.").AndReturns(Function(f) f) Dim name1 = config.Expression() name1.ThatMatches("w+").AndReturns(Function(f) f) Dim nothing1 = config.Rule() expr.IsMadeUp.By(name1).As("Genus") _ .Followed.By(name1).As("Species") _ .Followed.By(subSpecies).As("Subspecies") _ .WhenFound(Function(f) New Plant With {.Genus = f.Genus, .Species = f.Species, .SubSpecies = f.Subspecies}) _ .Or.By(name1).As("FirstSpecies").Followed.By(hybridIndicator).Followed.By(name1).As("SecondSpecies") _ .WhenFound(Function(f) New Plant With {.IsHybrid = True}) subSpecies.IsMadeUp.By(sp).Followed.By(name1).As("Subspecies").WhenFound(Function(f) f.Subspecies) _ .Or.By(nothing1) Dim parser = config.CreateParser() Dim result = DirectCast(parser.Parse(name), Plant) Return result End Function End Class``` And here is the C# code. ```csharp public Plant Parse(string input) { var config = ParserFactory.Fluent(); var expr = config.Rule(); var subSpecies = config.Rule(); var hybridIndicator = config.Expression(); hybridIndicator.ThatMatches("x").AndReturns(f => f); var sp = config.Expression(); sp.ThatMatches("sp\.").AndReturns(f => f); var name1 = config.Expression(); name1.ThatMatches("\w+").AndReturns(f => f); var nothing1 = config.Rule(); expr.IsMadeUp.By(name1).As("Genus") .Followed.By(name1).As("Species") .Followed.By(subSpecies).As("Subspecies") .WhenFound(f => new Plant {Genus = f.Genus, Species = f.Species, SubSpecies = f.Subspecies}) .Or.By(name1).As("FirstSpecies").Followed.By(hybridIndicator).Followed.By(name1).As("SecondSpecies") .WhenFound(f => new Plant {IsHybrid = true}); subSpecies.IsMadeUp.By(sp).Followed.By(name1).As("Subspecies").WhenFound(f => f.Subspecies) .Or.By(nothing1); var parser = config.CreateParser(); var result = (Plant) parser.Parse(input); return result; } }``` I won’t repeat the explanation here, I will leave that on SO. But I did a few performance tests. Nothing very official. Just good to know. ```csharp [Test] public void SpeedTest() { var parser = new ParseLatinPlantName(); Plant result; for(int i =0; i < 10000; i++) { result = parser.Parse("Salvia x jamensis"); } }``` Ncrunch tells me the for loop takes 20.717 seconds. And then I did this. ```csharp var parser = new ParseLatinPlantName(); Plant result; for(int i =0; i < 10000; i++) { result = parser.Parse("Salvia x jamensis"); } for (int i = 0; i < 10000; i++) { result = parser.Parse("Salvia jamensis"); } for (int i = 0; i < 10000; i++) { result = parser.Parse("Salvia jamensis sp. something"); }``` The first for takes around 20 seconds the second around 25 and the third around 13 seconds. I let you draw your own conlcusions on why that is. I think Piglet is very cool and can be useful The fluent code is very readable. The biggest problem so far is a lack of documentation. But it can only get better. [1]: /index.php/DesktopDev/MSTech/parsing-text-with-piglet-making [2]: http://stackoverflow.com/questions/13027171/parsing-latin-plant-names-with-piglet-fluent-configuration

Read More...

My PASS Summit Packing List

It’s almost here! It’s almost here! The world’s largest SQL Server conference kicks off in a few days. I’ll be in Seattle with thousands of other database professionals, soaking up knowledge, meeting new people, and spending time with my #sqlfamily. I realized this morning that I’ll have to start packing in a few days. Yes, I try to do this a few days in advance, instead of the night before, just in case I forget something. Then, I started thinking, “I should probably tell my First Timers what I’m bringing, so they don’t forget something important.” Then I had a better thought: “I could blog it and share it with the world.”

Read More...

Parsing text with Piglet making the first tests pass

Introduction Yesterday [RandomPunter][1] mentioned [Piglet][2] on Twitter. According to the site Piglet is: Piglet, the little friendly parser and lexer tool Piglet is a library for lexing and parsing text, in the spirit of those big parser and lexer genererators such as bison, antlr and flex. While not as feature packed as those, it is also a whole lot leaner and much easier to understand. Today I had some time and set out to see what this is all about. I never used a parser like this before so the learning curve would be high.

Read More...

Book Review: SQL Server Hardware

It’s bookworm time again! Since I’m back in the throes of half marathon training, there’s been less time for me to grab a cup of coffee and read a book each morning, but I’m making time for it when I can. My latest geek read was SQL Server Hardware by Glenn Berry (blog | twitter). This book is designed to help anyone who needs to build or troubleshoot a SQL Server system understand different processors and storage available, how to benchmark the hardware, and the differences in versions and editions of SQL Server.

Read More...

Why is it important to know that using has no empty catch and check for null in the finally?

Introduction In my previous post I examined what the Using code does. And why the 2005 version of the MSDN article might have been wrong. But why is it important to know that Using is not using a catch? The catch Here is the code that we saw in the article. Dim s2 = New FileStream("test2", FileMode.Create) Try Console.WriteLine("before exception") Throw New Exception() Console.WriteLine("after exception") Catch ex As Exception Finally s2.Dispose() End Try The above code will just go merrily on it’s way, it won’t really stop and it is swallowing the exception. The user of that code does not know something bad happened and thinks everything is just fine. The user does not know there is a line after the exception he was supposed to get. He is blissfully unaware.

Read More...

What does the Using statement do?

Introduction Yesterday there was [a question on the VBIB][1] forum on what the Using statement does and I answered it. But before going on I checked if I was right by looking at [this MSDN article about Using][2]. And it states. ' THE FOLLOWING TRY CONSTRUCTION IS EQUIVALENT TO THE USING BLOCK Dim resource As New resourceType Try ' Insert code to work with resource. Catch ex As Exception ' Insert code to process exception. Finally ' Insert code to do additional processing before disposing of resource. resource.Dispose() End Try ``` That is the 2005 version of that article. The 2010 and 2012 version seem to have a different opinion. ```vbnet ' For the acquisition and disposal of resource, the following ' Try construction is equivalent to the Using block. Dim resource As New resourceType Try ' Insert code to work with resource. Finally If resource IsNot Nothing Then resource.Dispose() End If End Try ``` Another user of VBIB corrected this saying that there is no catch. So I set out to check and downloaded [Teleriks JustDecompiler][3]. ## TestData First thing I did was to create a project. with this snippet in it. ```vbnet Imports System.IO Module Module1 Sub Main() Using s1 = New FileStream("test1", FileMode.Create) End Using End Sub End Module Decompilation And I then decompiled that.

Read More...