<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Isaac @ MSDN</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/isaac/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/isaac/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:14:15 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>StreamInsight 2012 on Academy Live</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/streaminsight-2012-on-academy-live</link>
      <pubDate>Thu, 08 Mar 2012 02:30:00 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2012/03/08/streaminsight-2012-on-academy-live/</guid>
      <description><![CDATA[Hi Folks,
As part of the SQL Server 2012 launch, I've contributed a presentation on StreamInsight...]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,</p>
<p>As part of the SQL Server 2012 launch, I've contributed a presentation on StreamInsight 2.0, which is available either on <a title="TechNet" href="https://technet.microsoft.com/en-us/edge/Video/hh858466">TechNet </a>or the <a title="Academy Live" href="https://www.microsoftvirtualacademy.com/tracks/breakthrough-insights-using-microsoft-sql-server-2012-scalable-data-warehouse">Microsoft Virtual Academy</a>.</p>
<p>You can get the code associated with the video here <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/55/34/AcadLive2012Demo/2703.Demo.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-34-AcadLive2012Demo/2703.Demo.zip">code</a>.</p>
<p>Enjoy!<br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>Map Projections</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/map-projections</link>
      <pubDate>Mon, 14 Nov 2011 10:43:25 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2011/11/14/map-projections/</guid>
      <description><![CDATA[Cute!  Although I’m guessing that people who really are into maps have a slightly higher view of...]]></description>
      <content:encoded><![CDATA[<p><a href="https://xkcd.com/977/">Cute!</a></p>  <p>Although I’m guessing that people who really are into maps have a slightly higher view of Mercator than he implies.</p>  <p>Cheers,   <br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>PASS Wrap-Up</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/pass-wrap-up</link>
      <pubDate>Mon, 17 Oct 2011 13:46:24 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2011/10/17/pass-wrap-up/</guid>
      <description><![CDATA[Hi Folks,  I just wrapped up my talk the 2011 PASS Summit. Here are a few quick thoughts:...]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,</p>  <p>I just wrapped up my <a href="https://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SessionDetail.aspx?sid=1911">talk</a> the <a href="https://www.sqlpass.org/summit/2011/">2011 PASS Summit</a>. Here are a few quick thoughts:</p>  <p>StreamInsight seems like a technology that could benefit a large number of customers, for a large number of scenarios. But relatively few people even know what SI can do. So although the title of my talks was, “What’s new in Microsoft StreamInsight?”, I turned it into more of a dev-ish, “What the Heck is StreamInsight?” This <em>seemed</em> successful: people seemed attentive; I got a lot of good questions; very few people waked out—all good signs. I’ll see what the session feedback looks like, and if you have any comments, please paste them here or shoot me an email. I’ll be talking again at <a href="https://devconnections.com/shows/fall2011/default.aspx?s=179">Connections</a>, and want to use all the feedback I can to refine that talk.</p>  <p>I promised folks at the talk that I’d post my code. I’ve cleaned it up a little—added comments and some copyright info to save myself from our legal department—but it really is the code I used during the talk. Hopefully both of these will show up with <a href="https://www.sqlpass.org/summit/2011/Speakers/CallForSpeakers/SessionDetail.aspx?sid=1911">the talk</a> on the PASS website, but you can also download my code <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/55/34/PASS2011Demo/1665.PASS%20Demo.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-55-34-PASS2011Demo/1665.PASS-Demo.zip">here</a>.</p>  <p>One final thought: I’ve underestimated how hard it would be to get back in the blogging groove. But I’ll keep trying.</p>  <p>Cheers,    <br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>Alastair on Spatiotemporal with StreamInsight</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/alastair-on-spatiotemporal-with-streaminsight</link>
      <pubDate>Fri, 05 Aug 2011 11:16:00 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2011/08/05/alastair-on-spatiotemporal-with-streaminsight/</guid>
      <description><![CDATA[Alastair Aitchison has started a series on doing spatiotemporal analysis using StreamInsight and the...]]></description>
      <content:encoded><![CDATA[<p>Alastair Aitchison has <a href="https://alastaira.wordpress.com/2011/07/31/spatio-temporal-event-processing-with-streaminsight-sql-server-denali-and-bing-maps-part-1/">started a series</a> on doing spatiotemporal analysis using StreamInsight and the SQL Server spatial library over on his <a href="https://alastaira.wordpress.com/">blog</a>. I&rsquo;ll certainly be watching how he makes out.</p>
<p>To answer one question he asks in his post: StreamInsight doesn&rsquo;t <em>require </em>SQL Server Compact, but if you use it for you use it for your <a href="https://msdn.microsoft.com/en-us/library/ff518478.aspx">metadata provider</a>, then the server metadata (applications, queries, and the like) will be persisted across restarts. This is required if you want to use <a href="https://blogs.msdn.com/b/isaac/archive/2011/07/25/introducing-checkpointing-in-streaminsight-1-2.aspx">resiliency</a> for fairly obvious reasons.</p>
<p>Cheers, <br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>Introducing Checkpointing in StreamInsight 1.2</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/introducing-checkpointing-in-streaminsight-1-2</link>
      <pubDate>Mon, 25 Jul 2011 00:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2011/07/25/introducing-checkpointing-in-streaminsight-1-2/</guid>
      <description><![CDATA[Hi Folks,
As I mentioned some a few posts ago, I recently made a move to the StreamInsight team....]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,</p>
<p>As I mentioned some a few posts ago, I recently made a move to the StreamInsight team. Well, we&rsquo;ve just released the new version, StreamInsight 1.2, so it&rsquo;s time to start talking about what we&rsquo;ve been up to.</p>
<p>One of the big features in the new version is resiliency, which helps you build highly available systems that use StreamInsight. This post gives a high-level, no-code overview of what this functionality does and how it can be used. More detailed posts will follow.</p>
<p>To motivate the feature, consider a few use cases:</p>
<ol>
<li>You have a query that consumes sensor data&mdash;say the temperature of a machine&mdash;and computes the average temperature over the last day. It&rsquo;s not the end of the world if StreamInsight were to miss a few minutes of data: the missed events will likely have little impact on the overall average. But if these missed events were caused by an outage, you do care (a) that your app comes back up quickly, (b) that you don&rsquo;t lose the substantial state that was built up for the aggregation, and (c) that the results you get when SI comes back up are <em>close </em>to what you would have gotten had SI not gone down.</li>
</ol><ol start="2">
<li>You have a query that consumes Twitter data and sends you email every time someone mentions <a href="https://en.wikipedia.org/wiki/Justin_bieber">Justin Bieber</a>. For this query, you have the same requirement (a) for speedy recovery as above, but (b) and (c) are no longer sufficient: you really don&rsquo;t want to miss an important alert should StreamInsight go down. On the other hand, you don't mind getting duplicate alerts. I.e., you want the <em>same</em> events you would have gotten without the outage&mdash;perhaps with some duplicates.</li>
</ol><ol start="3">
<li>You have a query that consumes stock price data, and produces trade events based on some secret algorithm. Now you have all of the requirements from the Bieber-bot&mdash;fast recovery, equivalent events&mdash;but now it could be catastrophic if you got duplicate trades. I.e., you want completely equivalent outputs whether or not there was an outage.</li>
</ol>
<p>The form of resiliency introduced in StreamInsight 1.2 allows SI to take and restore checkpoints. A checkpoint is a serialized form of all of the internal state SI keeps for a query. When SI restarts, it will automatically restart a previously-running query and restore its state from the checkpoint, effectively putting the query at a known point when the checkpoint was taken.</p>
<p>You can control when checkpoints are taken: take them more frequently and you&rsquo;ll lose less in a crash; take them less frequently and you&rsquo;ll keep the impact on the system low. Let&rsquo;s consider how this would be used in our first use case:</p>
<ol>
<li>Your query is happily chugging along, and you&rsquo;re asking the system to take a checkpoint every five minutes. At some time&mdash;say 12:59&mdash;some <a href="https://smurfs.wikia.com/wiki/Clumsy_Smurf">doofus</a> trips on the power cord of the machine and brings it down. Realizing what he&rsquo;s done, he plugs it back in and restarts everything. At 1:05 everything&rsquo;s ready and he restarts StreamInsight, which reads back the latest checkpoint from 12:55 and is ready to start accepting events again at 1:07. <br /> <br />In this case, SI was down from 12:59 to 1:07, and all events that should have been received during this time were lost. In addition, all events received between 12:55 and 12:59 were effectively lost as well, since they weren&rsquo;t recorded in the last checkpoint before the system went down. These lost input events may cause missed output events, and can also affect aggregate results that overlap the outage. Still, you&rsquo;re happy because the system is back up, you&rsquo;ve only lost 12 minutes of data, and your long-term aggregates are roughly intact.</li>
</ol>
<p>Perhaps all of this is fine for a silly temperature reading, but what if someone were to tweet a Bieber sighting during the outage? To avoid missing this critical information, StreamInsight needs some help: something needs to keep track of the events that occurred during the outage, as well as those that occurred before the outage but after the last checkpoint, and be ready to send them along when SI comes back up.</p>
<p>That something is the input adapter&mdash;or more properly, whatever the input adapter is connected to. In other words, there has to be a component sitting in front of StreamInsight that keeps track of recent events and can replay them for SI. And this component has to be independent and highly available as well.</p>
<p>If we have this in place, we&rsquo;re ready to tackle our second use case:</p>
<ol start="2">
<li>Your query is happily Biebering along, taking checkpoints every minute, but you have a historian sitting in front of your query. This historian is pulling tweets from Twitter and persisting them before sending them on to StreamInsight. As before, our doofus trips over the cable at 12:59 and restarts StreamInsight at 1:05. But now as part of its recovery routine, SI will ask its input adapter to replay the event it&rsquo;s missed and the historian will guarantee that SI will see all that it has missed since 12:55 when it took its last checkpoint. <br /> <br />And this is great: StreamInsight came back, and you haven&rsquo;t missed a thing. But you notice something funny: the report of Justin&rsquo;s new coif that issued at 12:57 came through twice. Once before the outage, and once after. Why? Because SI forgot that it issued that event before the outage, and when the events replayed, it got issued again.</li>
</ol>
<p>And that&rsquo;s not bad. Unless events have consequences&mdash;which is certainly the case with stock trades. To eliminate these duplicates, StreamInsight needs a little more help, this time on the output. As SI produces events, the output adapter&mdash;again, more properly, whatever the output adapter is connected to&mdash;has to remember them.</p>
<p>When StreamInsight comes back up after an outage, it will essentially tell its output adapters the last time it remembers. It also guarantees that every event that it produced after that time will be produced again. Since the output adapter knows what these events were, it can remove the duplicates when it sees them instead of acting on them. And this is what we need in our third use case:</p>
<ol start="3">
<li lt="" li="">Your query is happily trading away, taking checkpoints every minute. You also have a historian in front of the query recoding stock prices, and a historian on the end recording trades. As before our doofus&mdash;who we have somehow failed to fire&mdash;trips over the cable at 12:59 and restarts things at 1:05. During recovery, StreamInsight gets the input to replay all stock info since 12:55, so no input is missed. It also notifies its output that all trades that happened between 12:55 and the outage will be sent again, so when the duplicate trades are issued, the output adapter just drops them on the floor. <br /> <br />And now we have full stream equivalence. You don&rsquo;t miss a trade, and you don&rsquo;t get any duplicates.</li>
</ol>
<p>Hopefully this gives a feel of what&rsquo;s possible with checkpointing. I&rsquo;ll have more to say on specifics over the next few weeks. In the meantime, be sure to pick up <a href="https://www.microsoft.com/download/en/details.aspx?id=26720">the release</a>&nbsp;and take a look at the <a href="https://msdn.microsoft.com/en-us/library/ee828711.aspx">documentation</a>. And there&rsquo;s a full end-to-end demo available on <a href="https://streaminsight.codeplex.com/releases/view/46435">CodePlex</a> as well.</p>
<p>Cheers, <br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>The Database Shuffle</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/the-database-shuffle</link>
      <pubDate>Wed, 20 Apr 2011 09:56:00 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2011/04/20/the-database-shuffle/</guid>
      <description><![CDATA[Hi Folks,
As I mentioned in my previous post, I recently moved from my old home in the SQL Server...]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,</p>
<p>As I mentioned in my <a href="https://blogs.msdn.com/b/isaac/archive/2011/03/31/it-s-alive.aspx">previous post</a>, I recently moved from my old home in the SQL Server engine to the <a href="https://www.microsoft.com/sqlserver/2008/en/us/R2-complex-event.aspx">StreamInsight</a> team. As I continue to ramp up here, I want to take a few posts to talk about what I was working on back in the engine: the <a href="https://msdn.microsoft.com/en-us/library/ff929071%28SQL.110%29.aspx">contained database</a>.</p>
<p>To illustrate the problem contained databases are intended to solve, let&rsquo;s consider a simple scenario: I take a database <em>D</em> that lives on server <em>S</em>, detach it, and attach it to server <em>T</em>:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/55/34/metablogapi/7737.image_2AB0EED7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-55-34-metablogapi/7737.image_5F00_2AB0EED7.png"><img height="128" width="290" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/55/34/metablogapi/7713.image_thumb_7A59F453.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-55-34-metablogapi/7713.image_5F00_thumb_5F00_7A59F453.png" alt="image" border="0" title="image" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" /></a></p>
<p>This is one example of database movement, but there are many movement scenarios&mdash;recovery, upgrade, load balancing, consolidation, moves to production&mdash;and many movement techniques&mdash;backup/restore, detach/attach, mirroring. But how well do these techniques satisfy the scenarios?</p>
<p>In a word: poorly. As an illustrative example, let&rsquo;s take a look at what happens with authentication. </p>
<p><a href="https://msdn.microsoft.com/en-us/library/bb510418.aspx">SQL Server security</a> is a little complex, but for our purposes it&rsquo;s enough to consider two core artifacts: <em>logins </em>and <em>users.</em> Logins are instance-level objects (stored in master) and users are database-level objects (stored in the user database). Each of these are responsible for <em>authorization</em> in their respective domains, i.e., used to grant permissions at the instance and at the database respectively. But only logins are used for <em>authentication.</em> So in order to even log on to the server you have to have a login. </p>
<p>Users and logins are associated with each other through a matching identifier called a <em>SID</em>, and in order for a person to connect to and use a database, he must have a user in the target database and matching login on the instance. And here&rsquo;s where our problem comes from: while users are stored in and move with the database, logins are not and do not. They&rsquo;re left behind:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/55/34/metablogapi/4111.image_454D6523.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-55-34-metablogapi/4111.image_5F00_454D6523.png"><img height="128" width="445" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/55/34/metablogapi/1462.image_thumb_1A08CE1C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-55-34-metablogapi/1462.image_5F00_thumb_5F00_1A08CE1C.png" alt="image" border="0" title="image" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" /></a></p>
<p>The result of this is that someone who could connect to <em>D </em>when it lived on <em>S</em> may no longer be able to do so when it moves to <em>T</em> because their login is missing. This is reparable, of course: you just need to <em>manually</em> add the required logins to the new instance. It&rsquo;s also not easily automatable, since the target instance may already have a different login with the same name, which would cause a collision.</p>
<p>Were this only a problem for logins, we&rsquo;d have one nit to work around. But of course it isn&rsquo;t. The same applies to any other server-scoped object on which the database depends: agent jobs, error messages, linked servers, etc.</p>
<p>I&rsquo;m going to blow my punch line here: we solved <span style="text-decoration: line-through;">this</span> the authentication problem with contained databases. But before moving on to the details, I&rsquo;m going to touch on some more subtle problems. In particular, collations. Stay tuned.</p>
<p>Cheers, <br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>It’s Alive!</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/its-alive</link>
      <pubDate>Wed, 30 Mar 2011 16:46:13 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2011/03/30/its-alive/</guid>
      <description><![CDATA[Hi Folks,  Many years ago I kicked up this blog. It started with a trickle of general posts on SQL...]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,</p>  <p>Many years ago I kicked up this blog. It started with a trickle of general posts on SQL Server programmability topics. As our spatial support took off, it was quickly consumed by spatial-related posts.</p>  <p>And then it languished…</p>  <p>…and now its back. Let me quickly explain via a quick Q&amp;A with myself:</p>  <p><strong>Where did you go?</strong></p>  <p>Through the 2008 release, I was the program manager for spatial. I led spatial projects, thought spatial thoughts, and dreamt spatial… well only occasionally. In any case, as we ramped up the next release, I started working on what we now call “<a href="https://msdn.microsoft.com/en-us/library/ff929071%28SQL.110%29.aspx">contained databases</a>”. Since these weren’t public yet, I couldn’t say too much to say about them. And since I wasn’t involved so much in spatial, I didn’t have so much to say there, either.</p>  <p><strong>Why are you back?</strong></p>  <p>After spending six years in the SQL Server engine, I’ve taken a new job. I am now a program manager with <a href="https://www.microsoft.com/sqlserver/2008/en/us/R2-complex-event.aspx">StreamInsight</a>. And with this new adventure comes a renewed vigor on the blogging front.</p>  <p><strong>What is this blog about now?</strong></p>  <p>Since most of what I’m working on is centered around StreamInsight, StreamInsight would be a good guess. I’ll probably have a thing or two to say about contained databases as well. And heck, I may even do some spatial.</p>  <p>Stick around and we’ll find out.</p>  <p>Cheers,   <br />-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>Filter: One Odd Duck</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/filter-one-odd-duck</link>
      <pubDate>Thu, 04 Mar 2010 07:57:00 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2010/03/04/filter-one-odd-duck/</guid>
      <description><![CDATA[Hi Folks,
Over at his blog, Nicklas Avéns questions the behavior of Filter. He's right: Filter is a...]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,
</p><p>Over at his <a href="https://blog.jordogskog.no/2010/02/27/strange-behavior-by-design-of-the-spatial-function-filter-in-sql-server-2008/"><span style="color:#669966; text-decoration:underline">blog</span></a>, Nicklas Avéns questions the behavior of Filter. He's right: Filter is a little odd. It is also very much by design. 
</p><p>Before we look at filter, let's review the data flow for a typical spatial query. A spatial selection generally has two internal components: a primary filter, which is designed to be fast, but which may produce extra results; and a secondary filter, which is slower, but only works to remove the false positives passed by the primary filter. 
</p><p>The primary filter is accomplished by using the spatial index. The secondary filter requires calls to actual geometry routines, and will be much more expensive. But the secondary filter also guarantees index-independent—and geometrically correct—results.
</p><p>Without an index, most operations will just skip the primary filter. The result is slow, but returns the same results as the full primary–secondary pathway.
</p><p>Filter is designed for a pretty common, but somewhat odd use case. Imagine that you want to display a portion of a map: you want to retrieve from the database those objects that would show on the map, but if you happen to retrieve a few extras you don't care—they'll just fall off the display.
</p><p>In other words, false positives are okay. In fact, they're often preferred, because the overall performance is can be much better if you can skip the expensive geometry operations and instead render some additional objects.
</p><p>So we added Filter, which simply skips the secondary filter and gives you the quick index-only results.
</p><p>But what if you don't have an index? We had two choices, either (a) return an error, or (b) revert to STIntersects. Note that both of these options have index-dependent behavior: that ship sailed when we decided to skip the secondary filter.
</p><p>We chose to allow the operation, but revert to STIntersects in the non-indexed case. This gives us <em>clear</em> semantics: the correct results are always a subset of what we return. It's true that for SQL Server, these are somewhat <em>odd </em>semantics, since they are index-dependent.
</p><p>But this is the <em>only </em>place in spatial where we have such behavior. If you want consistent results regardless of index, use STIntersects or any of the other methods we provide. If your use case fits the one I described above, you may very well want Filter.
</p><p>Call it useful, call it odd. Call it Filter.
</p><p>Cheers,<br/>-Isaac</p>]]></content:encoded>
    </item>
    <item>
      <title>Spatial Data Type Structure</title>
      <link>https://docs.microsoft.com/archive/blogs/isaac/spatial-data-type-structure</link>
      <pubDate>Mon, 10 Aug 2009 12:38:25 GMT</pubDate>
      <dc:creator><![CDATA[Isaac Kunen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/isaac/2009/08/10/spatial-data-type-structure/</guid>
      <description><![CDATA[Hi Folks,  As part of a larger effort to document our protocols, SQL Server has just released...]]></description>
      <content:encoded><![CDATA[<p>Hi Folks,</p>  <p>As part of a <a href="https://msdn.microsoft.com/en-us/library/ee209073.aspx">larger effort</a> to document our protocols, SQL Server has just released <a href="https://msdn.microsoft.com/en-us/library/ee320529.aspx">documentation</a> on the structure of our spatial types.&#160; The document is also available in <a href="https://download.microsoft.com/download/7/9/3/79326E29-1E2E-45EE-AA73-74043587B17D/%5BMS-SSCLRT%5D.pdf">PDF</a>.&#160; Note that all of this is preliminary, and while I doubt it will change much, it could.&#160; I had very little to do with this effort; you have <a href="https://blogs.msdn.com/edkatibah">Ed</a> to thank.</p>  <p>It turns out that this structure is pretty simple, and there are folks out there who have fairly easily reverse-engineered it.&#160; Now that we’re publishing the structure, let me make one very specific warning: if you are going to play around with the binary format, <em>do not set the valid bit (v) unless you’re absolutely sure the object is valid.</em></p>  <p>Setting this should not cause SQL Server itself any problems: you won’t crash anything.&#160; We just can’t guarantee that you’ll get the most predictable results.&#160; And things get very difficult to fix.</p>  <p>Let’s work an example.&#160; Consider the following linestring: LINESTRING (0 0, 10 0, 5 0, 10 0).&#160; This is clearly invalid according to the OGC, since it overlaps itself.&#160; We can put this into a geometry element and play with it:</p>  <blockquote>   <div class="csharpcode">     <pre class="alt"><span class="kwrd">declare</span> @g geometry = <span class="str">'LINESTRING (0 0, 10 0, 5 0, 10 0)'</span></pre>

    <pre><span class="kwrd">select</span> @g.STIsValid()            <span class="rem">-- 0</span></pre>

    <pre class="alt"><span class="kwrd">select</span> @g.MakeValid().STLength() <span class="rem">-- 10</span></pre>
  </div>
</blockquote>
<style type="text/css">

















.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>We can’t run the STLength() without first making the object valid or we’ll get an error.&#160; We can now pull out the binary version of this to play with:</p>

<blockquote>
  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">select</span> @g</pre>
  </div>
</blockquote>
<style type="text/css">











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>And we get:</p>

<blockquote>
  <div class="csharpcode">
    <pre class="alt">0x0000000001<font style="background-color: yellow">00</font>040000000000000000000000000000000000000000000000000024400000000000000000000000000000144000000000000000000000000000002440000000000000000001000000010000000001000000FFFFFFFF0000000002</pre>
  </div>
</blockquote>
<style type="text/css">











.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>We’re particularly interested in the highlighted byte, which contains a number of flags, all currently false.&#160; Most of these aren’t particularly dangerous to play with.&#160; For example, the lowest-order bit tells SQL Server that the item contains Z values.&#160; If you flip it, you’ll just end up with an error, since the data that follows doesn’t actually contain any Z values:</p>

<blockquote>
  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">declare</span> @g geometry = 0x0000000001<font style="background-color: yellow">01</font>040000000000000000000000000000000000000000000000000024400000000000000000000000000000144000000000000000000000000000002440000000000000000001000000010000000001000000FFFFFFFF0000000002</pre>

    <pre>&#160;</pre>

    <pre class="alt">Msg 6522, <span class="kwrd">Level</span> 16, <span class="kwrd">State</span> 1, Line 1</pre>

    <pre>A .NET Framework error occurred during execution of user-defined routine or aggregate &quot;geometry&quot;: </pre>

    <pre class="alt">System.IO.EndOfStreamException: Unable to read beyond the end of the stream.</pre>
  </div>
</blockquote>
<style type="text/css">












.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>The valid bit, the third-least significant, is a little touchy, though.&#160; Let’s see what happens if we flip that on our instance and run a few operations:</p>

<blockquote>
  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">declare</span> @g geometry = 0x0000000001<font style="background-color: yellow">04</font>040000000000000000000000000000000000000000000000000024400000000000000000000000000000144000000000000000000000000000002440000000000000000001000000010000000001000000FFFFFFFF0000000002</pre>

    <pre><span class="kwrd">select</span> @g.STIsValid()  <span class="rem">-- 1</span></pre>

    <pre class="alt"><span class="kwrd">select</span> @g.STLength()   <span class="rem">-- 20</span></pre>
  </div>
</blockquote>
<style type="text/css">










.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>What’s happening?&#160; First, the system is trusting the bit and telling us that the instance is valid.&#160; This shouldn’t be too surprising: the bit was added so that we wouldn’t have to perform an expensive check every time we check the validity, and we’re using the optimization.</p>

<p>Second, the result of the STLength() operation is a bit odd.&#160; It’s calculating the length used to draw the invalid object, not the length of the object itself.</p>

<p>Okay, you say: let’s make this instance valid and see if we can fix things:</p>

<blockquote>
  <div class="csharpcode">
    <pre class="alt"><span class="kwrd">declare</span> @h geometry = @g.MakeValid()</pre>

    <pre><span class="kwrd">select</span> @h.STLength()  <span class="rem">-- 20</span></pre>

    <pre class="alt"><span class="kwrd">select</span> @h.ToString()  <span class="rem">-- LINESTRING (0 0, 10 0, 5 0, 10 0)<span></pre>
  </div>
</blockquote>
<style type="text/css">







.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Ack!&#160; We’re trapped.&#160; MakeValid() tries to preserve the input geometry whenever possible, and therefore refuses to touch a valid instance.&#160; Our instance isn’t actually valid, but we said it was.</p>

<p>So if you’re creating a geometry from scratch, how are you to know how to set this bit?&#160; That is, how on Earth do you figure out if an instance is valid?&#160; Unless you’re absolutely sure, let the system do it for you: tell SQL that it isn’t valid and then run MakeValid().&#160; Unlike setting the value true, there’s absolutely no harm in doing this—other than perf.&#160; In fact, when MakeValid() sees an object that isn’t marked as valid, it will first check to see if the instance is valid.&#160; If it is, MakeValid() won’t muck with the data, but will just flip the bit to true.</p>

<p>And keep in mind that although you <em>can </em>play with these structures, most of the time you shouldn’t need to.&#160; Use the built-in methods, and use the <a href="https://blogs.msdn.com/isaac/archive/2008/05/30/our-upcoming-builder-api.aspx">builder/sink API</a> if you need to do something fancy.&#160; As always, there are plenty of examples on the <a href="https://www.codeplex.com/sqlspatialtools/">SQL Server Spatial Tools</a> CodePlex project.</p>

<p>Cheers, 
  <br />-Isaac</p>]]></content:encoded>
    </item>
  </channel>
</rss>