<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>josecgomez.com &#187; microsoft</title>
	<atom:link href="http://www.josecgomez.com/tag/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.josecgomez.com</link>
	<description>The random thoughts of an IT professional.</description>
	<lastBuildDate>Wed, 18 Jan 2012 13:40:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Instead of Insert Trigger</title>
		<link>http://www.josecgomez.com/2010/05/11/instead-of-insert-trigger/</link>
		<comments>http://www.josecgomez.com/2010/05/11/instead-of-insert-trigger/#comments</comments>
		<pubDate>Tue, 11 May 2010 14:16:03 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=501</guid>
		<description><![CDATA[Ever wanted to have an easy way to get the most recent entry for any given key on a massive database? I ran into this problem a few days ago at work and I wanted to attempt to explain how I solved it. We have a large database that contains the lifetime history of our [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to have an easy way to get the most recent entry for any given key on a massive database? I ran into this problem a few days ago at work and I wanted to attempt to explain how I solved it.</p>
<p>We have a large database that contains the lifetime history of our trucks GPS locations. The data in these tables is entered once every 10 seconds per truck, given the fact that we have about 30 trucks on average there are about 31536000 entries into this table per year and we have been running this program for several years now. We need a quick way to get the most recent location for every truck on the fleet regardless of whether it was last reported 10 seconds ago or 10 days ago.</p>
<p>For a while we had created a simple SQL query that returned the MAX(date) record for each given truck and this seemed to work all right. That is until yesterday evening, at that time the query that I just mentioned was taking somewhere in the realm of 10-15 minutes to execute, just long enough for our program to time out. Our table now contains somewhere in the realm of two billion records and this query is just not efficient enough. We attempted to optimize the query and gained some performance but not nearly enough to make a sustainable difference in the future.</p>
<p>The program that relies on this query is a real time monitoring system and we cannot sit there and wait for this to process during several minutes. An idea I had was to intercept the incoming stream and tag it as &#8220;most-recent&#8221; before insertion thus allowing a simple query such as &#8220;SELECT * FROM TABLE WHERE MOST-RECENT=true&#8221; would work. The challenge with this approach was, the interception of the data. We knew that we could write a simple database trigger, but had no idea if  would allow us to modify the incoming data stream.</p>
<p>Most of the database triggers happen after insertion, or update so this may have posed a problem. However it appears that Microsoft had thought about this for us and gave us &#8220;Instead of Insert&#8221; triggers. This triggers take the incoming data and allow you to do something with it other than actually inserting it into the database. We decided to take the incoming data, update the table to clear the &#8220;most-current&#8221; flag and then insert the data while updating the current records most-current flag. See the implementation below, we went from a 10 minute query to a milliseconds long query. And the overhead placed on the insert hasn&#8217;t posed a problem for the amount of data we receive.</p>
<pre class="brush: sql; title: ; notranslate">
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Jose C Gomez
-- Create date: 5/10/2010
-- Description:	Trigger that allows us to keep track of the Vehicles most recent location
-- =============================================
CREATE TRIGGER InsteadofInsert
   ON  dbo.current_location
   INSTEAD OF INSERT
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
--CLEAR THE OLDER MOST-RECENT FLAG
UPDATE current_location
SET most_current=0
WHERE most_current =1 AND  Device_ID in (SELECT Device_ID from Inserted);

--INSERT THE RECORD WITH THE MOST-RECENT FLAF SET TO TRUE (1)
INSERT INTO current_location
	SELECT Device_ID, Lat, Lon, date, ip_address, direction, speed ,1
	FROM Inserted

END
GO
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2010/05/11/instead-of-insert-trigger/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The games that google plays.</title>
		<link>http://www.josecgomez.com/2009/07/08/the-games-that-google-plays/</link>
		<comments>http://www.josecgomez.com/2009/07/08/the-games-that-google-plays/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 15:44:06 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Views]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[OS]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=329</guid>
		<description><![CDATA[On July 7 google posted the following on their official blog. It&#8217;s been an exciting nine months since we launched the Google Chrome browser. Already, over 30 million people use it regularly. We designed Google Chrome for people who live on the web — searching for information, checking email, catching up on the news, shopping [...]]]></description>
			<content:encoded><![CDATA[<p>On July 7 google posted the following on their official blog.</p>
<blockquote><p>It&#8217;s been an exciting nine months since we launched the Google Chrome browser. Already, over 30 million people use it regularly. We designed Google Chrome for people who live on the web — searching for information, checking email, catching up on the news, shopping or just staying in touch with friends. However, the operating systems that browsers run on were designed in an era where there was no web. So today, we&#8217;re announcing a new project that&#8217;s a natural extension of Google Chrome — the Google Chrome Operating System. It&#8217;s our attempt to re-think what operating systems should be.</p></blockquote>
<blockquote><p><a href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html">more&#8230;</a></p></blockquote>
<p>It seems that the endless rumors about Google making an Operating System were not unfounded after all. After this announcement I went through the list of Google products, and I have found that basically Google&#8217;s model is simple. They take an existing product or function and create an improved version of it, in accordance with the company&#8217;s view. By making such a product the force the hand of the previous competitors, thus accelerating the evolution of said product and benefiting everyone.</p>
<p>Take Gmail for example, before Gmail came around all web based free email platforms had ridiculous restrictions 2-10 mb per account, no large attachments, poor POP and IMAP support etc&#8230; Then along comes Gmail and it blows all the caps and restrictions providing free unlimited space with POP and IMAP support excellent search and a snazzy interface. Immediately the competition reacts and now most of the web based email platforms support a wide range of features and unlimited space.</p>
<p>Google has done this with many of their products , Google Earth, Google News, Google Voice, the threat to buy the 700 mghz spectrum and many more. Google is playing a game and the thing is, that they are good at it. With this announcement about an OS they just threw the ball in Microsoft&#8217;s court. I guarantee you that the next version of &#8220;Windows&#8221; will take a lot from this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2009/07/08/the-games-that-google-plays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 Shake to Minimize?</title>
		<link>http://www.josecgomez.com/2009/06/08/windows-7-shake-to-minimize/</link>
		<comments>http://www.josecgomez.com/2009/06/08/windows-7-shake-to-minimize/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 13:24:48 +0000</pubDate>
		<dc:creator>Jose C Gomez</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[minimize]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[shake]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.josecgomez.com/?p=324</guid>
		<description><![CDATA[So I installed Windows 7 as my main OS at work a few days ago just to play around in a &#8220;Production Environment&#8221; and this morning I ran into the strangest, yet most useful feature yet. Apparently in an Aero enabled PC with Windows 7 if you grab and shake your foreground window it will [...]]]></description>
			<content:encoded><![CDATA[<p>So I installed Windows 7 as my main OS at work a few days ago just to play around in a &#8220;Production Environment&#8221; and this morning I ran into the strangest, yet most useful feature yet. Apparently in an Aero enabled PC with Windows 7 if you grab and shake your foreground window it will automatically minimize all the windows behind it, clearing all the noise. Once you are done, you can get all your windows back by shaking the screen again. Very useful! yet it can get annoying, I have several times now shaken my screen in anger or while waiting for something (who hasn&#8217;t?), and everything drops down. Check out the vid if you don&#8217;t believe me.</p>
<p style="text-align: center;">
<p><a href="http://www.youtube.com/watch?v=fEkSSaq-QFk">www.youtube.com/watch?v=fEkSSaq-QFk</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.josecgomez.com/2009/06/08/windows-7-shake-to-minimize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

