<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Journey to SQL Authority with Pinal Dave</title>
	<atom:link href="http://blog.sqlauthority.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com</link>
	<description>SQL, SQL Server, MySQL, Big Data and NoSQL</description>
	<lastBuildDate>Wed, 19 Mar 2014 08:19:38 +0000</lastBuildDate>
	<language>en</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.sqlauthority.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/08e35387c05b61340e885b1763a69d9f?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.sqlauthority.com/osd.xml" title="Journey to SQL Authority with Pinal Dave" />
	<atom:link rel='hub' href='http://blog.sqlauthority.com/?pushpress=hub'/>
	<item>
		<title>SQL SERVER &#8211; Retrieve Last Inserted Rows from Table &#8211; Question with No Answer</title>
		<link>http://blog.sqlauthority.com/2014/03/19/sql-server-retrieve-last-inserted-rows-from-table-question-with-no-answer/</link>
		<comments>http://blog.sqlauthority.com/2014/03/19/sql-server-retrieve-last-inserted-rows-from-table-question-with-no-answer/#comments</comments>
		<pubDate>Wed, 19 Mar 2014 01:30:53 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=27078</guid>
		<description><![CDATA[Some conversations are very interesting and I would like to bring them to everyone&#8217;s attention. Here is one of the conversation happened earlier this week. Let us say the question was asked by Dustin. Dustin: Can we retrieve last 10 rows from a table? Pinal: Sure, just get the top rows from the end of [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27078&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;"><img class="alignleft" alt="" src="http://www.pinaldave.com/bimg/cinema.jpg" width="300" /></p>
<p style="text-align:justify;">Some conversations are very interesting and I would like to bring them to everyone&#8217;s attention. Here is one of the conversation happened earlier this week. Let us say the question was asked by Dustin.</p>
<p style="text-align:justify;"><b>Dustin:</b> Can we retrieve last 10 rows from a table?</p>
<p style="text-align:justify;"><b>Pinal:</b> Sure, just get the top rows from the end of the table. For this you will have to order table with Identity Column Descending.</p>
<p style="text-align:justify;"><b>Dustin:</b> I do not have an identity column in table.</p>
<p style="text-align:justify;"><b>Pinal:</b> No problem. Do you have a column which tracks the date and time for the newly inserted row or timestamp?</p>
<p style="text-align:justify;"><b>Dustin:</b> No such thing in my table.</p>
<p style="text-align:justify;"><b>Pinal:</b> Hmmm&#8230; That means there is no property which can identify if the rows were inserted last or first.</p>
<p style="text-align:justify;"><span style="line-height:1.5em;"><b>Dustin:</b> I believe so. Any other thoughts?</span></p>
<p style="text-align:justify;"><b>Pinal:</b> Well, is there any auditing on the table or any trigger or any other mechanism where you store your data to another table for example with an OUTPUT clause?</p>
<p style="text-align:justify;"><b>Dustin:</b> No, nothing like that. <span style="line-height:1.5em;">Is there any administrative ways to get the last inserted </span><span style="line-height:1.5em;">row</span><span style="line-height:1.5em;">?</span></p>
<p style="text-align:justify;"><b>Pinal:</b> What do you mean?</p>
<p style="text-align:justify;"><b>Dustin:</b> Can I read the logs and know what were the rows inserted?</p>
<p style="text-align:justify;"><b>Pinal:</b> I have personally never tried to read log files and I have no clue how <span class="GINGER_SOFTWARE_mark" id="62d0ae2f-43ba-4571-a75d-51c41eff6161"><span class="GINGER_SOFTWARE_mark" id="a5a0252a-16ed-491a-a1ea-badabf59c7b3"><span class="GINGER_SOFTWARE_mark" id="885ae885-ddf0-4d36-b723-6e619d889814"><span class="GINGER_SOFTWARE_mark" id="f65fd0d9-622b-45d2-8392-f8be70a8e719">to do</span></span></span></span> that. If you are going <span class="GINGER_SOFTWARE_mark" id="0343c71d-a7c8-416a-8ca4-47febd4176f3"><span class="GINGER_SOFTWARE_mark" id="8bce00a2-f127-4586-82f8-f059a3aa6b03"><span class="GINGER_SOFTWARE_mark" id="ca10b646-4d76-44ee-9c41-aba9d2f999a3">do</span></span></span> that, I suggest you take backup of your log file and do the experiment on it. There are good chances if you use <span class="GINGER_SOFTWARE_mark" id="1e7a99c6-7411-4bf5-ad3e-6b6bc78569dd"><span class="GINGER_SOFTWARE_mark" id="3062f3e4-3f0d-4878-a556-e6a7ecb8d18b"><span class="GINGER_SOFTWARE_mark" id="bfcca28d-1635-4529-8fb0-eee51949824d">tool</span></span></span> which is not safe you will get your database at very high risk.</p>
<p style="text-align:justify;"><b>Dustin:</b> Do you recommend any tool?</p>
<p style="text-align:justify;"><b>Pinal:</b> No, I do not recommend any tool as of now. If I will find one, I will write a blog post.</p>
<p style="text-align:justify;"><strong>Note:</strong> Please do not post a comment with third party tools link, I will delete them without notice. I will be doing my research soon and will post a blog about it.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/27078/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/27078/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/27078/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/27078/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/27078/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/27078/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/27078/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/27078/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27078&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/19/sql-server-retrieve-last-inserted-rows-from-table-question-with-no-answer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/cinema.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Performance: Do-it-Yourself Caching with Memcached vs. Automated Caching with SafePeak</title>
		<link>http://blog.sqlauthority.com/2014/03/18/sql-server-performance-do-it-yourself-caching-with-memcached-vs-automated-caching-with-safepeak/</link>
		<comments>http://blog.sqlauthority.com/2014/03/18/sql-server-performance-do-it-yourself-caching-with-memcached-vs-automated-caching-with-safepeak/#comments</comments>
		<pubDate>Tue, 18 Mar 2014 01:30:16 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Safepeak]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=27050</guid>
		<description><![CDATA[We’ve all been reading a lot of articles that suggest adding a caching layer in front of a database is more efficient than hitting the database directly. Among different caching options there is Do-It-Yourself coding, using open source tools like Memcached, or using Velocity (part of the Microsoft AppFabric) or using Ehcache (for Java developers). [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27050&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;" align="left"><span style="text-align:justify;line-height:1.5em;">We<span class="GINGER_SOFTWARE_mark" id="63707d7c-93bb-4efc-85c4-2c5c91835e3d"><span class="GINGER_SOFTWARE_mark" id="47c16c1a-610d-47ac-bbbe-5dd8413d8200"><span class="GINGER_SOFTWARE_mark" id="98c67e85-183e-4882-86b3-1680add9cccb"><span class="GINGER_SOFTWARE_mark" id="9afb66e7-ac09-4e32-a860-c81dfc35aca0"><span class="GINGER_SOFTWARE_mark" id="7d72f9f9-fa64-4baf-aab0-c31b89b7d1df"><span class="GINGER_SOFTWARE_mark" id="f44facf9-b355-4874-bab2-c08157b792f0"><span class="GINGER_SOFTWARE_mark" id="e3a0cbb7-3f21-47ab-ac79-00fee3f5aa75"><span class="GINGER_SOFTWARE_mark" id="15cf8f40-652a-4804-84a8-eb8e588bf84a"><span class="GINGER_SOFTWARE_mark" id="a57d5ebf-ec8b-464e-9733-df566e9a900b">’ve all been reading</span></span></span></span></span></span></span></span></span> a lot of articles that suggest adding a caching layer in front of a database is more efficient than hitting the database directly. Among different caching options there is Do-It-Yourself coding, using open source tools like Memcached, or using Velocity (part of the Microsoft AppFabric) or using Ehcache (for Java developers). Alternatively, you can now find automated caching solutions like SafePeak’s dynamic caching for SQL Server.</span></p>
<h3 style="text-align:justify;"><b>Why use a caching solution?</b></h3>
<p style="text-align:justify;">Let’s quickly recap the many reasons to use data caching with SQL Server:</p>
<ul style="text-align:justify;">
<li>To improve data access read/write performance</li>
<li>To reduce the number queries hitting the of <span class="GINGER_SOFTWARE_mark" id="e34fb695-6d64-46c3-90b4-44fffd47ae3c"><span class="GINGER_SOFTWARE_mark" id="b5318eca-5548-474a-9fa2-32b79633cfd4"><span class="GINGER_SOFTWARE_mark" id="6ba092e3-974f-4551-8e89-2c3498afa11b"><span class="GINGER_SOFTWARE_mark" id="d182d1df-e83a-4505-8de7-c985db2117c0"><span class="GINGER_SOFTWARE_mark" id="61a9f864-e04b-4e96-b394-7ded8b09bdd9"><span class="GINGER_SOFTWARE_mark" id="2dbba63c-5951-490d-9a81-5857c08eee62"><span class="GINGER_SOFTWARE_mark" id="d8f1f2fc-e064-4454-a77e-59252636c488"><span class="GINGER_SOFTWARE_mark" id="d8e03eec-f811-4c9e-8981-5fc9297efd25"><span class="GINGER_SOFTWARE_mark" id="04f63058-6f8c-49d2-8ece-5345cba906f4">database</span></span></span></span></span></span></span></span></span></li>
<li>To reduce database load (CPU, IO, Memory)</li>
<li>To improve application page load response time (the user’s actual experience)</li>
<li>To distribute repetitive query workloads to separate cache servers</li>
<li>To share the benefit of cached data on one server across all other servers.</li>
<li>To increase operational efficiency, by scaling more data and more users on smaller and <span class="GINGER_SOFTWARE_mark" id="487defb2-57cc-4f85-97b2-64744d71b502"><span class="GINGER_SOFTWARE_mark" id="c5ffd648-a0e1-4979-9f84-127cfb45993b"><span class="GINGER_SOFTWARE_mark" id="754dcf63-a60c-4522-8b1b-18f477f49735"><span class="GINGER_SOFTWARE_mark" id="52d45d3b-6848-48d3-8271-c3c08331b84d"><span class="GINGER_SOFTWARE_mark" id="794a53db-33e5-44d1-945d-bf6bd9757426"><span class="GINGER_SOFTWARE_mark" id="9f872365-bfe1-44c3-a497-ac70f9106ffe"><span class="GINGER_SOFTWARE_mark" id="2889be4c-4c2f-4f60-a191-066e91efa42c"><span class="GINGER_SOFTWARE_mark" id="e9a8acbe-ec01-4e46-88f2-ea13d43d54be"><span class="GINGER_SOFTWARE_mark" id="9a28f199-4186-4101-9ce7-afd95bb55020"><span class="GINGER_SOFTWARE_mark" id="bf971ff3-1a9f-401e-b2c8-d0346b40b823"><span class="GINGER_SOFTWARE_mark" id="fb6efe9d-1e62-4eb7-ad7e-ead5e953414d">fewer</span></span></span></span></span></span></span></span></span></span></span> SQL <span class="GINGER_SOFTWARE_mark" id="92bcbaec-8419-4290-ab75-6eba3f08ffa8"><span class="GINGER_SOFTWARE_mark" id="a9c5d000-a9b4-46be-ac66-2af5c7dc2387"><span class="GINGER_SOFTWARE_mark" id="d7b738dd-2c23-4b49-81b2-9fcc8491e031"><span class="GINGER_SOFTWARE_mark" id="5bd3dd3f-71ac-4db8-84a4-a5f331218374"><span class="GINGER_SOFTWARE_mark" id="143bfb26-9abf-4a6c-b53b-ea8b65d34778"><span class="GINGER_SOFTWARE_mark" id="a9852376-0ef6-4148-998c-b966037a3bbe"><span class="GINGER_SOFTWARE_mark" id="816bf101-b36f-4f7b-b3d7-4e20ba6bee14"><span class="GINGER_SOFTWARE_mark" id="ca33092f-9720-4464-a6b9-7f4c20f81059"><span class="GINGER_SOFTWARE_mark" id="a7aa7e48-9ee0-4aaf-80d2-7cc4a61d199f"><span class="GINGER_SOFTWARE_mark" id="07d8ddda-2f9f-4043-b069-98a33fca2b09"><span class="GINGER_SOFTWARE_mark" id="58c64a6f-8e9e-42dc-8cc6-46df2e8000e9">Servers</span></span></span></span></span></span></span></span></span></span></span> machines</li>
</ul>
<p style="text-align:justify;" align="left">Another benefit of caching is its impact on database scalability. SQL Server is expensive to scale with bigger hardware, which also can trigger increased license fees. Fast Flash storage systems, which can be helpful, are also very expensive. Whereas adding a new web/caching server can be much cheaper (and potentially more effective).</p>
<p style="text-align:justify;" align="left">So, now that we know <i>why</i> we want to use caching with SQL SERVER, <i>what’s the best way</i> to go about it? Well, you’ll need to decide what’s best for you. Let’s look at three main SQL Server caching options:</p>
<ol style="text-align:justify;">
<li>SQL Server Memory and IO caching</li>
<li>Application data caching, a Do It Yourself approach using Memcached/similar APIs</li>
<li><span class="GINGER_SOFTWARE_mark" id="5df7ce63-7c83-4983-9d5c-15a464014eb3"><span class="GINGER_SOFTWARE_mark" id="90a64bff-c9a4-4162-89a7-48b0305b230d"><span class="GINGER_SOFTWARE_mark" id="30e8a7f7-6bbb-4b52-8103-7cf1a7742836"><span class="GINGER_SOFTWARE_mark" id="0be994d9-a682-42c2-bd4f-004d6703429c"><span class="GINGER_SOFTWARE_mark" id="c3242f67-57a9-4573-ab2a-cb3e98d68fc8"><span class="GINGER_SOFTWARE_mark" id="e3618245-328c-441b-bf34-2e5fa348a645"><span class="GINGER_SOFTWARE_mark" id="d6a032fe-c0db-411a-b8d4-afc2cb180734"><span class="GINGER_SOFTWARE_mark" id="646919d1-f39d-4492-8efd-f96592532b6b"><span class="GINGER_SOFTWARE_mark" id="87ba6a9e-4b49-42bc-a189-1cb4bccfabc3"><span class="GINGER_SOFTWARE_mark" id="75df9d0c-0600-4d0c-ac7d-0f46a6d1f6b6">SafePeak</span></span></span></span></span></span></span></span></span></span> automated SQL caching</li>
</ol>
<p style="text-align:justify;" align="left">By the way, I’d also like to learn from your experiences, so I look forward to your comments and thoughts on what I discuss here.</p>
<h3 style="text-align:justify;" align="left"><b>SQL Server: Doesn’t it already have memory cache?</b></h3>
<p style="text-align:justify;" align="left">To start with, we need to remember that SQL Server has its own memory cache for objects in the database. When data is retrieved, SQL Server maintains its cache and will (if necessary) pull the row from its memory and not hit the disk.</p>
<p style="text-align:justify;" align="left">So if SQL Server has its own cache, what’s the benefit of data caching layers such as Memcached, SafePeak or similar?</p>
<p style="text-align:justify;" align="left">The answer is this: SQL Server only caches:</p>
<ol style="text-align:justify;">
<li>Query plans</li>
<li>Pages from the database files.</li>
</ol>
<p style="text-align:justify;" align="left"><b>SQL Server </b><b>does NOT cache <i>results</i> from a query</b>.</p>
<p style="text-align:justify;" align="left">This is the important distinction.</p>
<p style="text-align:justify;" align="left">For example, imagine if you have a complex query which uses some aggregation on a lot of data (e.g.: how many different countries we have in our customer database: SELECT DISTINCT Country from Customers GROUP BY country). SQL Server will scan the WHOLE customer table, but your result-set will only be a few entries long. When you reissue your query, SQL Server will reuse the query plan and will <span class="GINGER_SOFTWARE_mark" id="0025aaac-2429-4149-ae13-944bbba274db"><span class="GINGER_SOFTWARE_mark" id="a4278b4b-1534-4a65-9a3a-8cab9192c5c5"><span class="GINGER_SOFTWARE_mark" id="b1f242d2-9792-4153-95e5-c8cab3efc3d7"><span class="GINGER_SOFTWARE_mark" id="26f63a1f-89bc-4604-bfa5-77c8e73b7be0"><span class="GINGER_SOFTWARE_mark" id="7d858cdb-07ba-49e9-be97-e48446f54377"><span class="GINGER_SOFTWARE_mark" id="84965478-e464-476d-a51a-beb142abebed"><span class="GINGER_SOFTWARE_mark" id="0c5a5d8d-9b3a-4e99-9c3e-2d1a19768429"><span class="GINGER_SOFTWARE_mark" id="cc6f624e-0bd1-4f59-8fb0-cdd00d33d84e"><span class="GINGER_SOFTWARE_mark" id="1e4c3684-0e18-4700-a99d-0ef3937fa4de">rescan</span></span></span></span></span></span></span></span></span> the customer table, (and if you are lucky the pages are still in memory)</p>
<p style="text-align:justify;" align="left"><span class="GINGER_SOFTWARE_mark" id="c5830cc4-263d-4a1d-86e9-26dac8915e86"><span class="GINGER_SOFTWARE_mark" id="b359074d-fde0-484a-a4eb-d598e8d2fd79"><span class="GINGER_SOFTWARE_mark" id="0b75f0f1-b6e9-4f4b-a83f-7bbd9bc6a648"><span class="GINGER_SOFTWARE_mark" id="3e02c484-85e3-4b3a-b715-80799052afa0"><span class="GINGER_SOFTWARE_mark" id="34fc6552-9f86-4a97-b21d-d37b777dc0a7"><span class="GINGER_SOFTWARE_mark" id="d6c2ff80-34f8-40fe-8ca9-1ed03dfc9108"><span class="GINGER_SOFTWARE_mark" id="9a501ac8-7f4b-438e-97c8-1801bebf0051"><span class="GINGER_SOFTWARE_mark" id="303b2277-eba1-4e71-8df9-64c7c2960cb0"><span class="GINGER_SOFTWARE_mark" id="6b734d05-5796-496c-9c2f-9f340dd43dd4">When you use application</span></span></span></span></span></span></span></span></span> cache, you store your result-sets in Memcached RAM. Then reuse them over and over again without connecting to the database server, thus offloading workloads from your database server.</p>
<h3 style="text-align:justify;" align="left"><b>Do-It-Yourself application data caching using Memcached / similar APIs</b><b></b></h3>
<p style="text-align:justify;" align="left">Application data caching is quite easy to start. However, changing (or building) code for large applications with effective data caching is challenging for a few reasons:</p>
<ol style="text-align:justify;">
<li>Correctly scoping required code changes;</li>
<li>Delivering and testing actual code changes required to handle caching of all (or most) SQL queries;</li>
<li>Preserving data integrity: how to invalidate all relevant cache items and to handle all kinds of data change events. And in real-life both READs / WRITEs can be <span class="GINGER_SOFTWARE_mark" id="b05d27f8-1a82-44c8-9681-3e9608bf34c6"><span class="GINGER_SOFTWARE_mark" id="9107c872-af2b-47a1-aaac-243339870a39"><span class="GINGER_SOFTWARE_mark" id="2a7a61e1-a176-4f2d-894d-c48983f24a9f"><span class="GINGER_SOFTWARE_mark" id="e16d32cc-038c-4678-8442-280804120eaa"><span class="GINGER_SOFTWARE_mark" id="05c5ec67-3354-4cae-ab47-a674e50c11ed"><span class="GINGER_SOFTWARE_mark" id="a87ca89e-2ad0-40d6-b39e-ffea17561d2c"><span class="GINGER_SOFTWARE_mark" id="29573bc5-7088-469a-a140-77a8609cf00f"><span class="GINGER_SOFTWARE_mark" id="48b23dd8-72f9-4afa-8349-e06ee86b95e8"><span class="GINGER_SOFTWARE_mark" id="1f01434a-16dc-43c1-a0f0-6557e2fc3562">complex involving</span></span></span></span></span></span></span></span></span> stored-procedures, triggers, views, table joins etc.; and</li>
<li>Maintaining the additional code layer.</li>
</ol>
<p style="text-align:justify;" align="left">One thing to keep in mind is that because DIY and Memcached approaches need to touch app code, they can’t be used to accelerate <span class="GINGER_SOFTWARE_mark" id="055dcd43-be98-46b5-9cd6-4a0fe069b61b"><span class="GINGER_SOFTWARE_mark" id="071f27f3-3485-4d94-93a4-1ef271d2a1b2"><span class="GINGER_SOFTWARE_mark" id="6e7323a8-8e9d-4a66-9839-f18d5a0a572f"><span class="GINGER_SOFTWARE_mark" id="e5e814b3-4553-48c2-b865-db8fa09254af"><span class="GINGER_SOFTWARE_mark" id="43bdc933-8b5c-4652-8110-c3e4eff563e4"><span class="GINGER_SOFTWARE_mark" id="fdec1075-5fd9-4c36-aa59-943ffde13c8e"><span class="GINGER_SOFTWARE_mark" id="44c1c352-6ad2-4cba-946b-22bc9b6d9fa4"><span class="GINGER_SOFTWARE_mark" id="1dfa4ae3-444b-41c4-8506-f697f49f5a0e"><span class="GINGER_SOFTWARE_mark" id="ddcea833-56a2-40b2-b237-7591548583b9">any</span></span></span></span></span></span></span></span></span> off-the-shelf software that relies on SQL Server.</p>
<p style="text-align:justify;" align="left">So, while it can be complicated, application performance benefits are always good, so let’s dive into what you would do using Memcached.</p>
<p style="text-align:justify;"><b>About Memcached data caching<br />
</b><span class="GINGER_SOFTWARE_mark" id="eea0bb95-bce2-4791-a539-0b6dc3e26c93"><span class="GINGER_SOFTWARE_mark" id="43d0f163-c7c5-4711-8ac2-aa503b3c55c7"><span class="GINGER_SOFTWARE_mark" id="84a70f34-7a0c-4ba3-a789-d50906e44789"><span class="GINGER_SOFTWARE_mark" id="5de42c49-6d83-4eb2-8ccb-0200f64f3a3a"><span class="GINGER_SOFTWARE_mark" id="332f7495-38c6-470d-9c92-d61f8eb86d80"><span class="GINGER_SOFTWARE_mark" id="7a789367-74cd-43d9-aae0-87bec6db26f0"><span class="GINGER_SOFTWARE_mark" id="5af4d282-1272-4b8a-8182-e935d0d19aec"><span class="GINGER_SOFTWARE_mark" id="6c60ed6a-2422-40b2-b838-3b160562bb00"><span class="GINGER_SOFTWARE_mark" id="560e434e-561f-41c6-8dfe-647a233db552">Memcached</span></span></span></span></span></span></span></span></span> is a big hash table: a key/value store that lives entirely in RAM on multiple servers. It allows you to use RAM from multiple servers as single memory caching space.</p>
<p style="text-align:justify;"><b>Basic data caching using Memcached</b></p>
<p style="text-align:justify;" align="left">Below is a basic tutorial showing (via pseudocode) how you can get started with integrating Memcached into your application. If you&#8217;re an application developer, it isn&#8217;t something you just &#8220;turn on&#8221; and then your site goes faster. You have to pay attention. For every query you want to be cached, you have to put (<b>set<span class="GINGER_SOFTWARE_mark" id="d4161c88-99c4-4df6-838b-f9ebb43e05bf"><span class="GINGER_SOFTWARE_mark" id="c5068f90-ddc3-45e2-bda9-7f6b8299a6b1"><span class="GINGER_SOFTWARE_mark" id="610dcddc-a1d3-4f94-9481-c3842f19b781"><span class="GINGER_SOFTWARE_mark" id="762375cd-70fa-43b1-8ae6-adf9af449b65"><span class="GINGER_SOFTWARE_mark" id="e054adc7-d6b3-43ee-8138-1225429a798c"><span class="GINGER_SOFTWARE_mark" id="847dbe47-b714-4ab1-823d-aed5dac8d1ef"><span class="GINGER_SOFTWARE_mark" id="3381a023-b081-460a-a8b7-1d13b2095a71">(</span></span></span></span></span></span></span>)</b>) it into <span class="GINGER_SOFTWARE_mark" id="46539445-c72b-4877-8e39-efe9cde30658"><span class="GINGER_SOFTWARE_mark" id="3ddc5353-42f5-462a-8314-3e4472fd7c4e"><span class="GINGER_SOFTWARE_mark" id="b962c84e-b06e-4906-895f-cf9793c0e215"><span class="GINGER_SOFTWARE_mark" id="4bc41bae-1771-4599-9a20-df40700f7fcb"><span class="GINGER_SOFTWARE_mark" id="c97b1af7-cd2d-4752-b06d-43e18027897e"><span class="GINGER_SOFTWARE_mark" id="d1b56dd7-a1ef-4774-9d3f-d9560cf8c3f8"><span class="GINGER_SOFTWARE_mark" id="69f0af76-0a5e-4d38-b1ac-4ec4aa784ee8">cache</span></span></span></span></span></span></span>, get it from cache (<b>get<span class="GINGER_SOFTWARE_mark" id="a57167e4-e1ab-41cf-9527-4b87fa7c168e"><span class="GINGER_SOFTWARE_mark" id="6b28a661-9220-45b5-83e4-6c80df727cd0"><span class="GINGER_SOFTWARE_mark" id="e7cfbff9-2b65-4aa7-a90c-c91eed6dfce3"><span class="GINGER_SOFTWARE_mark" id="e3364e2b-87bd-4125-a04c-d6f3a3eb9e37"><span class="GINGER_SOFTWARE_mark" id="07db5188-aabd-42bb-a79d-64b5b439fa70"><span class="GINGER_SOFTWARE_mark" id="3b638168-4711-4edb-8ca9-221a7d841879"><span class="GINGER_SOFTWARE_mark" id="15e038e5-b9f6-4f9c-b996-b2b01ebdaeae">(</span></span></span></span></span></span></span>)</b>) and (probably <span class="GINGER_SOFTWARE_mark" id="541859f6-8539-4690-a384-e6383c0730ff"><span class="GINGER_SOFTWARE_mark" id="2fe4b158-dcbc-4d55-a970-4a92124ef47c"><span class="GINGER_SOFTWARE_mark" id="ae4227a3-c6d2-4baa-b734-7f8bf58e9e54"><span class="GINGER_SOFTWARE_mark" id="7fc896bd-7af3-4130-9552-88db13653336"><span class="GINGER_SOFTWARE_mark" id="a5753542-b62e-4f9c-820c-9a804fa5e234"><span class="GINGER_SOFTWARE_mark" id="2689ba3f-73bb-447b-8b77-6e5d493f1009"><span class="GINGER_SOFTWARE_mark" id="acea4ec5-f3e0-458d-8ddd-c4ef03455e86">most complicated</span></span></span></span></span></span></span>) make sure you keep the data in the cache correct by removing from cache (<b>delete<span class="GINGER_SOFTWARE_mark" id="018a860a-44f3-495d-bafb-da3ca43d18ad"><span class="GINGER_SOFTWARE_mark" id="b4ef51be-6d10-4f70-8df4-3662988493d7"><span class="GINGER_SOFTWARE_mark" id="0719ad0e-4661-49f3-90e4-5baa7f55012c"><span class="GINGER_SOFTWARE_mark" id="2b673f16-182c-46ab-90db-305839433e95"><span class="GINGER_SOFTWARE_mark" id="06fcde5d-ae92-4ae3-b65a-e81a9a3f231f"><span class="GINGER_SOFTWARE_mark" id="0bf87814-bf6a-49e4-85c9-2ee0f7ec46e7"><span class="GINGER_SOFTWARE_mark" id="dc2a8d03-c222-4e82-a08a-51c09febc848">(</span></span></span></span></span></span></span>)</b>) when the data is updated.</p>
<p style="text-align:justify;">The following pseudocode of Memcached example is written in #Perl but can be done in <span class="GINGER_SOFTWARE_mark" id="0b1c3945-4908-4e95-a4be-a9e6d1f2f905"><span class="GINGER_SOFTWARE_mark" id="be98232e-2a2b-417c-ac19-6f765ba9c4bc"><span class="GINGER_SOFTWARE_mark" id="df25b50c-1ea9-4ba6-991c-2d69949a1f0a"><span class="GINGER_SOFTWARE_mark" id="68ac09dc-bd9a-4b0c-bf17-fc450a91d55c"><span class="GINGER_SOFTWARE_mark" id="a3fe6a7a-b0cb-47c6-83cb-91f9fb1fa597"><span class="GINGER_SOFTWARE_mark" id="ca28dc9c-4a70-47a2-9619-0018a8d4c37b"><span class="GINGER_SOFTWARE_mark" id="da3abc3e-2e08-48a9-91b6-64fa9d6e147e"><span class="GINGER_SOFTWARE_mark" id="1b9be598-2841-42f3-ac5b-e58d4567d2fc">same way</span></span></span></span></span></span></span></span> in most other languages, including<span class="GINGER_SOFTWARE_mark" id="4f8a94cb-eefe-41be-92c3-8b65a85e350c"><span class="GINGER_SOFTWARE_mark" id="c52418eb-f8df-4622-bcdc-5610ec0c1e86"><span class="GINGER_SOFTWARE_mark" id="9ab0e0d1-9bd0-4e38-9b6c-da98dd508009"><span class="GINGER_SOFTWARE_mark" id="f13bae2b-2aec-4f7b-911a-834cd3f66849"><span class="GINGER_SOFTWARE_mark" id="28124a0b-168d-4b04-843c-fff26eb66b7e"><span class="GINGER_SOFTWARE_mark" id="77a8a695-e67b-4861-82c5-900e0ad5f1bb"><span class="GINGER_SOFTWARE_mark" id="d929f56b-2a40-47eb-96a4-76dc96b471f9"><span class="GINGER_SOFTWARE_mark" id="7c6c62e4-20fa-4733-b9f6-86b1aeaa0e34"> .</span></span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="0052a1f4-3944-49a7-9ea2-b944b7d6a2ab"><span class="GINGER_SOFTWARE_mark" id="8f4c2a11-62de-4324-92ad-df8e35beaf65"><span class="GINGER_SOFTWARE_mark" id="07126c58-d9ff-4610-a322-22c56855a03f"><span class="GINGER_SOFTWARE_mark" id="fa83f944-c04c-4376-b88a-418b87ff27cd"><span class="GINGER_SOFTWARE_mark" id="53329b64-c2f0-4895-bc04-86ae989fb6af"><span class="GINGER_SOFTWARE_mark" id="60d8da63-a62f-41d2-949f-9f7f8ef7f0a9"><span class="GINGER_SOFTWARE_mark" id="acb3a944-dbc6-441b-9851-f44ac6826a9e"><span class="GINGER_SOFTWARE_mark" id="dfe86c84-bb42-4f58-b76c-160acd0bde05">net</span></span></span></span></span></span></span></span>, <span class="GINGER_SOFTWARE_mark" id="1342a63c-c8ad-4106-a6c5-d4c47879f513"><span class="GINGER_SOFTWARE_mark" id="54afaaf9-4585-44f1-97f0-4f212773f1fb"><span class="GINGER_SOFTWARE_mark" id="7f2859a8-b0e2-4d11-a88a-87cf666635a4"><span class="GINGER_SOFTWARE_mark" id="5ae596e9-5c9b-432f-a5ab-d5c9abe19ca2"><span class="GINGER_SOFTWARE_mark" id="59591bfd-6a16-461a-89de-88f5b99d0542"><span class="GINGER_SOFTWARE_mark" id="ee3434c6-49cf-49fc-b0e8-1b7c4ebc2e63"><span class="GINGER_SOFTWARE_mark" id="bf5ba9fb-3ea0-4651-b636-0993bccfcddb"><span class="GINGER_SOFTWARE_mark" id="c3033c9e-1c75-4ab7-8ce9-e07601bf6893">java</span></span></span></span></span></span></span></span> and <span class="GINGER_SOFTWARE_mark" id="8e501368-38a9-4872-85a4-d16dde18b51c"><span class="GINGER_SOFTWARE_mark" id="93a0482d-0334-4ce2-8a6c-24f0ead42f3d"><span class="GINGER_SOFTWARE_mark" id="c2508ba8-4c74-4688-af24-14aa5575b5cc"><span class="GINGER_SOFTWARE_mark" id="bc4667dd-3bcd-4a8c-9f1d-9bd6a0c0c420"><span class="GINGER_SOFTWARE_mark" id="4605aad8-c37d-4d84-a4c1-d372f8bd3e87"><span class="GINGER_SOFTWARE_mark" id="f79aef02-d8b7-4246-bb0b-a02c1264ba6f"><span class="GINGER_SOFTWARE_mark" id="d64f8415-5e68-4083-90ce-faa4d67e89bb"><span class="GINGER_SOFTWARE_mark" id="56be80c9-8d84-4580-99ac-8397bd49da3e">php</span></span></span></span></span></span></span></span> – <span class="GINGER_SOFTWARE_mark" id="edb755d2-d57d-4c91-9ea0-d91e7e2d91d3"><span class="GINGER_SOFTWARE_mark" id="2fad39eb-1dac-401e-9f84-586302af1b54"><span class="GINGER_SOFTWARE_mark" id="84965a6f-4019-4677-8a5c-e4589bc28b25"><span class="GINGER_SOFTWARE_mark" id="22a76db6-6c96-4cf8-a594-80d93b3c3b28"><span class="GINGER_SOFTWARE_mark" id="3ede7dbe-40cb-4df2-bfe6-b6d5218c77d1"><span class="GINGER_SOFTWARE_mark" id="be4be418-1391-4cda-9f70-b2cc3d4f3795"><span class="GINGER_SOFTWARE_mark" id="d84d1c85-f516-435d-8cf7-4cfa5dce7b50"><span class="GINGER_SOFTWARE_mark" id="ca0e5563-6306-4527-8278-bc6fd54d6567">etc</span></span></span></span></span></span></span></span> (<a href="https://code.google.com/p/memcached/wiki/Clients" rel="nofollow"><span class="GINGER_SOFTWARE_mark" id="f6edb736-dc61-4ac7-ad43-94ff59412990"><span class="GINGER_SOFTWARE_mark" id="fd606e37-1ed8-4d7d-9c84-cd4bf90fa75d"><span class="GINGER_SOFTWARE_mark" id="4313679e-a046-4377-8f88-75c75e655b18"><span class="GINGER_SOFTWARE_mark" id="d0d26e2c-2698-4067-9ca0-7d9dcaec3447"><span class="GINGER_SOFTWARE_mark" id="dfc7ca22-ee8a-4ed1-a8c5-2ee9c9dc25e4"><span class="GINGER_SOFTWARE_mark" id="65eb0cf3-7490-434c-9439-c70cb1cf872c"><span class="GINGER_SOFTWARE_mark" id="ab1a05e3-20ae-465d-a964-057934f7c4f4"><span class="GINGER_SOFTWARE_mark" id="fe3b71e1-afcf-42a3-800f-0fbd94340fde">memcached</span></span></span></span></span></span></span></span> clients</a>)</p>
<p style="text-align:justify;" align="left"><b>Initializing a Memcached Client with a list of your pre-configured Memcached servers:</b></p>
<pre># <span class="GINGER_SOFTWARE_mark" id="6b2171ae-ff48-4c9a-bd06-7dc68cddb523"><span class="GINGER_SOFTWARE_mark" id="35839d0a-735a-4ba4-a846-1cb47982bca1"><span class="GINGER_SOFTWARE_mark" id="706d1f12-059c-4811-a800-45dac2d75d4c"><span class="GINGER_SOFTWARE_mark" id="9e47fbe8-cbf7-4eda-a273-205d43244669"><span class="GINGER_SOFTWARE_mark" id="e6b71170-460c-416f-951e-a54a53f77d55"><span class="GINGER_SOFTWARE_mark" id="fdc65ed7-70dd-4463-bed3-9a54cd609388"><span class="GINGER_SOFTWARE_mark" id="04f5d790-a8fc-492e-a920-937216c6cbe3"><span class="GINGER_SOFTWARE_mark" id="57477fec-3a39-4ca1-b012-74d0213ba9ab">perl</span></span></span></span></span></span></span></span> <span class="GINGER_SOFTWARE_mark" id="03161fc5-d12a-4ef1-9e9a-15b4f0dcc4b0"><span class="GINGER_SOFTWARE_mark" id="fc316c8d-f17f-4fd5-bc43-3387dfbc6e7c"><span class="GINGER_SOFTWARE_mark" id="446f8b1f-1676-45d0-9c7c-bde91929129e"><span class="GINGER_SOFTWARE_mark" id="0f5385f8-953c-432b-811b-572e614ca01d"><span class="GINGER_SOFTWARE_mark" id="f52fc32b-6bf7-49f3-85f5-67a1e39f2e43"><span class="GINGER_SOFTWARE_mark" id="1c2947c5-5116-491e-b990-7251e68a3a67"><span class="GINGER_SOFTWARE_mark" id="4113cd12-e291-4ae5-9ddc-5d27d6fee8cd">example
<span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f">my</span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span></span><span class="GINGER_SOFTWARE_mark" id="109768e7-5ec6-4d3f-8cd9-ef925bff961f"></span> $memclient = Cache:<span class="GINGER_SOFTWARE_mark" id="98e2df95-70d8-4cf9-953c-bce5b3bd9b6f"><span class="GINGER_SOFTWARE_mark" id="56ece3dc-5771-4965-ba3d-28d53c2066e7"><span class="GINGER_SOFTWARE_mark" id="c6a31742-e690-48fd-a732-ac7c41f97547"><span class="GINGER_SOFTWARE_mark" id="6c16179b-c896-4b99-88f0-ea5ab568a6f6"><span class="GINGER_SOFTWARE_mark" id="3be46bf4-c8ab-47bb-b652-051dbf62092f"><span class="GINGER_SOFTWARE_mark" id="04aee79a-5ff9-4719-ba1d-406fa9bff619"><span class="GINGER_SOFTWARE_mark" id="bd85d727-dd59-4460-851c-bb23f5cb4386"><span class="GINGER_SOFTWARE_mark" id="b51e7f50-1f26-4878-b427-35a9cb7a9b73">:</span></span></span></span></span></span></span></span>Memcached-&gt;new<span class="GINGER_SOFTWARE_mark" id="d3de7fcf-c42c-4c74-b6b5-2d4a7101b997"><span class="GINGER_SOFTWARE_mark" id="b3b10090-e18c-47f7-aa5f-17ebd392414b"><span class="GINGER_SOFTWARE_mark" id="704be579-e203-4963-ac8f-d59095a782ca"><span class="GINGER_SOFTWARE_mark" id="bf6aad60-1adb-40ef-9bc7-b284b872ba3f"><span class="GINGER_SOFTWARE_mark" id="106b9ffe-d7cb-41b9-bd91-56a4826649b6"><span class="GINGER_SOFTWARE_mark" id="1867fae0-51ae-4402-981a-736ec0032b98"><span class="GINGER_SOFTWARE_mark" id="15b93216-1d51-483d-a5dd-489f554da718"><span class="GINGER_SOFTWARE_mark" id="70c93066-5a49-4b04-a642-34fa2117258a">(</span></span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="796c9e1d-d7dd-435d-b7b0-88bf1120cee8"><span class="GINGER_SOFTWARE_mark" id="54b7e6a0-5305-4eb7-b05e-50d2d9b83a9c"><span class="GINGER_SOFTWARE_mark" id="3ced95bd-28d5-48f7-bdce-966a4c96c674"><span class="GINGER_SOFTWARE_mark" id="1fbe36e6-1265-4015-8655-e9e55cfd4264"><span class="GINGER_SOFTWARE_mark" id="54b47903-57d0-4152-b3ef-de4f2d90e1ff"><span class="GINGER_SOFTWARE_mark" id="cfac5f77-e1ba-462b-aec0-2ae90f796ee1"><span class="GINGER_SOFTWARE_mark" id="64e0fd80-8881-4ff1-ab78-9732f7795c80"><span class="GINGER_SOFTWARE_mark" id="b57ac99f-3509-49fc-999f-cb88695a73f8">{ </span></span></span></span></span></span></span></span>servers =&gt; <span class="GINGER_SOFTWARE_mark" id="371e6933-28d2-4c72-a978-ce077009c37c"><span class="GINGER_SOFTWARE_mark" id="fe9048d3-a44f-46de-9525-ce0e5f86563b"><span class="GINGER_SOFTWARE_mark" id="dc8d1b7c-d4fb-48d5-8c6e-6ce0e538c4bf"><span class="GINGER_SOFTWARE_mark" id="90c64abe-4165-4f5f-8dc4-ba7e64693ca9"><span class="GINGER_SOFTWARE_mark" id="95f00772-20b3-43db-80a6-24c70d33bb4f"><span class="GINGER_SOFTWARE_mark" id="7ca2c6bc-46a1-48d9-a6ba-0f53cc58aa83"><span class="GINGER_SOFTWARE_mark" id="489e6d87-95a3-4123-a6d8-37cbb4a62763"><span class="GINGER_SOFTWARE_mark" id="6ef5c940-15d7-4aa3-ae5d-ef7b93e48caf">[ </span></span></span></span></span></span></span></span>'10.0.0.10:11211', '10.0.0.11:11211'<span class="GINGER_SOFTWARE_mark" id="0dce9d3e-e852-4d5e-8d1c-d3948a855d90"><span class="GINGER_SOFTWARE_mark" id="061dab3d-f4bc-4eee-8128-3f0658cf2279"><span class="GINGER_SOFTWARE_mark" id="2298d1ac-ceb4-43f0-8628-9bf1153ce360"><span class="GINGER_SOFTWARE_mark" id="71166d43-cc77-48e5-bd4f-d7f1e3640115"><span class="GINGER_SOFTWARE_mark" id="cbc822fb-bde4-4666-bdf7-3348e66b0b09"><span class="GINGER_SOFTWARE_mark" id="f84e2061-bb28-4414-a52f-8f0ab634a055"><span class="GINGER_SOFTWARE_mark" id="2d22cfb8-7c3b-44bb-b780-746873100af9"><span class="GINGER_SOFTWARE_mark" id="4fcbfa22-e04b-42eb-9ad8-cbeed5f054fe"> ]</span></span></span></span></span></span></span></span>});</pre>
<p style="text-align:justify;" align="left"><b>Wrapping an SQL Query<br />
</b><span class="GINGER_SOFTWARE_mark" id="707462e0-e365-44e5-a788-d10e37fe0dc4"><span class="GINGER_SOFTWARE_mark" id="29bc7717-028f-4acd-b2dc-715f8af1456b"><span class="GINGER_SOFTWARE_mark" id="6b2cf49a-8914-4956-a6a8-5e650812392f"><span class="GINGER_SOFTWARE_mark" id="e5553618-1711-4b94-a19c-4333cd05f9e3"><span class="GINGER_SOFTWARE_mark" id="acdaf615-33eb-40db-8f36-9945d043ace3"><span class="GINGER_SOFTWARE_mark" id="8d4fa6a5-9938-4bba-b441-8e63d63ec4ce"><span class="GINGER_SOFTWARE_mark" id="d7b697b1-716f-4b4d-b201-3761b420acbe"><span class="GINGER_SOFTWARE_mark" id="75a599d6-ceee-4ddf-b969-7e4ad2511f8b">Memcached</span></span></span></span></span></span></span></span> is famous for reducing load on SQL databases. Here is some pseudocode showing how to wrap a database query access with a <span class="GINGER_SOFTWARE_mark" id="613ff6da-c66a-4a6b-9dd8-2b2637ff7e29"><span class="GINGER_SOFTWARE_mark" id="3b47536b-ef6c-4b59-bc7e-f570aa667897"><span class="GINGER_SOFTWARE_mark" id="f2536783-07a7-46f0-8ba9-8a9b3576a9e1"><span class="GINGER_SOFTWARE_mark" id="12210ad2-2e24-47fd-996d-2855780eaca9"><span class="GINGER_SOFTWARE_mark" id="b62d9f6f-9d49-401c-a917-dc4e04ae8c71"><span class="GINGER_SOFTWARE_mark" id="47eee6b2-483b-4e62-bff0-bca6247b5ac0"><span class="GINGER_SOFTWARE_mark" id="ebd05d11-54e4-43fd-ac7a-f3569f4875ae">memcached</span></span></span></span></span></span></span> caching layer, by implementing check-in-<span class="GINGER_SOFTWARE_mark" id="4876929e-69d2-46e7-a52c-725486e7b5ce"><span class="GINGER_SOFTWARE_mark" id="4fae72b6-f405-4f14-b175-e5a592ff3f01"><span class="GINGER_SOFTWARE_mark" id="2f56ddd0-63ec-45a3-a2ec-07adab3eb22a"><span class="GINGER_SOFTWARE_mark" id="466e987d-fc45-4d41-9a3c-64590735943e"><span class="GINGER_SOFTWARE_mark" id="88319577-6bb6-472c-ba7c-becf4a850642"><span class="GINGER_SOFTWARE_mark" id="98e234c4-0dcf-46e8-8282-018e1501196e"><span class="GINGER_SOFTWARE_mark" id="0e431b2b-2980-4893-a3fb-5e1787026a15">cache</span></span></span></span></span></span></span> (<b>function get<span class="GINGER_SOFTWARE_mark" id="6961ec11-cace-40e6-852d-97e115bec817"><span class="GINGER_SOFTWARE_mark" id="76ed2786-3b9d-43f6-a288-d451f5a3b9f6"><span class="GINGER_SOFTWARE_mark" id="c4f2253d-caef-472f-8072-47d986be756a"><span class="GINGER_SOFTWARE_mark" id="af30ef22-c95e-4919-865f-1ed442ae03c8"><span class="GINGER_SOFTWARE_mark" id="304ab402-d7d9-4fb9-8009-6139097b9f8a"><span class="GINGER_SOFTWARE_mark" id="2f6ae51a-f40f-4cb3-ae84-c10344cd8fd6"><span class="GINGER_SOFTWARE_mark" id="b2f39df7-5299-40e6-8bbe-c200142feeeb">(</span></span></span></span></span></span></span>)</b>) and place-into-cache (<b>function set<span class="GINGER_SOFTWARE_mark" id="42e06bec-5c2f-40c5-b9ea-ebf34e0eec17"><span class="GINGER_SOFTWARE_mark" id="c960d71e-bb8b-4d41-83e1-d63cffe257bf"><span class="GINGER_SOFTWARE_mark" id="1bef9d23-c86e-47bc-b021-1ab721aa6d0d"><span class="GINGER_SOFTWARE_mark" id="df54747e-9899-4870-b4fd-eeb41a1ee7be"><span class="GINGER_SOFTWARE_mark" id="2c0b254e-5c86-43d2-9ede-003388618115"><span class="GINGER_SOFTWARE_mark" id="775a6d65-d85e-4f5f-9503-957886d91349"><span class="GINGER_SOFTWARE_mark" id="4035a79b-6d20-4015-9c0e-9f0c15908c63">(</span></span></span></span></span></span></span>)</b>):</p>
<pre># Define a query and use it as a key for the Memcached:
<span class="GINGER_SOFTWARE_mark" id="eac1dedd-fbfb-44fe-9283-c89e53be0f17"><span class="GINGER_SOFTWARE_mark" id="08c0d636-f6df-4707-a3cc-0ddc0fd3d98b"><span class="GINGER_SOFTWARE_mark" id="4dd25b3c-2a3d-40c1-9237-726f9e37babd"><span class="GINGER_SOFTWARE_mark" id="cfc38ee4-570c-489a-bd9c-9b09778cff78"><span class="GINGER_SOFTWARE_mark" id="1147fd5b-c3fc-4296-8c12-48adc93dbb0b"><span class="GINGER_SOFTWARE_mark" id="f7dc0736-805c-48f3-9fc0-9cfe8c339e4d"><span class="GINGER_SOFTWARE_mark" id="00fa979b-e5d0-4b3a-9ca1-07e15152a3a1">sql</span></span></span></span></span></span></span> = "SELECT * FROM user WHERE user_id =<span class="GINGER_SOFTWARE_mark" id="7af8918c-35b6-4e7a-822f-63012cf4b1a1"><span class="GINGER_SOFTWARE_mark" id="5580cae8-87fb-4425-b6c7-b135ac8f6ae3"><span class="GINGER_SOFTWARE_mark" id="91b0ab86-3ee4-4453-ad8f-5d3842da15e7"><span class="GINGER_SOFTWARE_mark" id="9ed75b20-847c-4c94-b187-213a95077e5b"><span class="GINGER_SOFTWARE_mark" id="e3b6e4e1-2352-4639-94d5-a718e2571806"><span class="GINGER_SOFTWARE_mark" id="6f84e6a8-e17c-42af-8cc3-5d2538cff586"><span class="GINGER_SOFTWARE_mark" id="4f265528-7f9f-435e-9da2-eee1b4893eaa"> ?</span></span></span></span></span></span></span>"
<span class="GINGER_SOFTWARE_mark" id="e3ade5e9-f3ac-44b6-99be-cef3783f8848"><span class="GINGER_SOFTWARE_mark" id="0271e44a-578a-477a-9e13-b835563a8403"><span class="GINGER_SOFTWARE_mark" id="7759a771-977e-46cb-8725-27db3f992b48"><span class="GINGER_SOFTWARE_mark" id="f11ba08d-6115-4e15-a46b-94a3fec96a67"><span class="GINGER_SOFTWARE_mark" id="479917ac-0214-4746-91ed-60c7b19a74c1"><span class="GINGER_SOFTWARE_mark" id="1dbc3a74-0d35-4fe2-a3a4-5716e21d5e5b"><span class="GINGER_SOFTWARE_mark" id="c12559a2-08b1-4280-a4f5-ce70aa089545">key</span></span></span></span></span></span></span> = 'SQL:'<span class="GINGER_SOFTWARE_mark" id="83738c56-f15b-4da8-98fb-3f180706edb1"><span class="GINGER_SOFTWARE_mark" id="a5f7c859-7153-41fc-8c48-d5d357080aec"><span class="GINGER_SOFTWARE_mark" id="c77a4642-17fc-441b-9248-c2b74d8cd8ed"><span class="GINGER_SOFTWARE_mark" id="b33278c7-a973-43d6-bdfb-95edaf3b68bc"><span class="GINGER_SOFTWARE_mark" id="c4ee5ff6-e374-49a4-a3cb-a97e9d34958b"><span class="GINGER_SOFTWARE_mark" id="0525ea1e-8e42-49b4-8005-38149f05bd87"><span class="GINGER_SOFTWARE_mark" id="6c714101-e538-431e-ba57-993e96f17e35"> .</span></span></span></span></span></span></span> user_id<span class="GINGER_SOFTWARE_mark" id="a5fba39c-3c01-4315-9fb3-fba7bd1b5832"><span class="GINGER_SOFTWARE_mark" id="28e880c3-17a0-45f5-800b-1ead17d0762d"><span class="GINGER_SOFTWARE_mark" id="65dcf012-25f7-406a-86f9-892945a8b24c"><span class="GINGER_SOFTWARE_mark" id="2f9e8bee-d4c3-4bf2-8236-42c053521e34"><span class="GINGER_SOFTWARE_mark" id="d2d42063-b251-4488-ab28-001cc90e85fe"><span class="GINGER_SOFTWARE_mark" id="9e7c8023-33ba-4fcc-b26b-aab80e7c637a"><span class="GINGER_SOFTWARE_mark" id="04f22623-5631-4d09-a6ab-5c24390155dd"> .</span></span></span></span></span></span></span> ':' . md5sum<span class="GINGER_SOFTWARE_mark" id="fecc5ed7-79cb-4a9d-ab0b-a92b0bb26046"><span class="GINGER_SOFTWARE_mark" id="af33565c-af5e-4aa4-9cc9-2d7884df5283"><span class="GINGER_SOFTWARE_mark" id="4f974680-142e-4883-a3ef-780d81e67ab1"><span class="GINGER_SOFTWARE_mark" id="c5402da7-973f-40e4-9104-7a69450b9618"><span class="GINGER_SOFTWARE_mark" id="906b1e95-1449-4188-89ad-e05667430e95"><span class="GINGER_SOFTWARE_mark" id="0b5ea1a2-4045-4549-8e83-975f7e2457f2"><span class="GINGER_SOFTWARE_mark" id="2db5303a-486c-4dd6-b576-b0a7073ac7e1">(</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="44d5a784-b185-4404-a448-81407bc29f53"><span class="GINGER_SOFTWARE_mark" id="a1f9f901-c198-4ae2-9d3f-2aaccf8b4a23"><span class="GINGER_SOFTWARE_mark" id="0682d12f-4d67-4e88-9380-08f8458e0eb1"><span class="GINGER_SOFTWARE_mark" id="219a5c27-d224-4a8b-8c13-0732597eb3d0"><span class="GINGER_SOFTWARE_mark" id="0197e86d-6bd3-4606-a274-a67d52840e70"><span class="GINGER_SOFTWARE_mark" id="cbf5c325-9931-4bab-835b-2d854b931ab5"><span class="GINGER_SOFTWARE_mark" id="294a91fa-0e96-476e-872f-0b66fc6f36f5">sql</span></span></span></span></span></span></span>)
# We check if the value is 'defined' (or in cache), since '0' or 'FALSE' can be legitimate values!
<span class="GINGER_SOFTWARE_mark" id="ccb22ca3-0b4f-4778-965a-21298846fdd0"><span class="GINGER_SOFTWARE_mark" id="33bf8e13-5a6e-4cc1-b0a5-ff1dffbf49d0"><span class="GINGER_SOFTWARE_mark" id="96be5c61-93ba-4bc3-9272-b6b6fa291f08"><span class="GINGER_SOFTWARE_mark" id="144dfd79-da41-4bf8-889f-b980fc70c967"><span class="GINGER_SOFTWARE_mark" id="b540e035-ec32-490a-9572-306b9a20337b"><span class="GINGER_SOFTWARE_mark" id="987272d1-d30e-44ec-a38a-6193dd4549dd"><span class="GINGER_SOFTWARE_mark" id="4300935a-9744-41fb-a01a-2439a11dccea">if</span></span></span></span></span></span></span> (defined result = <span class="GINGER_SOFTWARE_mark" id="be313c1e-cb9e-4279-ad46-cf9e14480dec"><span class="GINGER_SOFTWARE_mark" id="bf05754f-469f-4075-b7c9-0c2562ab8ae3"><span class="GINGER_SOFTWARE_mark" id="fd74c46f-32ee-48bc-a9b6-b355d1b42d6d"><span class="GINGER_SOFTWARE_mark" id="433a3371-f69a-4457-89a6-5b9dac46b721"><span class="GINGER_SOFTWARE_mark" id="48ab9c2e-4859-438e-bf05-871a07dc516b"><span class="GINGER_SOFTWARE_mark" id="01502561-bb7e-418d-b946-1da71e34fbd7"><span class="GINGER_SOFTWARE_mark" id="e9883710-82d1-4cd1-8f54-6f2f17922c1a">memcli</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="64df3f56-759e-4868-bf0c-c36200ec79a6"><span class="GINGER_SOFTWARE_mark" id="00ec3843-e63a-461e-930d-d4de59bffb7a"><span class="GINGER_SOFTWARE_mark" id="e67cf785-e31f-4e99-bd91-7baddb38c2ca"><span class="GINGER_SOFTWARE_mark" id="1cb7820d-d010-453e-973a-2d585e5c1349"><span class="GINGER_SOFTWARE_mark" id="5be7a574-5408-4219-88f8-056125d83781"><span class="GINGER_SOFTWARE_mark" id="53760ef9-c570-428b-a2e3-5b4dd99ebcee"><span class="GINGER_SOFTWARE_mark" id="2ffb63f2-fcb6-4bbf-a577-867a02b8ac7b">:</span></span></span></span></span></span></span>get<span class="GINGER_SOFTWARE_mark" id="4dca460d-e184-4319-ba86-2f50da3ada0a"><span class="GINGER_SOFTWARE_mark" id="15b556f6-5be5-4639-b0cb-1d5d066451ef"><span class="GINGER_SOFTWARE_mark" id="fd7a522d-18d4-476e-895c-5ceb8daeb349"><span class="GINGER_SOFTWARE_mark" id="6e0d29a5-80b4-4c34-9b79-7759c575488f"><span class="GINGER_SOFTWARE_mark" id="46bd833f-f87a-41c3-aa17-4ccb678683bd"><span class="GINGER_SOFTWARE_mark" id="e7ec7478-4ccb-459f-8cf3-7cb0af4ae6e0"><span class="GINGER_SOFTWARE_mark" id="36a5d7c7-0394-42b1-9ec3-eab3158ab623">(</span></span></span></span></span></span></span>key)) <span class="GINGER_SOFTWARE_mark" id="fc97b2d6-fb40-4361-a2aa-36296fe02217"><span class="GINGER_SOFTWARE_mark" id="5c537b1d-7d8c-481a-be4b-2e2ec24d1f91"><span class="GINGER_SOFTWARE_mark" id="bb73c9cd-3ee3-4f73-bf97-b358bffb1ee4"><span class="GINGER_SOFTWARE_mark" id="64803939-767e-4f49-a46f-2cefe81b41cf"><span class="GINGER_SOFTWARE_mark" id="bf845f79-2aea-48ad-9d32-00f29c885c71"><span class="GINGER_SOFTWARE_mark" id="cb05364c-e5ae-4133-8a80-b942af56f42e">{
        </span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="3af52dcb-8a4f-45c7-84c8-7e2003c28841">return</span> result<span class="GINGER_SOFTWARE_mark" id="c67b912b-7e82-43ce-a3cb-a1b504da7475"><span class="GINGER_SOFTWARE_mark" id="90ffec3c-6514-4fee-a636-c8a9063ae8d0"><span class="GINGER_SOFTWARE_mark" id="e8ecd233-06f8-4a9d-a620-9b02137f34ed"><span class="GINGER_SOFTWARE_mark" id="9f12bf6b-fa98-44b2-9251-27e67ec664c6"><span class="GINGER_SOFTWARE_mark" id="f029abe8-91eb-4d39-b863-64ac887e37fb"><span class="GINGER_SOFTWARE_mark" id="483ce540-6922-441b-a01c-7f80b6882ae5">
}</span></span></span></span></span></span> <span class="GINGER_SOFTWARE_mark" id="6ad8df77-6d97-483c-9e3f-af3949e75405">else</span> <span class="GINGER_SOFTWARE_mark" id="4fa9042a-9316-4f29-9687-ca43eec0ede2"><span class="GINGER_SOFTWARE_mark" id="5f7fb148-6af5-4939-b361-be973ae2974e"><span class="GINGER_SOFTWARE_mark" id="3b7ef7c4-4348-4769-b15d-5df2995931cc"><span class="GINGER_SOFTWARE_mark" id="d7e010a6-0258-4885-bd1e-cfa7b967625d"><span class="GINGER_SOFTWARE_mark" id="cb8a7cfe-b2e7-41b1-b290-b8d39a73c30d"><span class="GINGER_SOFTWARE_mark" id="01e8656c-cb2f-4114-853b-3f9b1420c42b"><span class="GINGER_SOFTWARE_mark" id="5cd54535-daa9-42bf-8188-6a0829822e5d">{
        </span></span></span></span></span></span></span># Query is not in Cache, Get query <span class="GINGER_SOFTWARE_mark" id="db21e73e-ef4e-4867-9f8c-bede2343d8cc"><span class="GINGER_SOFTWARE_mark" id="1678ef77-91d7-4f36-ab13-c7579db30576"><span class="GINGER_SOFTWARE_mark" id="b4bde1a4-489a-45f0-9af2-dfd77e02b17a"><span class="GINGER_SOFTWARE_mark" id="4fd32154-5c18-4a1a-b534-095831d095c4"><span class="GINGER_SOFTWARE_mark" id="aa9ce7ef-a4c1-424a-b1c7-7a394ff548ef"><span class="GINGER_SOFTWARE_mark" id="21c74f01-46af-4b6b-93f0-a92ff5fdeb19"><span class="GINGER_SOFTWARE_mark" id="9cc3963b-f602-4875-b25a-4929d1eb2265">resultset</span></span></span></span></span></span></span> from your database server and convert it to <span class="GINGER_SOFTWARE_mark" id="02dcbedd-1a5b-4450-8800-eccb4ccffe02"><span class="GINGER_SOFTWARE_mark" id="f285b862-7a02-4084-ba64-5f439200fdf2"><span class="GINGER_SOFTWARE_mark" id="ada7f5b3-f393-4361-935f-e02d17748f69"><span class="GINGER_SOFTWARE_mark" id="ca79f4e9-fa90-424a-b377-223a27552296"><span class="GINGER_SOFTWARE_mark" id="4c194c81-7937-4513-9189-73dcdf1b43e5"><span class="GINGER_SOFTWARE_mark" id="50ec7ad0-9913-44b1-9dfc-14cfc9ce2dc8"><span class="GINGER_SOFTWARE_mark" id="a1eaa376-1a46-44ba-be40-22aded03a1a5">resultset</span></span></span></span></span></span></span> array
        <span class="GINGER_SOFTWARE_mark" id="8ddc9fe9-7248-4795-bcdc-20e81159d8a2">handler</span> = run_sql<span class="GINGER_SOFTWARE_mark" id="78d09e4b-a5cb-43f0-9210-5f9a7025634c"><span class="GINGER_SOFTWARE_mark" id="705de6f3-47d7-4f6e-85dc-af76c31b3f38"><span class="GINGER_SOFTWARE_mark" id="e18d7822-e341-45b6-a710-2f2d15471c1b"><span class="GINGER_SOFTWARE_mark" id="ce761ebe-06a3-4f63-9193-d00f34655efa"><span class="GINGER_SOFTWARE_mark" id="834352b4-03fe-4258-b1f2-dd938d4fe771"><span class="GINGER_SOFTWARE_mark" id="b2713806-c282-4c1e-ab28-8e76beacef43"><span class="GINGER_SOFTWARE_mark" id="3c839774-bdeb-409e-bc6c-834ee2abf0a6">(</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="49433c34-0208-41e8-99e7-7a4475804ee4"><span class="GINGER_SOFTWARE_mark" id="0e4b09c5-bf89-495f-97c8-d398d71493a5"><span class="GINGER_SOFTWARE_mark" id="1cb236ea-8590-48c6-8f3f-f923ad5895bf"><span class="GINGER_SOFTWARE_mark" id="0e47892d-4bae-4fc6-99a9-1803a9a17d1e"><span class="GINGER_SOFTWARE_mark" id="f222e0b8-681c-46e3-9a0f-c46b85e69147"><span class="GINGER_SOFTWARE_mark" id="19c18cec-6319-484b-b178-00c54fb23cbc"><span class="GINGER_SOFTWARE_mark" id="a376b201-06ba-414f-b942-7f1cb67238d5">sql</span></span></span></span></span></span></span>, user_id)
        rows_array = handler<span class="GINGER_SOFTWARE_mark" id="9adbd33e-565a-4dac-a08d-03bf7fac95d3"><span class="GINGER_SOFTWARE_mark" id="9b9547dd-ba77-4d3a-b848-14682be0d098"><span class="GINGER_SOFTWARE_mark" id="d3755362-705f-428b-8192-e9664eb15812"><span class="GINGER_SOFTWARE_mark" id="07246b65-8aba-42b1-a1ea-04a3f83415e6"><span class="GINGER_SOFTWARE_mark" id="c807f1d1-aa97-4ca5-bee1-4b12bde45aa1"><span class="GINGER_SOFTWARE_mark" id="9dfefbf6-2721-4ecb-a1fb-6c493011f933"><span class="GINGER_SOFTWARE_mark" id="ce2f735f-3fe8-48ca-9ba1-e46d7c3dfb66">:</span></span></span></span></span></span></span>turn_into_an_array

        # Cache it for five minutes
        <span class="GINGER_SOFTWARE_mark" id="5a154327-5b35-45ad-a2b2-e931ed77d158"><span class="GINGER_SOFTWARE_mark" id="f1163065-64c6-453d-8b75-f13ff3de33a6"><span class="GINGER_SOFTWARE_mark" id="32821523-0590-40d4-b914-b72b7f58db72"><span class="GINGER_SOFTWARE_mark" id="cd5cbdf0-6843-454b-b679-79e3ca98b86f"><span class="GINGER_SOFTWARE_mark" id="ed365b41-9c33-48cb-928f-a9aa8cd5fa86"><span class="GINGER_SOFTWARE_mark" id="29267835-176c-45c1-b781-25f2cff9fcac"><span class="GINGER_SOFTWARE_mark" id="428c8100-6917-4a45-9c65-50bf71f174a4">memcli</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="c951b32e-560f-4fd2-8709-85559ebf09c8"><span class="GINGER_SOFTWARE_mark" id="86edea8b-4375-4274-a657-cdb4fc8c978e"><span class="GINGER_SOFTWARE_mark" id="a6bc4340-24b6-4985-b1ab-cecc7ef1e79f"><span class="GINGER_SOFTWARE_mark" id="0bf52360-48a6-4949-a9d7-c1d617ab015c"><span class="GINGER_SOFTWARE_mark" id="5f6e8273-4ed6-4564-890a-aa4c38ce1f4b"><span class="GINGER_SOFTWARE_mark" id="0d4cef82-c9d5-4ed8-94ab-7f2285c1c541"><span class="GINGER_SOFTWARE_mark" id="01ee4760-2b1f-4d14-b38e-2fca1bc35819">:</span></span></span></span></span></span></span>set<span class="GINGER_SOFTWARE_mark" id="8e9ff0a5-c91b-4d63-b05b-91f6b0420d45"><span class="GINGER_SOFTWARE_mark" id="482efd36-7496-4e9b-aab8-a831c8031f73"><span class="GINGER_SOFTWARE_mark" id="8d5fde14-29b2-45db-96d4-0f84b8dbe3fd"><span class="GINGER_SOFTWARE_mark" id="b99edac7-d029-46d4-94bc-444998b27ac9"><span class="GINGER_SOFTWARE_mark" id="768999c4-ba14-428d-9080-28ac03595901"><span class="GINGER_SOFTWARE_mark" id="283f7915-79d2-4408-92e6-e57eaabd1fc7"><span class="GINGER_SOFTWARE_mark" id="e36a36d5-9b20-4da4-8313-fed35426d914">(</span></span></span></span></span></span></span>key, rows_array, 5 * 60)
        <span class="GINGER_SOFTWARE_mark" id="d09a8d2c-acf8-48cc-91d8-622b2a312380">return</span> rows_array<span class="GINGER_SOFTWARE_mark" id="d6a03489-9b80-4b10-afb1-86d0b568141e"><span class="GINGER_SOFTWARE_mark" id="ef1bb58d-e7ea-4077-8570-7b86b1cd8cdf"><span class="GINGER_SOFTWARE_mark" id="8e8d1ce0-1638-41a7-b1ba-e7bd2f5212c0"><span class="GINGER_SOFTWARE_mark" id="c83a3f24-950b-4c34-8f56-33e99ae381d7"><span class="GINGER_SOFTWARE_mark" id="98a7877c-0edb-465e-a1b3-d5cafc19dc3a"><span class="GINGER_SOFTWARE_mark" id="8fe76b70-e2c7-4987-88d8-ab928722edfa">
}</span></span></span></span></span></span></pre>
<p style="text-align:justify;" align="left">Notice that the SQL query result-set was entered to cache with five-minute expiration time, as an example.</p>
<p style="text-align:justify;" align="left"><b>Stale data in cache and invalidation of cached items<br />
</b>Unless you actively invalidate the cached item, when a user (or your database) makes a change, it can take up to five minutes (or more, depending on cache item expiration time) for users to see the correct new data. This is a key issue when implementing a Do-It-Yourself caching strategy.<b></b></p>
<p style="text-align:justify;" align="left">When a user comes along and edits data, you can keep the cache in sync in two main ways:</p>
<ol style="text-align:justify;">
<li>You can update the item in <span class="GINGER_SOFTWARE_mark" id="15cbfbfa-4682-4cec-8e4a-be80a22425a6"><span class="GINGER_SOFTWARE_mark" id="8f4dc786-3fc6-443e-8615-a2b1db3a002a"><span class="GINGER_SOFTWARE_mark" id="90b54a2c-4e2c-4f91-b620-8ff3572d5ccc"><span class="GINGER_SOFTWARE_mark" id="92a1a21e-f6be-45cb-b08f-f5bef955bac2"><span class="GINGER_SOFTWARE_mark" id="da118eda-f0b1-4900-8aea-a3be12b4b7b8"><span class="GINGER_SOFTWARE_mark" id="5605585e-afa0-41cd-9f12-093e8b732075"><span class="GINGER_SOFTWARE_mark" id="4e89b680-cb44-4974-8027-e39db552f240">cache</span></span></span></span></span></span></span>; or</li>
<li>Delete the old item.</li>
</ol>
<p style="text-align:justify;" align="left"><b>Expiration<br />
</b>The most basic invalidation happens by defining the Expiration period. Even if you<span class="GINGER_SOFTWARE_mark" id="4b6fa23d-071b-4430-a800-8990e234d2ca"><span class="GINGER_SOFTWARE_mark" id="1474704e-037b-471d-a9ba-55f122f1d701"><span class="GINGER_SOFTWARE_mark" id="23528eeb-a7da-4159-8c6a-5f6b1134b551"><span class="GINGER_SOFTWARE_mark" id="d8841fed-4766-4944-ab1b-f5f9804167fb"><span class="GINGER_SOFTWARE_mark" id="bf9fe42a-3cf5-43e9-b4c4-8c5f942970d7"><span class="GINGER_SOFTWARE_mark" id="231d79ed-0671-4902-82d6-904b14a65d02"><span class="GINGER_SOFTWARE_mark" id="ab94e40a-9d61-4d38-b7e5-9ca8c3f0cafd">&#8216;re actively deleting</span></span></span></span></span></span></span> or overwriting cached data, you&#8217;ll still want to have the cache expire occasionally.</p>
<pre> # Cache it for five minutes
  <span class="GINGER_SOFTWARE_mark" id="1899068a-8573-47d8-b7be-9b06cf46af4b"><span class="GINGER_SOFTWARE_mark" id="290da69f-97b3-42e5-b37a-4ba0fe25eb49"><span class="GINGER_SOFTWARE_mark" id="7b683599-be57-45fb-9911-860a60cd43bb"><span class="GINGER_SOFTWARE_mark" id="c73ec54d-4c02-4907-bc33-e037be653264"><span class="GINGER_SOFTWARE_mark" id="34768bb4-2124-4959-9444-2c83c9ba3003"><span class="GINGER_SOFTWARE_mark" id="e4812544-c10b-4c73-aa19-f870a990c677"><span class="GINGER_SOFTWARE_mark" id="a11c5da5-f38a-4aa2-85b1-078f6692dd53">memcli</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="9e13ee9e-b2b3-48a4-9c65-36f0847115dc"><span class="GINGER_SOFTWARE_mark" id="d33c002e-0db9-4baf-b053-cf5797045c96"><span class="GINGER_SOFTWARE_mark" id="ed17f474-7de8-448a-a9ea-a6ca4cbacfc0"><span class="GINGER_SOFTWARE_mark" id="1edb535d-859b-4adf-a435-c05aecbe1c06"><span class="GINGER_SOFTWARE_mark" id="8f5f3c4a-7669-4315-8015-1d2b5e65160b"><span class="GINGER_SOFTWARE_mark" id="961fed64-e64b-44ed-b53f-efe3ac050b07"><span class="GINGER_SOFTWARE_mark" id="2f8ad62f-5d34-4ddb-ad2f-9a18a0ca1e46">:</span></span></span></span></span></span></span>set<span class="GINGER_SOFTWARE_mark" id="d97935f3-b9fd-4e43-be82-624242b2800b"><span class="GINGER_SOFTWARE_mark" id="f2a88a2c-7110-489c-b629-d5b7e3abd3a2"><span class="GINGER_SOFTWARE_mark" id="11af2932-8556-4686-a00f-e35b15f6ba7c"><span class="GINGER_SOFTWARE_mark" id="c2800c93-cd2b-4f19-be09-ce2fe317dbd9"><span class="GINGER_SOFTWARE_mark" id="470c6b11-1daf-4ddf-8ca7-3560a148dbd1"><span class="GINGER_SOFTWARE_mark" id="27e3f5ab-6507-4e12-8512-b8d647699ed2"><span class="GINGER_SOFTWARE_mark" id="25e7d159-bcc5-4104-953b-bfdbba95acc4">(</span></span></span></span></span></span></span>key, rows_array, <b>5</b><b> </b><b>*</b><b> </b><b>60</b>)</pre>
<p style="text-align:justify;" align="left">Expiration times can be set from 0, meaning &#8220;never expire&#8221;, to 30 days. Any time higher than 30 days is interpreted as a timestamp date.</p>
<p style="text-align:justify;" align="left"><b><span class="GINGER_SOFTWARE_mark" id="922f37bb-13ba-443b-b805-4f2ff375751c"><span class="GINGER_SOFTWARE_mark" id="271f46d2-38d8-4812-bb89-4dad56e9cdb9"><span class="GINGER_SOFTWARE_mark" id="407c3037-1084-4f9f-bd34-f423ee20623c"><span class="GINGER_SOFTWARE_mark" id="57687e11-e814-48ef-82b4-76f1bc2b9bd6"><span class="GINGER_SOFTWARE_mark" id="a7def658-3775-4a7e-ba36-06b5b7da4fd5"><span class="GINGER_SOFTWARE_mark" id="b71f8c6f-b023-495d-9aa4-e85765528130"><span class="GINGER_SOFTWARE_mark" id="56dfa0df-3548-4945-b1b2-14a852b219af">delete</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="90ccd296-dbc3-48b5-ae3f-e86dbe1e5484"><span class="GINGER_SOFTWARE_mark" id="20c6d2cd-4e91-40dc-b4c2-5d55de4fa5c4"><span class="GINGER_SOFTWARE_mark" id="1a6d32aa-beff-428b-a35d-625fc5ebb33c"><span class="GINGER_SOFTWARE_mark" id="8adb02fd-1771-45f0-b3d4-40802b7ca631"><span class="GINGER_SOFTWARE_mark" id="bef823da-3138-456d-aced-42a606dae2ee"><span class="GINGER_SOFTWARE_mark" id="35572ffa-0a7a-4fbd-80e6-2f1066f3f07a"><span class="GINGER_SOFTWARE_mark" id="c3e3585f-a1a5-47d9-a467-34a168247fb6">(</span></span></span></span></span></span></span>)<br />
</b>The simplest method of invalidation is to simply delete an entry and have your website re-cache the data the next time it&#8217;s fetched. For example, when a user updates her bio, you want her to see her latest info when she reloads the page:</p>
<pre> <span class="GINGER_SOFTWARE_mark" id="a9c78baa-a898-43d7-a8fd-420f9ad620df"><span class="GINGER_SOFTWARE_mark" id="a583769d-74b6-4dd0-b44c-fbe5460c798b"><span class="GINGER_SOFTWARE_mark" id="725cfd5d-f062-45d8-9df9-c367e66648ba"><span class="GINGER_SOFTWARE_mark" id="792dbea4-9ba5-4d08-b6a5-80ec060e93b2"><span class="GINGER_SOFTWARE_mark" id="d4a2d696-1543-4e39-b6f0-783d2655e646"><span class="GINGER_SOFTWARE_mark" id="fa5ff41c-8c4c-4dd8-98ff-670eb1940e69"><span class="GINGER_SOFTWARE_mark" id="f51660a0-dfe0-44df-8437-4f7bcfb821fd">sql</span></span></span></span></span></span></span> = "SELECT * FROM user WHERE user_id =<span class="GINGER_SOFTWARE_mark" id="53a75b8c-6bd3-47ca-b50d-c91efd9d0af7"><span class="GINGER_SOFTWARE_mark" id="fee0c763-b33e-45d2-9e27-0bb7e7f5bc55"><span class="GINGER_SOFTWARE_mark" id="b176907f-361f-4487-b00d-ccc3b8ab3230"><span class="GINGER_SOFTWARE_mark" id="950b7c48-d417-4e28-aac9-2986a8a388a9"><span class="GINGER_SOFTWARE_mark" id="29379bd5-331c-42dc-a5e9-4812b5029bb2"><span class="GINGER_SOFTWARE_mark" id="db50c80d-beae-41c4-b68c-5774d521dfe3"><span class="GINGER_SOFTWARE_mark" id="7bcccf37-dff3-4bea-a512-0b6b020143a3"> ?</span></span></span></span></span></span></span>"
 <span class="GINGER_SOFTWARE_mark" id="4a831e6c-cdbd-4801-ac75-d942b7f36c6a"><span class="GINGER_SOFTWARE_mark" id="d77a0ea1-4eda-4999-9f3b-8bb30ee78a96"><span class="GINGER_SOFTWARE_mark" id="3a85ba88-8a92-400d-a296-1645f4e4f578"><span class="GINGER_SOFTWARE_mark" id="04c66eb3-7c40-4e39-b3a7-e64ec4fc945d"><span class="GINGER_SOFTWARE_mark" id="61fc4b67-b9b0-44a3-b9d5-4666f769baa0"><span class="GINGER_SOFTWARE_mark" id="d7970719-11dd-4c22-b999-8a0186d3a03c"><span class="GINGER_SOFTWARE_mark" id="5b508492-7989-4f9c-9c6f-08682034df33">key</span></span></span></span></span></span></span> = 'SQL:'<span class="GINGER_SOFTWARE_mark" id="779a250b-f31e-4897-a12f-6bf2373c1b74"><span class="GINGER_SOFTWARE_mark" id="291c8fbf-12df-4051-8010-759e366b400c"><span class="GINGER_SOFTWARE_mark" id="f388e9b9-c4f1-4b21-afb9-3ca95433efbe"><span class="GINGER_SOFTWARE_mark" id="7ac77eb5-3ae1-4d15-a839-6a806d092f87"><span class="GINGER_SOFTWARE_mark" id="cd1cf17c-6653-406b-a198-e1fb9898c0ca"><span class="GINGER_SOFTWARE_mark" id="f0ebf2de-0be0-4809-8815-bc41d25db2eb"><span class="GINGER_SOFTWARE_mark" id="572dd10a-8d18-41b6-8dff-1bede9d528dc"> .</span></span></span></span></span></span></span> user_id<span class="GINGER_SOFTWARE_mark" id="50931fd4-3c41-4f22-b766-956bce106e73"><span class="GINGER_SOFTWARE_mark" id="27e3e26e-5f37-4666-8c4c-54d6279fc545"><span class="GINGER_SOFTWARE_mark" id="fc645702-7af4-47c6-876c-bea78c983577"><span class="GINGER_SOFTWARE_mark" id="832e8b4c-0e38-410a-bdfe-567d7066bbe4"><span class="GINGER_SOFTWARE_mark" id="d62278bc-c7ba-47bc-81ed-46ff621e6738"><span class="GINGER_SOFTWARE_mark" id="8485adde-4e2b-4b0f-8a96-ca6714363a00"><span class="GINGER_SOFTWARE_mark" id="42bb6dd8-5515-461d-b66b-bd223dd0a1ec"> .</span></span></span></span></span></span></span> ':' . md5sum<span class="GINGER_SOFTWARE_mark" id="a2926a10-9858-4503-9adb-2f3b2f92336c"><span class="GINGER_SOFTWARE_mark" id="a40c8550-ee5d-447a-87a8-bb28a7578ff6"><span class="GINGER_SOFTWARE_mark" id="c412bbc2-6078-411e-a3e2-b50987e13d06"><span class="GINGER_SOFTWARE_mark" id="89330d33-75ee-4d6d-873f-449dfc6200fb"><span class="GINGER_SOFTWARE_mark" id="b16b1c1d-a2b4-4c2b-89bc-4358057f344c"><span class="GINGER_SOFTWARE_mark" id="3a902f67-b4f3-4d38-8589-836917105001"><span class="GINGER_SOFTWARE_mark" id="d7d24da2-eb6f-43db-9fae-2f6565897211">(</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="5dda4c64-53bf-4d23-94ba-ff43e2d14e7d"><span class="GINGER_SOFTWARE_mark" id="cb8220a0-1fac-4f1d-889b-5096f4477adc"><span class="GINGER_SOFTWARE_mark" id="480c9af9-88e6-4bbf-9eb7-18e60349152a"><span class="GINGER_SOFTWARE_mark" id="3375683a-277a-4d53-974e-af8a57430476"><span class="GINGER_SOFTWARE_mark" id="bc9e5843-79da-4c5b-b03d-7fe6756e706a"><span class="GINGER_SOFTWARE_mark" id="459c53aa-324c-4749-978b-aba05d68ead2"><span class="GINGER_SOFTWARE_mark" id="29d2fa10-df0e-4946-9a1d-5d98cb6fd817">sql</span></span></span></span></span></span></span>)

 <span class="GINGER_SOFTWARE_mark" id="9d0dc1e5-e78a-429b-85d1-0766e3a27950"><span class="GINGER_SOFTWARE_mark" id="57491478-2594-4630-95d1-2c16c2187022"><span class="GINGER_SOFTWARE_mark" id="cf341def-0215-4d2f-a3ab-f6aa750898c4"><span class="GINGER_SOFTWARE_mark" id="b8ced8ec-b727-4656-a53f-0e2eeec909f5"><span class="GINGER_SOFTWARE_mark" id="5eef6988-7806-443d-a51c-2f60fc0758c4"><span class="GINGER_SOFTWARE_mark" id="299ca7e7-8e4b-4128-bce3-28c6254d6f8d"><span class="GINGER_SOFTWARE_mark" id="f5731a40-04b4-41b5-8d8e-8029f3938c79">memcli</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="cfd907f4-9c20-43e7-bd48-7047ea2bb56e"><span class="GINGER_SOFTWARE_mark" id="f42b2ba9-51e4-47dc-8370-70c82634e58d"><span class="GINGER_SOFTWARE_mark" id="b5e3cf12-e5ef-493c-947f-b76ebcf497b8"><span class="GINGER_SOFTWARE_mark" id="956712d0-45ee-4b48-bdff-60d7b8bc82e2"><span class="GINGER_SOFTWARE_mark" id="7594ef2a-fa6a-45c2-8add-2f2592d9ea14"><span class="GINGER_SOFTWARE_mark" id="c064ac05-f504-4dbe-8c36-6e259f622b10"><span class="GINGER_SOFTWARE_mark" id="0df77f8e-c11f-4ad7-938e-7fc9435a55e0">:</span></span></span></span></span></span></span>delete<span class="GINGER_SOFTWARE_mark" id="dabbf3c8-288d-4ba7-beb1-5f0f08c0e1e7"><span class="GINGER_SOFTWARE_mark" id="97991ef2-53e7-407f-b1b6-5ae1a25c3d7d"><span class="GINGER_SOFTWARE_mark" id="d1aa54a0-bf21-4cec-afec-352afcae22c5"><span class="GINGER_SOFTWARE_mark" id="246fb1da-dfe1-43ce-b1f6-650c2c750271"><span class="GINGER_SOFTWARE_mark" id="0d42c49a-b01a-4fe2-a590-07a34f1f8deb"><span class="GINGER_SOFTWARE_mark" id="b9904f84-a09a-4002-a89b-1585c4ed96e3"><span class="GINGER_SOFTWARE_mark" id="c5d56961-6432-444b-a29b-50b21a3a394e">(</span></span></span></span></span></span></span>key)</pre>
<p style="text-align:justify;" align="left">The next time this query will be requested it will be fetched from the database and repopulate the cache.</p>
<p style="text-align:justify;" align="left"><tt><b><span class="GINGER_SOFTWARE_mark" id="fae381d6-1ab9-4a93-a854-80fd835080fc"><span class="GINGER_SOFTWARE_mark" id="7135f486-d4d0-46c1-b61b-8389e8747a3c"><span class="GINGER_SOFTWARE_mark" id="736f69a9-5c85-4140-a0fb-b30c1308ed35"><span class="GINGER_SOFTWARE_mark" id="68a2ea76-c470-4954-968a-7829dab1ba2a"><span class="GINGER_SOFTWARE_mark" id="caa84c1c-56c4-4764-bfbf-c9f07a7614b0"><span class="GINGER_SOFTWARE_mark" id="4bcba721-e5c2-4642-8e62-ac7dea10efef"><span class="GINGER_SOFTWARE_mark" id="b96d342e-c4fc-4a1d-844e-9ba603e6b8bd">set</span></span></span></span></span></span></span><span class="GINGER_SOFTWARE_mark" id="43a3ce18-4d75-4e2f-81db-9787d2a54b90"><span class="GINGER_SOFTWARE_mark" id="00c1d711-c7ac-46cb-b8a8-a441baec4f5f"><span class="GINGER_SOFTWARE_mark" id="903180ac-71c1-4cfa-b2d1-c078c6aada8a"><span class="GINGER_SOFTWARE_mark" id="411398d1-74e2-413c-82c1-405e773325bf"><span class="GINGER_SOFTWARE_mark" id="1548d317-54ae-4653-818b-257cfb91082e"><span class="GINGER_SOFTWARE_mark" id="839d70c2-ac85-4486-b240-a125d1552c3c"><span class="GINGER_SOFTWARE_mark" id="cc2eb309-7056-4d17-addf-85c53956d5da">(</span></span></span></span></span></span></span>)</b></tt><b><br />
</b>A more efficient idea is to actively update your cache as your data changes. When our user updates her bio, take the bio object and move it into the cache via &#8216;set&#8217;. You can pass the new data into the same routine that normally checks for data, or however you want to structure it.</p>
<h3 style="text-align:justify;" align="left"><b>Summary about DYI application data caching </b></h3>
<p style="text-align:justify;" align="left">Data caching is considered a key component of a high performance and scalable application architecture<b>. </b>Fast page load response time is a one of the key metrics for user satisfaction. <span class="GINGER_SOFTWARE_mark" id="d22b87f4-38c3-4db0-8e60-ff9f05558415"><span class="GINGER_SOFTWARE_mark" id="91053898-a47b-493b-a7f4-d1b0fd7059d0"><span class="GINGER_SOFTWARE_mark" id="1a2e7119-3127-481a-8685-72e1481ee8f4"><span class="GINGER_SOFTWARE_mark" id="781d17de-c5dc-414c-ab1d-7a19d7f8c530"><span class="GINGER_SOFTWARE_mark" id="769adbcb-e824-413a-8100-2879b43733c7"><span class="GINGER_SOFTWARE_mark" id="1ad0548b-8fea-4d8c-b174-1c8c03982b51"><span class="GINGER_SOFTWARE_mark" id="db6e2b02-623c-49e7-88eb-6f3b612fe09f">Memcached</span></span></span></span></span></span></span> and similar distributed caching technologies are used today in most (if not all) well-known big <span class="GINGER_SOFTWARE_mark" id="be8c4a7a-5ad8-4837-b023-18665f1da623"><span class="GINGER_SOFTWARE_mark" id="a20d4eae-1806-4eaa-9354-5aec12df7b30"><span class="GINGER_SOFTWARE_mark" id="bdd3d854-792a-4c3e-b042-7c1836818767"><span class="GINGER_SOFTWARE_mark" id="134d419e-57a7-48d7-93a8-837e38348d8b"><span class="GINGER_SOFTWARE_mark" id="87c54707-d728-4cc3-acfd-c7b57aa231f6"><span class="GINGER_SOFTWARE_mark" id="cd4b09c2-257f-4bc1-af33-69c871421606"><span class="GINGER_SOFTWARE_mark" id="d919f85a-53e7-4782-bb43-2fec911c7576">websites</span></span></span></span></span></span></span> (Linkedin, Facebook <span class="GINGER_SOFTWARE_mark" id="ead6a576-e14d-4fa6-b6ad-5d4015d94263"><span class="GINGER_SOFTWARE_mark" id="3f1e34e1-5696-46bd-9aef-571a28c4139b"><span class="GINGER_SOFTWARE_mark" id="7a78bd78-c391-46ff-937e-3ad09214bdf9"><span class="GINGER_SOFTWARE_mark" id="80db6d3a-aa8b-45b9-9c42-06b92d154d4d"><span class="GINGER_SOFTWARE_mark" id="47fe70c4-27f2-45c9-ae7e-4263280a4e53"><span class="GINGER_SOFTWARE_mark" id="1ad5e31f-ec0f-41e4-8f57-9fdf484af03a"><span class="GINGER_SOFTWARE_mark" id="b9286325-2486-4265-b6d0-6afaf38c8537">others</span></span></span></span></span></span></span>). The challenge is doing all the extra work custom DIY caching represents for a development team to implement, test, and maintain.</p>
<p style="text-align:justify;" align="left">If you think I’m painting a dark picture for Do-It-Yourself, <span class="GINGER_SOFTWARE_mark" id="e85026be-1290-4357-9972-2d7245ec4047"><span class="GINGER_SOFTWARE_mark" id="d7f21d06-7a37-4cfc-9c97-ab72ba3bebaf"><span class="GINGER_SOFTWARE_mark" id="7a65d0b8-c5dc-41ae-a5cd-d4c0133dff35"><span class="GINGER_SOFTWARE_mark" id="a3aa1ba5-5923-4ae6-88f1-89a12a2a12e0"><span class="GINGER_SOFTWARE_mark" id="324ac649-98c4-44e1-be1c-813df5be382a"><span class="GINGER_SOFTWARE_mark" id="51bcd958-0ead-4167-989f-c91a6c7e157b"><span class="GINGER_SOFTWARE_mark" id="ce58ff90-6db8-4df1-b604-02ed8521ab7e">home-grown</span></span></span></span></span></span></span> caching, you’re right. Why? Because nowadays there are alternatives to use a commercial smart caching layer. The cost to purchase third-party caching software is much more accurately defined, than the unknown cost of developing caching code yourself.</p>
<p style="text-align:justify;">But, you need to decide for yourself if that’s the best option for your situation.</p>
<h3 style="text-align:justify;" align="left"><b><span class="GINGER_SOFTWARE_mark" id="e7f2e59d-7691-46a5-86f2-96cec71bfbc1"><span class="GINGER_SOFTWARE_mark" id="61d3ed18-a034-43a1-8f2a-2b4528f72e03"><span class="GINGER_SOFTWARE_mark" id="aa001220-6275-4f66-a60f-9be225dc38d1"><span class="GINGER_SOFTWARE_mark" id="0e766bd5-15ac-4f7a-a48d-7bc829612aa3"><span class="GINGER_SOFTWARE_mark" id="87c357d2-e1de-44ba-a37e-8f27df8c50ec"><span class="GINGER_SOFTWARE_mark" id="cf1e0831-b814-4375-bb1d-1f21b29e4eb9"><span class="GINGER_SOFTWARE_mark" id="343d0c1c-e4fc-4876-9ac3-42f142c4cc02">SafePeak’s</span></span></span></span></span></span></span> “Automated Dynamic Caching”</b></h3>
<p style="text-align:justify;" align="left"><a href="http://www.safepeak.com/Product/Safepeak-Demo" rel="nofollow"><span class="GINGER_SOFTWARE_mark" id="b11a47d9-4868-4755-8e7a-6886ec40400f"><span class="GINGER_SOFTWARE_mark" id="9215c06b-960f-4316-9cb7-b76bc97920a2"><span class="GINGER_SOFTWARE_mark" id="b59b7642-9680-4aef-881a-a0bb37bcbd92"><span class="GINGER_SOFTWARE_mark" id="7a49e50c-f6a8-429e-b8a4-43afaa98f5b1"><span class="GINGER_SOFTWARE_mark" id="4c7db7ab-4a0e-407a-af4a-6daa271b132e"><span class="GINGER_SOFTWARE_mark" id="f1ad7845-7e7c-46b5-89ea-986266414a21"><span class="GINGER_SOFTWARE_mark" id="fa95a962-e0d7-474d-8f61-8349a211f8c4">SafePeak</span></span></span></span></span></span></span></a> is pre-packaged software that is specifically designed to cache SQL Server queries. It automates many of the steps that developers would try to do manually with Memcached. And it doesn’t require any changes to application code. This makes it quick to deploy and useful to accelerate the performance of both 3<sup><span class="GINGER_SOFTWARE_mark" id="713c4994-0e88-45cf-8497-71a708620d1b"><span class="GINGER_SOFTWARE_mark" id="88e147d7-5c7a-4049-91b0-444467b2bfa7"><span class="GINGER_SOFTWARE_mark" id="2b384dd6-ead1-4f2a-a406-262ba12fb6a5"><span class="GINGER_SOFTWARE_mark" id="7c124fe2-8a83-4ee3-9164-351fe37eb1d4"><span class="GINGER_SOFTWARE_mark" id="b7c1f896-5b29-4120-b7c4-000aa23615d6"><span class="GINGER_SOFTWARE_mark" id="1d416a06-0b00-428e-a987-e7daf49c6019"><span class="GINGER_SOFTWARE_mark" id="f7f1f2e9-aeb1-4e98-b15a-ca08b48cbed6">rd</span></span></span></span></span></span></span></sup>-<span class="GINGER_SOFTWARE_mark" id="8fb9a71b-a38c-4fad-bde5-2aedc8414393"><span class="GINGER_SOFTWARE_mark" id="e9e28227-a46c-483b-b8e2-035004cfd5a2"><span class="GINGER_SOFTWARE_mark" id="3c84dcb8-4ccb-4714-b3f5-e29caaba8862"><span class="GINGER_SOFTWARE_mark" id="5308b15e-5294-474a-9f72-2f00e22baf86"><span class="GINGER_SOFTWARE_mark" id="3bfc902b-7b1b-424a-a77e-f37f20d4f742"><span class="GINGER_SOFTWARE_mark" id="8465140b-ee60-4388-a327-94ca0e3df2c6"><span class="GINGER_SOFTWARE_mark" id="692f090b-d156-4043-b62a-5a0a65c8dd28">party</span></span></span></span></span></span></span> applications (like SharePoint, CRM Dynamics) and your own custom applications.</p>
<p style="text-align:justify;" align="left">In my opinion, this makes Safepeak’s approach much easier for software and database architects and developers to use: you can literally “plug-in” SafePeak to production SQL Server systems. All queries are analyzed and managed by SafePeak automatically: their logic and dependent objects (like tables, views, triggers, procedures, etc.) are identified and analyzed, write commands are monitored and cache invalidation applied in real-time.</p>
<p style="text-align:justify;" align="left">And its app acceleration encompasses all of an app’s queries and procedures traffic immediately on deployment.</p>
<p style="text-align:justify;" align="left"><span class="GINGER_SOFTWARE_mark" id="fc3b1b8c-b373-4223-889f-fca7d52a7a7f"><span class="GINGER_SOFTWARE_mark" id="fad722e9-eae8-49da-ba78-51eacc4d32ad"><span class="GINGER_SOFTWARE_mark" id="e27b0136-bcec-43f5-807a-c4bdec557f16"><span class="GINGER_SOFTWARE_mark" id="391e6238-38d4-460e-99c8-ae871561ae3e"><span class="GINGER_SOFTWARE_mark" id="265cb2f7-435c-40c3-bd27-d91ab329a938"><span class="GINGER_SOFTWARE_mark" id="79ee0f45-e5f4-4b11-9e3e-d4aa97c25206"><span class="GINGER_SOFTWARE_mark" id="753114df-6409-42fa-8448-a06269530fbe">SafePeak’s</span></span></span></span></span></span></span> self-learning algorithms manage most of <span class="GINGER_SOFTWARE_mark" id="48f86cd1-17d4-4e6c-a2e1-77a5a3dfab51"><span class="GINGER_SOFTWARE_mark" id="7f589e5a-f29e-4d3a-b1bb-7886439bc8e6"><span class="GINGER_SOFTWARE_mark" id="4a03a3d1-ffb4-4e2c-920b-05c896aa2a0b"><span class="GINGER_SOFTWARE_mark" id="6a7feda1-b5ae-4302-bec3-d17ac3ee8e2b"><span class="GINGER_SOFTWARE_mark" id="6c7a66c8-3bcc-44f7-a4aa-4e150ff46ea0"><span class="GINGER_SOFTWARE_mark" id="e7b9570e-d198-4851-b2ff-fd218697e6f6"><span class="GINGER_SOFTWARE_mark" id="54b2bced-4b28-4f5a-a9f0-bf437de8b06c">configuration</span></span></span></span></span></span></span>; the rest is done via a dashboard tool that combines cache management with real-time monitoring and statistics. By analyzing both the database schemas and the SQL traffic, SafePeak creates optimized caching patterns specific to your applications and improves them over time. <span class="GINGER_SOFTWARE_mark" id="661e78ee-ae75-4ad7-b38d-85d2250cf21d"><span class="GINGER_SOFTWARE_mark" id="b5b2855f-4c46-47dc-8622-15d009a65163"><span class="GINGER_SOFTWARE_mark" id="934ddcd2-ccc6-4ae5-8555-b2e5b634c48f"><span class="GINGER_SOFTWARE_mark" id="636be5d9-7f50-4874-8cfa-fffcedd8d61c"><span class="GINGER_SOFTWARE_mark" id="682f3fa3-07f1-4ef6-a73d-fbf94f5555d2"><span class="GINGER_SOFTWARE_mark" id="8b196c6e-5665-4f26-b296-d66039d179bf"><span class="GINGER_SOFTWARE_mark" id="07d6776e-77d7-4981-90f7-afdd785d75f7">SafePeak</span></span></span></span></span></span></span> cache supports read-write database transactions and is dynamically kept in sync with any data changes as they happen.</p>
<p style="text-align:justify;" align="left">Here’s what the SafePeak dashboard looks like (screenshot from <a href="http://www.safepeak.com/Product/Resource-Library/SafePeak-Whitepaper" rel="nofollow">SafePeak’s <span class="GINGER_SOFTWARE_mark" id="00f25626-a8c7-433d-b971-1f671e6def09"><span class="GINGER_SOFTWARE_mark" id="f60641d4-8821-4f6c-8b05-0ecc72f09175"><span class="GINGER_SOFTWARE_mark" id="15665a8d-93c9-4c7d-b9e4-6039395258f8"><span class="GINGER_SOFTWARE_mark" id="4e67121f-f014-49a9-8a19-8442df17f6cc"><span class="GINGER_SOFTWARE_mark" id="deb00176-0f9e-4f93-97dd-d8131ca54255"><span class="GINGER_SOFTWARE_mark" id="5c899e43-dc81-4517-80d4-9f1061671a41"><span class="GINGER_SOFTWARE_mark" id="3349febc-7d82-4f16-987a-5efe85ae7bf7">whitepaper</span></span></span></span></span></span></span></a>):</p>
<p style="text-align:justify;" align="left"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/sfpeak-memcache.png" width="954" height="560" /></p>
<p style="text-align:justify;" align="left"><b>What Next?</b></p>
<p style="text-align:justify;" align="left">You have to decide what approach or technology is best for your situation.</p>
<p style="text-align:justify;" align="left">An effective DYI caching strategy, using libraries like Memcached or Velocity, has some advantages (better granular cache invalidation control, ability to store additional types of data besides database row-sets and others). But it can be tricky to accurately scope the work needed, hard to code correctly and comes at a real cost of time and focus away from developing application capabilities.</p>
<p style="text-align:justify;" align="left"><span class="GINGER_SOFTWARE_mark" id="46c4a45c-feb8-49e4-b924-f6d1e335b7df"><span class="GINGER_SOFTWARE_mark" id="648470ff-d58d-4189-a5e7-d5bf24c659c2"><span class="GINGER_SOFTWARE_mark" id="5e2eae67-cf6e-4325-bf23-aca31a4e19c3"><span class="GINGER_SOFTWARE_mark" id="5109759a-b9c4-4d5e-ad8d-eccae1df0224"><span class="GINGER_SOFTWARE_mark" id="4228cedb-0a95-4316-9c64-7e0cb0676260">SafePeak</span></span></span></span></span> offers an easier way to accelerate SQL Server based applications, with all caching benefits without any app re-programming. In a way, SafePeak’s design reminds me of a combination of Memcached caching and an In-Memory database, but enhanced with machine learning intelligence.</p>
<p style="text-align:justify;" align="left">Caching technology is designed to maximize operational efficiency of your existing infrastructure, so that you can scale more data and more workloads.</p>
<p style="text-align:justify;" align="left">I like SafePeak’s “plug-and-play” approach as it gets results <span class="GINGER_SOFTWARE_mark" id="ce8822b6-af10-40a4-806f-165be94ff958"><span class="GINGER_SOFTWARE_mark" id="e9bb2fe0-5ef2-4521-81db-3903da644e69"><span class="GINGER_SOFTWARE_mark" id="863b8b08-c290-4d7e-be10-388b26ccc13b"><span class="GINGER_SOFTWARE_mark" id="f9140685-66dd-488d-90da-e100d7ad22d6"><span class="GINGER_SOFTWARE_mark" id="6a40b362-a9ae-4433-8a6f-71c507d130ec"><span class="GINGER_SOFTWARE_mark" id="41d7be6f-d9b7-4b3f-a281-685e174e703e">fastest</span></span></span></span></span></span> and with minimum risk. If you’d like to check it out, they offer a free trial (<a href="http://bit.ly/dl-safepeak" rel="nofollow"><b>www.safepeak.com/download</b></a>) that includes one-on-one technical training &amp; assistance support.</p>
<p style="text-align:justify;" align="left">Now I’d like to hear from you. Have you deployed a SQL caching strategy? What have you done? How has it worked out?</p>
<p style="text-align:justify;" align="left">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/safepeak/'>Safepeak</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/27050/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/27050/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/27050/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/27050/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/27050/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/27050/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/27050/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/27050/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27050&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/18/sql-server-performance-do-it-yourself-caching-with-memcached-vs-automated-caching-with-safepeak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/sfpeak-memcache.png" medium="image" />
	</item>
		<item>
		<title>MySQL &#8211; Pattern Matching Comparison Using Regular Expressions with REGEXP</title>
		<link>http://blog.sqlauthority.com/2014/03/17/mysql-pattern-matching-comparison-using-regular-expressions-with-regexp/</link>
		<comments>http://blog.sqlauthority.com/2014/03/17/mysql-pattern-matching-comparison-using-regular-expressions-with-regexp/#comments</comments>
		<pubDate>Mon, 17 Mar 2014 01:30:00 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Regex]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=27041</guid>
		<description><![CDATA[MySQL supports pattern matching comparison using regular expressions with REGEXP keyword. In this post we will see how to use REGEXP in MySQL. We can use the patterns ^, $, &#124; and sqaure braces to effectively match the values. Let us create the following table: CREATE TABLE items(item_id INT, item_description VARCHAR(100)); INSERT INTO items VALUES [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27041&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;"><img class="alignleft" alt="" src="http://www.pinaldave.com/bimg/regex.jpg" width="200" />MySQL supports pattern matching <span class="GINGER_SOFTWARE_mark" id="53376f91-d883-4814-84c8-4b22747b5d41"><span class="GINGER_SOFTWARE_mark" id="e049e238-3a73-4500-b14c-8fdb99382bd0"><span class="GINGER_SOFTWARE_mark" id="8888e2e1-bf0d-42d8-8b73-8bc49097d7eb">comparison</span></span></span> using <span class="GINGER_SOFTWARE_mark" id="c81a917d-0206-4a4a-9847-079b0139c1dd"><span class="GINGER_SOFTWARE_mark" id="16c6c582-455e-4666-b590-4e0e783c5d63"><span class="GINGER_SOFTWARE_mark" id="98f14e43-194e-462d-9158-d90864ec12b2">regular expressions</span></span></span> with REGEXP keyword. In this post we will see how to use REGEXP <span class="GINGER_SOFTWARE_mark" id="8d83a060-62fe-41e7-9814-80e86db39c0b"><span class="GINGER_SOFTWARE_mark" id="d34c1d42-fa0f-4237-b82b-97b4499bf9be"><span class="GINGER_SOFTWARE_mark" id="8675c369-700c-4f0a-a7e1-9277d407423d"><span class="GINGER_SOFTWARE_mark" id="827a7d4b-c34c-43c8-bee0-ade077186880"><span class="GINGER_SOFTWARE_mark" id="f61ca66c-867f-4676-aeaa-a1ea7f4fdf2d">in</span></span></span></span></span> MySQL. We can use the patterns ^, $, | and <span class="GINGER_SOFTWARE_mark" id="e0dcde3c-b408-4aec-a726-30dd3d6d20e2"><span class="GINGER_SOFTWARE_mark" id="50ee8e0e-a10b-42df-b131-f0323dc59625"><span class="GINGER_SOFTWARE_mark" id="a874887b-18a7-4d41-94d6-39d88ddecd9c"><span class="GINGER_SOFTWARE_mark" id="8cedd9a7-b7f8-4a47-b330-0b15b62fa83e"><span class="GINGER_SOFTWARE_mark" id="b7ea0a8e-2cd8-40ce-8358-09127f162999">sqaure</span></span></span></span></span> braces to effectively match the values.</p>
<p style="text-align:justify;">Let us create the following table:</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">items</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="bc0e19ec-c004-411b-8471-94ec6abe248e"><span class="GINGER_SOFTWARE_mark" id="dac84b8f-73ab-47fc-929a-96e95d1a89b5"><span class="GINGER_SOFTWARE_mark" id="2779eb0a-4940-4894-b9b5-b85b0fafa2ea"><span class="GINGER_SOFTWARE_mark" id="f92ab5fe-d6e8-400e-8fe3-c8a55dc357a4">(</span></span></span></span></span><span style="color:black;">item_id </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">item_description </span><span style="color:blue;">VARCHAR</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="0445f9db-8ae1-4076-b032-635a617691c0"><span class="GINGER_SOFTWARE_mark" id="fb6fb61b-50ba-46fb-9fe4-10094eb5c005"><span class="GINGER_SOFTWARE_mark" id="ca3e49b4-5c2c-458a-9cce-0baf923bfaf9"><span class="GINGER_SOFTWARE_mark" id="baad8ce7-49f8-4fbd-a4d5-7f3f9942c3c7">(</span></span></span></span></span><span style="color:black;">100</span><span style="color:gray;">));<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'Television'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'Mobile'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'laptop'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">4</span><span style="color:gray;">,</span><span style="color:red;">'Cables'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">5</span><span style="color:gray;">,</span><span style="color:red;">'Camera'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">6</span><span style="color:gray;">,</span><span style="color:red;">'jewels'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">7</span><span style="color:gray;">,</span><span style="color:red;">'shirt'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">8</span><span style="color:gray;">,</span><span style="color:red;">'Cup'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">9</span><span style="color:gray;">,</span><span style="color:red;">'Pen'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">10</span><span style="color:gray;">,</span><span style="color:red;">'Pencil'</span><span style="color:gray;">);</span></code></p>
<h3 style="text-align:justify;">1 Find out item_description that starts with c<br />
<code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">item_description </span><span style="color:blue;">FROM </span><span style="color:black;">items<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">item_description <span class="GINGER_SOFTWARE_mark" id="811bd958-f7ab-4715-b9b1-09b9b0804572"><span class="GINGER_SOFTWARE_mark" id="86950228-930b-4eb4-a6c0-fb91d0fe5851"><span class="GINGER_SOFTWARE_mark" id="7a6862bd-1edf-4a81-8df5-0f66ec3d67e2"><span class="GINGER_SOFTWARE_mark" id="2bb51dd3-f095-47f3-aae4-d42228f320e0">regexp</span></span></span></span> </span><span style="color:red;">'^c'</span><span style="color:gray;">;</span></code></h3>
<h4 style="text-align:justify;"><code style="font-size:12px;"><span style="color:gray;"><span style="font-size:1em;color:#333333;font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:1.5em;">Result</span><span class="GINGER_SOFTWARE_mark" id="895d5f5a-4938-47b8-9f5b-cb570ac7bad8" style="font-size:1em;color:#333333;font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:1.5em;"><span class="GINGER_SOFTWARE_mark" id="93c7c9a2-6b16-4e22-8438-43e2f0fbb4f1"><span class="GINGER_SOFTWARE_mark" id="9efd015d-6c5b-47f2-a38e-7bb6593393f6"><span class="GINGER_SOFTWARE_mark" id="2f47950e-c774-4bf9-b395-390b2158c011"> :</span></span></span></span></span></code></h4>
<h4 style="text-align:justify;"></h4>
<pre>Item_description
 Cables
 Camera
 Cup</pre>
<h3 style="text-align:justify;">2 Find out item_description that ends with <span class="GINGER_SOFTWARE_mark" id="8624665b-6294-493f-8ef5-764579fdefff"><span class="GINGER_SOFTWARE_mark" id="5de6bca6-fee6-4717-add9-c02c8baa46b7"><span class="GINGER_SOFTWARE_mark" id="230f4f40-fca7-41c5-907b-26f6af6d4645"><span class="GINGER_SOFTWARE_mark" id="4e1f9302-30ea-48ed-855e-610c9a1befd9">s</span></span></span></span><br />
<code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">item_description </span><span style="color:blue;">FROM </span><span style="color:black;">items<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">item_description <span class="GINGER_SOFTWARE_mark" id="67be47ec-c4e4-4ec7-8617-9377d20b29b1"><span class="GINGER_SOFTWARE_mark" id="074c8994-5c45-41a7-9a4c-62c7f054d556"><span class="GINGER_SOFTWARE_mark" id="b88293c8-4fc6-44a2-8001-8e535e649860">regexp</span></span></span> </span><span style="color:red;">'s$'</span><span style="color:gray;">;</span></code></h3>
<h4 style="text-align:justify;">Result<span class="GINGER_SOFTWARE_mark" id="10fdab12-ee54-49f6-8e5e-2e32b26b1120"><span class="GINGER_SOFTWARE_mark" id="73cca65d-e28c-4c85-bd59-1ad0b1391862"><span class="GINGER_SOFTWARE_mark" id="ebe63ce4-64d8-4625-9cef-b84e066a4456"><span class="GINGER_SOFTWARE_mark" id="39adaa83-e8b2-4957-b8fe-0bb494a903c5"> :</span></span></span></span></h4>
<pre>Item_description
 Cables
 <span class="GINGER_SOFTWARE_mark" id="2bb8a295-3394-4a06-999a-e20e7488733c"><span class="GINGER_SOFTWARE_mark" id="17107466-04cd-4aec-9078-177a51a72d88">jewels</span></span></pre>
<h3 style="text-align:justify;">3 Find out item_description that starts with c or ends with <span class="GINGER_SOFTWARE_mark" id="e1cabce6-9b60-4bde-9397-d06a2c4c5ee3"><span class="GINGER_SOFTWARE_mark" id="bfe10112-2b76-4605-99ad-e3b2fc4415df"><span class="GINGER_SOFTWARE_mark" id="cb4b4a84-a414-4f2f-9dbd-c6de9264f93f"><span class="GINGER_SOFTWARE_mark" id="39e0f99b-2561-417d-81e7-29a05d0858cb"><span class="GINGER_SOFTWARE_mark" id="83326437-482b-4701-a99d-dddee9255da4">s</span></span></span></span></span><br />
<code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">item_description </span><span style="color:blue;">FROM </span><span style="color:black;">items<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">item_description <span class="GINGER_SOFTWARE_mark" id="bab4cd9e-c0b0-4f7e-9c12-2e17721a520d"><span class="GINGER_SOFTWARE_mark" id="3513bd98-bb4a-48a2-9ee0-d8f9920a4a04"><span class="GINGER_SOFTWARE_mark" id="fc4e00ad-9c60-4236-8692-0cdc3dca6e11">regexp</span></span></span> </span><span style="color:red;">'^c|s$'</span><span style="color:gray;">;</span></code></h3>
<h4 style="text-align:justify;">Result<span class="GINGER_SOFTWARE_mark" id="f58e071e-a604-4469-8fef-65b38d03664e"><span class="GINGER_SOFTWARE_mark" id="3c71375f-8a25-49e6-ac0c-3b7ef3479405"><span class="GINGER_SOFTWARE_mark" id="1950cf44-5fd9-48e1-949c-f24add03b5dd"><span class="GINGER_SOFTWARE_mark" id="31c8c49f-e8f5-4483-ad3b-ec2369147c9a"> :</span></span></span></span></h4>
<pre>Item_description
 Cables
 Camera
 <span class="GINGER_SOFTWARE_mark" id="d1b71222-e371-4c2a-9782-df86e783aa90"><span class="GINGER_SOFTWARE_mark" id="4eddaacd-c5d3-494e-a58a-15ec3f33b0dc">jewels</span></span>
 Cup</pre>
<h3 style="text-align:justify;">4 Find out item_description that contains the alphabet a<br />
<code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">item_description </span><span style="color:blue;">FROM </span><span style="color:black;">items<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">item_description <span class="GINGER_SOFTWARE_mark" id="0a7af7c9-97ad-482a-b7c3-71ea50d6742e"><span class="GINGER_SOFTWARE_mark" id="165dccfb-2ec8-43bb-a60f-9177ce61086d"><span class="GINGER_SOFTWARE_mark" id="eee0276e-8a1c-4501-945d-c1413d5aefdb">regexp</span></span></span> </span><span style="color:red;">'[a]'</span><span style="color:gray;">;</span></code></h3>
<p style="text-align:justify;">Result<span class="GINGER_SOFTWARE_mark" id="00d768c1-fcb8-4d98-a220-87ba40fabf29"><span class="GINGER_SOFTWARE_mark" id="58a5d6f6-246e-4722-adc2-f22590273f38"><span class="GINGER_SOFTWARE_mark" id="5fa357fb-3841-46de-9c5f-8d0660a8be03"><span class="GINGER_SOFTWARE_mark" id="09f348bf-596e-468f-82f3-419c0a64972f"> :</span></span></span></span></p>
<pre>Item_description
 <span class="GINGER_SOFTWARE_mark" id="7dcf2a0f-c6ad-45d7-b316-2b610db1c560"><span class="GINGER_SOFTWARE_mark" id="aeca81b6-c19e-458e-b329-d8bf6b6c32ce">laptop</span></span>
 Cables
 Camera</pre>
<h3 style="text-align:justify;">5 Find out item_description that contains the alphabet c or p</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">item_description </span><span style="color:blue;">FROM </span><span style="color:black;">items<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">item_description <span class="GINGER_SOFTWARE_mark" id="04a999d1-970e-42b5-8a14-4ec61622306a"><span class="GINGER_SOFTWARE_mark" id="cbc80b7d-db72-403a-a72f-0d7673e8ed67"><span class="GINGER_SOFTWARE_mark" id="f6c8c1dd-422e-41c4-ad58-c19acdd9fdba">regexp</span></span></span> </span><span style="color:red;">'^<span class="GINGER_SOFTWARE_mark" id="0366d92f-bec7-485b-ab38-c15bc361c3c8"><span class="GINGER_SOFTWARE_mark" id="08332801-ac0c-493f-8cb3-cd5850fba1f6">[</span></span><span class="GINGER_SOFTWARE_mark" id="211027ff-6569-490d-8b5f-29f1e7a0abc0"><span class="GINGER_SOFTWARE_mark" id="d252383c-1c57-4226-938d-44fb45d35670">cp</span></span>]'</span><span style="color:gray;">;</span></code></p>
<h4 style="text-align:justify;">Result<span class="GINGER_SOFTWARE_mark" id="59dce3ff-0890-448f-adef-8d4e75a521a8"><span class="GINGER_SOFTWARE_mark" id="d2a4a37f-9625-4608-a7d0-7272b03aee90"><span class="GINGER_SOFTWARE_mark" id="a15ebdcb-d2f6-4585-a043-290e0a1493f6"><span class="GINGER_SOFTWARE_mark" id="872a2c10-567f-4296-a50b-e4aa2ae6818d"> :</span></span></span></span></h4>
<pre>Item_description
 Cables
 Camera
 Cup
 <span class="GINGER_SOFTWARE_mark" id="d180521d-2f00-40b8-ba26-c66a48bbe47c"><span class="GINGER_SOFTWARE_mark" id="471b83b5-440d-47a4-90af-58cff5ad3b23">Pen
 Pencil</span></span></pre>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/regex/'>Regex</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/27041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/27041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/27041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/27041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/27041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/27041/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/27041/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/27041/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27041&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/17/mysql-pattern-matching-comparison-using-regular-expressions-with-regexp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/regex.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; What is the Difference Between Latches and Locks</title>
		<link>http://blog.sqlauthority.com/2014/03/16/sql-server-what-is-the-difference-between-latches-and-locks/</link>
		<comments>http://blog.sqlauthority.com/2014/03/16/sql-server-what-is-the-difference-between-latches-and-locks/#comments</comments>
		<pubDate>Sun, 16 Mar 2014 01:30:52 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=27033</guid>
		<description><![CDATA[A very common question I often get in the email is &#8220;What is the difference between latches and locks?&#8221; The answer to this question is not an easy one. Here is a quick answer from the MS white paper. A page in SQL Server is 8KB and can store multiple rows. To increase concurrency and [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27033&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">A very common question I often get in the email is</p>
<p style="text-align:justify;"><strong><em>&#8220;What is the difference between latches and locks?&#8221;</em></strong></p>
<p style="text-align:justify;">The answer to this question is not an easy one. Here is a quick answer from the MS white paper.</p>
<p style="text-align:justify;">A page in SQL Server is 8KB and can store multiple rows. To increase concurrency and performance, buffer latches are held only for the duration of the physical operation on the page, unlike locks which are held for the duration of the logical transaction. Latches are internal to the SQL engine and are used to provide memory consistency, whereas locks are used by SQL Server to provide logical <span class="GINGER_SOFTWARE_mark" id="9a03cb73-bf32-47d8-a6d6-db4d8f5f20a6">transactional</span> consistency.</p>
<p style="text-align:justify;">Above answer is taken from the old, but extremely relevant white paper written in the year 2011. It was written for SQL Server 2008 R2, however, almost all the concepts from this Whitepaper are still very accurate.</p>
<p style="text-align:justify;">If you want to learn more about Latches and how to diagnose and resolve problems around latch contention, I strongly suggest following <span class="GINGER_SOFTWARE_mark" id="4c2dd9f5-d183-4c9a-844d-c31cdc141ddb"><span class="GINGER_SOFTWARE_mark" id="fcd35bc9-9e09-499d-82cb-3f530a557dfc">whitepaper</span></span>.</p>
<p style="text-align:justify;"><strong><a href="http://www.microsoft.com/en-us/download/details.aspx?id=26665" target="_blank">Diagnosing and Resolving Latch Contention on SQL Server</a></strong></p>
<p style="text-align:justify;">Let me know your thoughts about this subject.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-interview-questions-and-answers/'>SQL Interview Questions and Answers</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/27033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/27033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/27033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/27033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/27033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/27033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/27033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/27033/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27033&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/16/sql-server-what-is-the-difference-between-latches-and-locks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Find Port SQL Server is Listening &#8211; Port SQL Server is Running</title>
		<link>http://blog.sqlauthority.com/2014/03/15/sql-server-find-port-sql-server-is-listening-port-sql-server-is-running/</link>
		<comments>http://blog.sqlauthority.com/2014/03/15/sql-server-find-port-sql-server-is-listening-port-sql-server-is-running/#comments</comments>
		<pubDate>Sat, 15 Mar 2014 01:30:35 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Interview Questions and Answers]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Management Studio]]></category>
		<category><![CDATA[SQL Stored Procedure]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=27025</guid>
		<description><![CDATA[Here is one of the very common interview questions I often ask people - Q: What is the default Port SQL Server running on? A: 1433 for TCP/IP and 1434 for USD connection. I always get the correct answer for this question. However, when I ask a follow up question, so far I have yet [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27025&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">Here is one of the very common interview questions I often ask people<span class="GINGER_SOFTWARE_mark" id="76584373-0660-421d-ac11-2cbd0f7dfc8d"><span class="GINGER_SOFTWARE_mark" id="1a1f1914-7c5c-4b37-9ddf-8d96c8d9639b"><span class="GINGER_SOFTWARE_mark" id="45bdd3c1-8627-4be3-9b39-d72cbeb43748"><span class="GINGER_SOFTWARE_mark" id="8bc709af-1c86-424c-a350-55a493e08c02"><span class="GINGER_SOFTWARE_mark" id="6e6e1edc-c182-4824-9b6e-47616fc2a435"> -</span></span></span></span></span></p>
<p style="text-align:justify;"><strong>Q:</strong> What is the default Port SQL Server running on?</p>
<p style="text-align:justify;"><strong>A:</strong> 1433 for TCP/IP and 1434 for USD connection.</p>
<p style="text-align:justify;">I always get the correct answer for this question. However, when I ask a follow up question, so far I have yet not got a single correct answer.</p>
<p style="text-align:justify;"><strong>Q:</strong> Great, now assumes that there is more than one instance of SQL Server running on the same server. What will be the port of the second SQL Server running on the server as the default port is already used by default instant?</p>
<p style="text-align:justify;"><strong>A:</strong> (I have yet to get the correct answer for this one in interview).</p>
<p style="text-align:justify;">Because of the same reason, I have decided to blog about this.</p>
<p style="text-align:justify;">Here are different ways one can figure out on which port the second instance of SQL Server is running.</p>
<h3 style="text-align:justify;">Method 1: using xp_readerrorlog</h3>
<p style="text-align:justify;">Execute following stored procedure on the instance where you want to find out port on which SQL Server is running.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE MASTER<br />
</span><span style="color:black;">GO<br />
</span><span style="color:darkred;">xp_readerrorlog </span><span style="color:black;">0</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;"><span class="GINGER_SOFTWARE_mark" id="c171721b-fb3a-485b-88a8-6f503ad279d8"><span class="GINGER_SOFTWARE_mark" id="85ecc01d-1e9c-40f7-9d18-54a5d2dcb818"><span class="GINGER_SOFTWARE_mark" id="0caa7eb8-4540-4094-8035-8fa61992fa32"><span class="GINGER_SOFTWARE_mark" id="472f700e-a4d8-47c8-b69d-1cd568db2b38">N'Server</span></span></span></span> is listening <span class="GINGER_SOFTWARE_mark" id="27ba9ee1-7022-4fb8-b79a-d96efc92d324"><span class="GINGER_SOFTWARE_mark" id="7aa38262-b26d-4ef3-bb2e-864d90f30d72"><span class="GINGER_SOFTWARE_mark" id="251aea52-fbfa-4d4a-9f90-6c9f1812f725"><span class="GINGER_SOFTWARE_mark" id="8b51948d-2c2f-4f1a-be7c-1eff33abede9">on</span></span></span></span>'<br />
</span><span style="color:black;">GO<br />
</span></code></p>
<p style="text-align:justify;">The above query will return results something very similar to the following:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/xpport.jpg" width="641" height="214" /></p>
<h3 style="text-align:justify;">Method 2: Configuration Properties</h3>
<p style="text-align:justify;">Go to Windows &gt;&gt; Start &gt;&gt; SQL Server Program Folder &gt;&gt; SQL Server Configuration Manager</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/xpport2.jpg" width="236" height="137" /></p>
<p style="text-align:justify;">Now go to SQL Server Network Configurations &gt;&gt; Protocols for Your Server and go to TCP/IP and right click over it.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/xpport3.jpg" width="580" height="389" /></p>
<p style="text-align:justify;">Now over here when you scroll down you will notice Port Details.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/xpport4.jpg" width="731" height="664" /></p>
<p style="text-align:justify;">It is that easy to find the port of the second instance of SQL Server.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-interview-questions-and-answers/'>SQL Interview Questions and Answers</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/sql-server-management-studio/'>SQL Server Management Studio</a>, <a href='http://blog.sqlauthority.com/category/sql-stored-procedure/'>SQL Stored Procedure</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/27025/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/27025/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/27025/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/27025/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/27025/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/27025/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/27025/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/27025/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=27025&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/15/sql-server-find-port-sql-server-is-listening-port-sql-server-is-running/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/xpport.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/xpport2.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/xpport3.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/xpport4.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Error &#8211; Resolution &#8211; Could not allocate space for object in database because the filegroup is full</title>
		<link>http://blog.sqlauthority.com/2014/03/14/sql-server-error-resolution-could-not-allocate-space-for-object-in-database-because-the-filegroup-is-full/</link>
		<comments>http://blog.sqlauthority.com/2014/03/14/sql-server-error-resolution-could-not-allocate-space-for-object-in-database-because-the-filegroup-is-full/#comments</comments>
		<pubDate>Fri, 14 Mar 2014 01:30:04 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Error Messages]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26998</guid>
		<description><![CDATA[Just a day ago on my local box I received following error. Could not allocate space for object &#8216;&#60;object_name&#62;&#8217; in database &#8216;&#60;database_name&#62;&#8217; because the &#8216;PRIMARY&#8217; filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26998&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">Just a day ago on my local box I received following error.</p>
<p style="text-align:justify;"><span style="color:#ff0000;">Could not allocate space for object &#8216;&lt;object_name&gt;&#8217; in database &#8216;&lt;database_name&gt;&#8217; because the &#8216;PRIMARY&#8217; filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.</span></p>
<p style="text-align:justify;">I was a bit surprised as this was not a production server or even real <span class="GINGER_SOFTWARE_mark" id="8c9d62d7-5d78-4e49-b7e9-037f13c0f540"><span class="GINGER_SOFTWARE_mark" id="37200c8f-6439-4d30-abb7-15f8c3bd86a1"><span class="GINGER_SOFTWARE_mark" id="8a2c555a-2ae8-4c4b-b943-15660aa213d3"><span class="GINGER_SOFTWARE_mark" id="17c1fa29-0a93-4d32-8a5c-e15f351c60a2">server</span></span></span></span>. It was my laptop with SQL Server installed in it for testing and presentation purpose. I was a bit shocked and decided to figure out what is wrong with my SQL Server. Just like everyone I searched online and I end up having few solutions, however, after a while I realized then what exactly I was missing. However, I encourage all of you to read various steps I took to reach to <span class="GINGER_SOFTWARE_mark" id="577d045e-5031-4127-9ed6-1483ca5fdc03"><span class="GINGER_SOFTWARE_mark" id="127e6ebe-e549-42ec-91f6-a62ddd516553">a solution</span></span> to this problem.</p>
<h3 style="text-align:justify;">Solution / Fix<span class="GINGER_SOFTWARE_mark" id="20845a95-d9a8-411b-9813-7c987747eab1"><span class="GINGER_SOFTWARE_mark" id="b6641c8d-311f-4641-96da-308d776c715f"><span class="GINGER_SOFTWARE_mark" id="2d7adb12-f492-433c-8f5d-416632b12cb8"><span class="GINGER_SOFTWARE_mark" id="3cb7cded-5c31-48e8-ad6e-549f429d363a"> :</span></span></span></span></h3>
<p style="text-align:justify;"><strong>Step 1:</strong> I checked if my Hard Drive has more space available.</p>
<p style="text-align:justify;">If your Hard Drive is full, please empty out any unnecessary stuff. This may not directly fix your <span class="GINGER_SOFTWARE_mark" id="485e4dbc-46d6-445c-8238-a9ad35ed0327">problem, but</span> it is <span class="GINGER_SOFTWARE_mark" id="606c7e7e-1289-4229-a71f-2ba280002139">a necessary exercise</span> to do before you do Step 2.</p>
<p style="text-align:justify;"><strong>Step 2:</strong> Delete unnecessary object from your file group.</p>
<p style="text-align:justify;">If your primary <span class="GINGER_SOFTWARE_mark" id="70fc4a5d-56d5-4112-8867-1fc381391dbe"><span class="GINGER_SOFTWARE_mark" id="b024a66c-7b3e-413c-9f82-9713e353fb1d"><span class="GINGER_SOFTWARE_mark" id="e073c07b-c7ac-492e-83ed-e1ef7793b5f1">filegroup</span></span></span> (in most cases) or <span class="GINGER_SOFTWARE_mark" id="87d017cf-2ff1-42df-9a8c-eedf1bc8f86d"><span class="GINGER_SOFTWARE_mark" id="2aa66b5e-fda9-40d1-bc4a-97cd147be58b"><span class="GINGER_SOFTWARE_mark" id="88a2923d-1f4a-48c5-83d3-3754f744180a">filegroup</span></span></span> which has generated this error is restricted to fix size, you may get this error. You have two workarounds here.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/fixedgrowth.jpg" width="704" height="632" /></p>
<p style="text-align:justify;"><strong>Step 2a:</strong> Delete objects from your <span class="GINGER_SOFTWARE_mark" id="9b8735c6-2a44-40cf-88a9-8d0e8ba15e39"><span class="GINGER_SOFTWARE_mark" id="dda14fe9-43c3-4066-b262-b4c4bb1cfe41"><span class="GINGER_SOFTWARE_mark" id="e03d7686-e3fe-4133-83f2-6b8d01b9a6a2">filegroup</span></span></span> which you do not need. You can move objects to another <span class="GINGER_SOFTWARE_mark" id="b1ed3bcc-eddc-44f8-b248-42a28ad3ae88">filegroup</span> if you have multiple filegroups.</p>
<p style="text-align:justify;"><strong>Step 2b:</strong> Increase the fixed size of your primary <span class="GINGER_SOFTWARE_mark" id="7bb530b4-cd6b-4a60-8c1c-037eb8076a93"><span class="GINGER_SOFTWARE_mark" id="470c5826-44d4-401c-bc26-776b1485810a"><span class="GINGER_SOFTWARE_mark" id="9571a097-e7c4-4557-bddc-f4ff3a50a93e">filegroup</span></span></span>.</p>
<p style="text-align:justify;"><strong>Step 3:</strong> Check your SQL Server version.</p>
<p style="text-align:justify;">SQL Server Express version 2008 and earlier had the limitation of 4GB maximum Database size. SQL Server Express 2008 R2 and onwards have limitation 10GB maximum database size.</p>
<p style="text-align:justify;">In my case, I was running SQL Server Express version, hence I had faced above error. I moved my database to standard edition and everything went fine.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-error-messages/'>SQL Error Messages</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26998/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26998/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26998/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26998&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/14/sql-server-error-resolution-could-not-allocate-space-for-object-in-database-because-the-filegroup-is-full/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/fixedgrowth.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; SSIS Data Flow Troubleshooting &#8211; Part1 &#8211; Notes from the Field #019</title>
		<link>http://blog.sqlauthority.com/2014/03/13/sql-server-ssis-data-flow-troubleshooting-part1-notes-from-the-field-019/</link>
		<comments>http://blog.sqlauthority.com/2014/03/13/sql-server-ssis-data-flow-troubleshooting-part1-notes-from-the-field-019/#comments</comments>
		<pubDate>Thu, 13 Mar 2014 01:30:28 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[Notes from the Field]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Backup and Restore]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26989</guid>
		<description><![CDATA[[Note from Pinal]: This is a new episode of Notes from the Field series. SQL Server Integration Service (SSIS) is one of the most key essential part of the entire Business Intelligence (BI) story. It is a platform for data integration and workflow applications. The tool may also be used to automate maintenance of SQL Server databases and [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26989&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">[Note from Pinal]: This is a new episode of <strong>Notes from the Field</strong> series. SQL Server Integration Service (SSIS) is one of the most key essential part of the entire Business Intelligence (BI) story. It is a platform for data integration and workflow applications. The tool may also be used to automate maintenance of SQL Server databases and updates to multidimensional cube data.</p>
<p style="text-align:justify;"><img class="alignleft" style="line-height:1.5;" alt="" src="http://www.pinaldave.com/bimg/andyleonard.jpg" width="200" /></p>
<p style="text-align:justify;">In this episode of the Notes from the Field series I asked SSIS Expert Andy Leonard a very crucial question &#8211; How to troubleshoot SSIS data flow? It is such a complicated problem that everyone thinks they know, but not everyone can resolve this issue. Any Leonard is a world renowned expert, explains in this blog post how to troubleshoot SSIS data flow.</p>
<hr />
<p style="text-align:justify;">SQL Server Integration Services (SSIS) <span class="GINGER_SOFTWARE_mark" id="7ca29b54-d3c2-4248-a82d-8e355a499180"><span class="GINGER_SOFTWARE_mark" id="16375e08-1fca-4228-ae38-056cdf783588"><span class="GINGER_SOFTWARE_mark" id="03b95735-5a12-42fc-b570-498cf674f3ed"><span class="GINGER_SOFTWARE_mark" id="10b41a9c-060f-47da-8d96-fce8c8987679">is designed</span></span></span></span> to move data. Several SSIS tasks can move data but the Data Flow Task is arguably used most to accomplish moving data. When bad things happen to good developers, it helps to know how to troubleshoot. Writing about all the ways to troubleshoot an SSIS Data Flow Task will take more than one post. So this is Part 1.</p>
<h2 style="text-align:justify;">Building a Quick Demo Package</h2>
<p style="text-align:justify;">If you are interested in working through some demos with me, create a new SSIS project named DataFlowTests. Add a Data Flow Task to the Control Flow as shown in Figure 1:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_1.jpg" width="251" height="153" /></p>
<p style="text-align:justify;">You can use any source data you desire, but I am going to use a file containing weather data captured from my weather station here in Farmville, Virginia beginning in December 2008. You can obtain this data <a href="http://andyweather.com/data/WeatherData_Dec08.zip" rel="nofollow">here</a>. Click the Data Flow tab to edit the Data Flow Task. Add a Flat File Connection Manager configured to consume the sensor1-all<span class="GINGER_SOFTWARE_mark" id="47bf9cf9-5601-4f4a-98e8-76c0bca6473e"><span class="GINGER_SOFTWARE_mark" id="52d57a49-18ff-4467-9ceb-06f40aa4c93d"><span class="GINGER_SOFTWARE_mark" id="e7f2b740-eb6f-434b-bbe8-80e8441dd259"><span class="GINGER_SOFTWARE_mark" id="d0e465bc-1a08-45bf-8dbf-35d5b4c844d9">.</span></span></span></span><span class="GINGER_SOFTWARE_mark" id="60991ef2-495b-41bb-a74b-c578f2598577"><span class="GINGER_SOFTWARE_mark" id="5694cd20-f3b2-4c66-9ccd-6748080a3e29"><span class="GINGER_SOFTWARE_mark" id="4d1ff291-25b3-4fff-a206-7f6931f5cc3b"><span class="GINGER_SOFTWARE_mark" id="ece4e91e-c7a6-4edf-b5ba-f24f8210e4f8">csv</span></span></span></span> file containing the December 2008 weather data. Add a Flat File Source adapter and link it to the Flat File Connection Manager. You Data Flow should appear as shown in Figure 2:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_2.jpg" /></p>
<p style="text-align:justify;">To test the Flat File Source adapter, we need to connect an output to another component. Add a Union All transformation and connect the output of the Flat File Source to it, as shown in Figure 3:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_3.jpg" /></p>
<p style="text-align:justify;">You can now test-execute the SSIS package. You should see results similar to those shown in Figure 4:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_4.jpg" /></p>
<p style="text-align:justify;">This data flow isn’t doing very much. The Flat File Source adapter is coupled to the Flat File Connection Manager. The Flat File Connection Manager reads data from the sensor1<span class="GINGER_SOFTWARE_mark" id="afd5de1e-1bb3-456b-9415-260b18b16c79"><span class="GINGER_SOFTWARE_mark" id="db14a3b5-a5a2-4ea9-b222-de3afd3c4d48"><span class="GINGER_SOFTWARE_mark" id="90cc9c04-5cdb-4101-930e-77f6ff1d9b00"><span class="GINGER_SOFTWARE_mark" id="af86efac-c4b1-4ca0-bef7-9b2d2034ed6e">.</span></span></span></span>all<span class="GINGER_SOFTWARE_mark" id="e4ad6622-df17-423e-bd85-7bb0f4e5277c"><span class="GINGER_SOFTWARE_mark" id="6391518f-57e6-42c8-ac02-76c9a18d2ada"><span class="GINGER_SOFTWARE_mark" id="bd268c3a-8a7f-4d86-98ba-275627408e61"><span class="GINGER_SOFTWARE_mark" id="5abe38a0-738f-4948-bd78-51dc125b6e95">.</span></span></span></span><span class="GINGER_SOFTWARE_mark" id="ba2bba96-9d0a-46e7-90ba-e8fef42de242"><span class="GINGER_SOFTWARE_mark" id="b9a53cd3-dc3c-43d8-8704-07affe57195d"><span class="GINGER_SOFTWARE_mark" id="fb5770f1-c7e2-4a1e-84a0-0e4cabe90a0e"><span class="GINGER_SOFTWARE_mark" id="07354813-4992-4649-ba37-ae16a8b25e13">csv</span></span></span></span> file you downloaded from andyweather.com. Weather data <span class="GINGER_SOFTWARE_mark" id="a365da83-9465-46f6-aa41-3655f5154583"><span class="GINGER_SOFTWARE_mark" id="6c2e7337-e74e-45fe-b8c3-d17a6f6b052f"><span class="GINGER_SOFTWARE_mark" id="063b37ff-10ec-4ddd-a9f5-84bc3a2470c4"><span class="GINGER_SOFTWARE_mark" id="4d4849fc-0d33-43bb-a3b8-95bd7891d2a0">is read</span></span></span></span> into the data flow from the file via the Flat File Connection Manager and the Flat File Source adapter. The 106 rows of weather data <span class="GINGER_SOFTWARE_mark" id="b9e23bc6-e362-4805-b8f6-e787ea002355"><span class="GINGER_SOFTWARE_mark" id="76b07acf-f967-4330-8e1d-28315d14c1ee"><span class="GINGER_SOFTWARE_mark" id="f87da656-76a9-41ba-8cef-12a1152d0c01"><span class="GINGER_SOFTWARE_mark" id="945e9091-8867-4757-8df8-d2562d0090ef">are then passed</span></span></span></span> into the Data Flow Path connecting the Flat File Source adapter output to the first Union All Input (Union All Input 1).</p>
<h2 style="text-align:justify;">Insert a Warning</h2>
<p style="text-align:justify;">Let’s create an issue that will raise a warning. Open the Flat File Connection Manager Editor, click on the Advanced page, select the Min T column, and change its DataType property to “four-byte signed integer [DT_I4] as shown in Figure 5:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_5.jpg" /></p>
<p style="text-align:justify;">When you close the Flat File Connection Manager Editor, a warning icon <span class="GINGER_SOFTWARE_mark" id="bd61f6dd-f86c-446a-b332-7314dab6d2e8"><span class="GINGER_SOFTWARE_mark" id="bc800be1-602d-420c-aab7-89c8a8293623"><span class="GINGER_SOFTWARE_mark" id="e5531e7d-d00b-41ed-9f88-b905acaec328"><span class="GINGER_SOFTWARE_mark" id="af7eff16-26b9-4297-9b8a-86910a06958c">displays</span></span></span></span> on the Flat File Source adapter. If you hover over the Flat File Source adapter with your mouse, a tooltip will display some of the warning text as shown in Figure 6:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_6.jpg" /></p>
<p style="text-align:justify;">You can see more of the Warning if you execute the package and the view the Progress (if the package is running the SSIS Debugger) or Execution Results tab (if the package has been executed in the Debugger and then the Debugger has been stopped), as shown in Figure 7:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_7.jpg" /></p>
<p style="text-align:justify;">The warning we injected by changing the DataType property of the Min T column in the Flat File Connection Manager does not cause an error. The warning stems from the fact that there is a difference between the data type of the Min T column flowing into the Flat File Source adapter from the Flat File Connection Manager and the data type of the Min T column flowing out of the Flat File Source adapter. You can correct this warning by opening the Flat File Source adapter and clicking the Columns page. When opening the Editor (or Advanced Editor) of the Flat File Source adapter, you will be prompted as shown in Figure 8:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_8.jpg" /></p>
<p style="text-align:justify;">Click the “Yes” button to synchronize the Min T column’s data type in the Flat File Source adapter’s output (the metadata of the “output column”) with the Min T column’s data type supplied from the Flat File Connection Manager (the metadata of the “external column”).</p>
<h2 style="text-align:justify;">Insert an Error</h2>
<p style="text-align:justify;">One way to generate an error in our simple data flow task is to configure the Flat File Connection Manager to perform an impossible data type coercion. Every value in the Min HI column contains “—“. Let’s configure the Min HI column in the Flat File Connection Manager and the Flat File Source adapter as data type Integer.</p>
<p style="text-align:justify;">First, open the Flat File Connection Manager Editor and change the Min HI DataType property to DT_I4 as shown in Figure 9:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_9.jpg" /></p>
<p style="text-align:justify;">When you click the “OK” button, we see the same warning displayed in Figure 6 – the external columns are out of synchronization with the data source columns. Right-click the Flat File Source adapter and click Show Advanced Editor as shown in Figure 10:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_10.jpg" /></p>
<p style="text-align:justify;">When you attempt to open the Advanced Editor, you will be prompted to fix the data type mismatch between the output columns and the external columns. Click the “No” button to proceed, as shown in Figure 11:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_11.jpg" /></p>
<p style="text-align:justify;">When the Advanced Editor for the Flat File Source adapter opens, click the Input and Output Properties tab. Expand the Flat File Source Output node, and then expand the Output Columns node. Click on the Min HI column and change the DataType property to “four-byte signed integer [DT_I4] as shown in Figure 12:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_12.jpg" /></p>
<p style="text-align:justify;">Click the “OK” button to close the Advanced Editor. Note the Union All now displays a validation error as shown in Figure 13:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_13.jpg" /></p>
<p style="text-align:justify;">What has happened? The tooltip reveals an issue with a metadata mismatch, but the error is truncated. We can view the full error message in the Error List by clicking <span class="GINGER_SOFTWARE_mark" id="e204d546-e00f-4520-9b7f-7085fbaed9fa"><span class="GINGER_SOFTWARE_mark" id="dbb50070-b4d0-4715-946e-a89bab4497af"><span class="GINGER_SOFTWARE_mark" id="ed24a600-1d98-4a26-8ff2-777d298d2569"><span class="GINGER_SOFTWARE_mark" id="ff602370-be10-4ad1-87d7-123f2588420a">ViewàError List</span></span></span></span> as shown in Figure 14:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_140.jpg" /></p>
<p style="text-align:justify;"><i>Note: The Error List option is missing from the View menu in some versions of SSDT-BI. In those environments, use the keystrokes. Hold down Ctrl and press \ followed by E.</i></p>
<p style="text-align:justify;">The Error List window displays the full text of errors, warnings, and other informational messages, and is shown in Figure 15:<br />
<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_15.jpg" /></p>
<p style="text-align:justify;">There are a couple ways to fix this error. The easy way is to delete the Union All and add a new Union All transformation in its place (the hard way is to edit the package’s XML).</p>
<h2 style="text-align:justify;">Conclusion</h2>
<p style="text-align:justify;">We are going to stop here. We have introduced an error in the Flat File Source Adapter, though. And we will begin there in Part 2.</p>
<p style="text-align:justify;"><span style="font-size:14px;line-height:1.5;">If you want to get started with SSIS with the help of experts, read more over at </span><strong style="font-size:14px;line-height:1.5;"><a href="http://blog.sqlauthority.com/fix-your-sql-server/" target="_blank" rel="nofollow">Fix Your SQL Server</a></strong><span style="font-size:14px;line-height:1.5;">.</span></p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/notes-from-the-field/'>Notes from the Field</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-backup-and-restore/'>SQL Backup and Restore</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/ssis/'>SSIS</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26989/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26989/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26989/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26989&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/13/sql-server-ssis-data-flow-troubleshooting-part1-notes-from-the-field-019/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/andyleonard.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_1.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_2.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_3.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_4.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_5.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_6.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_7.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_8.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_9.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_10.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_11.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_12.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_13.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_140.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/ssis-tr1/DFT1_15.jpg" medium="image" />
	</item>
		<item>
		<title>MySQL &#8211; How to do Straight Join in MySQL?</title>
		<link>http://blog.sqlauthority.com/2014/03/12/mysql-how-to-do-straight-join-in-mysql/</link>
		<comments>http://blog.sqlauthority.com/2014/03/12/mysql-how-to-do-straight-join-in-mysql/#comments</comments>
		<pubDate>Wed, 12 Mar 2014 01:30:38 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26982</guid>
		<description><![CDATA[In an earlier post, we have learnt a new type of join called NATURAL JOIN supported in MySQL. In this post will see another type of join called STRAIGHT_JOIN. STRAIGHT_JOIN is actually an INNER JOIN but it forces the order in which data should be processed. As per MySQL&#8217;s documentation at, the definition is given [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26982&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">In <span class="GINGER_SOFTWARE_mark" id="6da52f6a-239e-465a-8cbb-f8f82c795f42"><span class="GINGER_SOFTWARE_mark" id="577eeeba-0306-4eb2-a5f9-8b9042bda699">an earlier post</span></span>, we have learnt a new type of join called NATURAL JOIN supported in MySQL. In this post will see another type of join called STRAIGHT_JOIN.</p>
<p style="text-align:justify;">STRAIGHT_JOIN is actually an INNER JOIN but it forces the order in which data should be processed.</p>
<p style="text-align:justify;">As per MySQL&#8217;s documentation at, the definition is given below</p>
<p style="text-align:justify;"><em><strong>&#8220;STRAIGHT_JOIN is similar to JOIN, except that the left table is always read before the right table. This can be used for those (few) cases for which the join optimizer puts the tables in the wrong order.&#8221;</strong></em></p>
<p style="text-align:justify;">Let us create the following data</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">items</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="ad27c39b-38dd-408a-b8ca-cd8b6ed57704"><span class="GINGER_SOFTWARE_mark" id="e1f641b4-82f9-4e75-be75-683aad7498ed"><span class="GINGER_SOFTWARE_mark" id="601d9f86-8d6d-4f3a-b5c3-1151e88ee2ea">(</span></span></span></span><span style="color:black;">item_id </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">item_description </span><span style="color:blue;">VARCHAR</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a8b9ba3a-08c0-4c54-b60f-5f48326fb37d"><span class="GINGER_SOFTWARE_mark" id="31ab3e55-c2c0-4118-a7cb-ea5105d3c239"><span class="GINGER_SOFTWARE_mark" id="4cfb5091-de7b-487e-bddb-356b7673dbcd">(</span></span></span></span><span style="color:black;">100</span><span style="color:gray;">));<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="9a943a32-6a3f-4e7e-9f99-0c4978233200"><span class="GINGER_SOFTWARE_mark" id="8ceb60ed-2eb4-4cac-aba1-85f872abc339"><span class="GINGER_SOFTWARE_mark" id="1552bf81-e5c4-472e-a1b7-ed622132033a">(</span></span></span></span><span style="color:black;">sales_id </span><span style="color:blue;">INT </span><span style="color:black;">auto_increment </span><span style="color:blue;">KEY</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="495175b5-e4b6-4365-8550-6154f71a3416"><span class="GINGER_SOFTWARE_mark" id="70dec988-f956-46af-9070-5d0e076e0471"><span class="GINGER_SOFTWARE_mark" id="5149d041-77df-4584-a32d-416c95347daa">,</span></span></span></span><span style="color:black;">item_id </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">sales_date </span><span style="color:blue;">DATETIME</span><span style="color:gray;">, </span><span style="color:black;">sales_amount </span><span style="color:blue;">DECIMAL</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="5a921f6b-4b2d-40fb-bd0a-541e4b92abd4"><span class="GINGER_SOFTWARE_mark" id="cb25ee99-5af7-4371-9685-400d6f3c1960"><span class="GINGER_SOFTWARE_mark" id="756487a4-16bb-49c9-bd4b-d53051551710">(</span></span></span></span><span style="color:black;">12</span><span style="color:gray;">,</span><span style="color:black;">2</span><span style="color:gray;">));<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'Television'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'Mobile'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'laptop'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c364a4c3-b25a-4c02-bed7-6e46a18c2f78"><span class="GINGER_SOFTWARE_mark" id="dc82649c-838d-437b-ab92-a66db9bd4c22"><span class="GINGER_SOFTWARE_mark" id="9c325227-1a51-49f2-ad37-cced6377eb4a">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="15fc0af4-e3d4-41f8-b322-f43af3c4c6ea"><span class="GINGER_SOFTWARE_mark" id="22acb04b-20e5-400f-af79-087daf9ae009"><span class="GINGER_SOFTWARE_mark" id="2216e1a8-53e3-4c71-8167-3eb3ca988f22">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="366dba69-e002-47f8-837d-b706d81895b3"><span class="GINGER_SOFTWARE_mark" id="45dd6cf7-475d-4edf-81b7-32a1c9c5d785"><span class="GINGER_SOFTWARE_mark" id="dca91fd1-5235-41fc-adce-eb0aff4570e9">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-01'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c789602a-4a54-4b4d-962d-76bceea86000"><span class="GINGER_SOFTWARE_mark" id="7839ee72-8ed9-4676-8ea5-859d689232df"><span class="GINGER_SOFTWARE_mark" id="86d69218-8e63-491f-8849-af17e25e6def">,</span></span></span></span><span style="color:black;">1200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="8ab0e437-e633-484f-9012-164b01c78637"><span class="GINGER_SOFTWARE_mark" id="fbf47d76-3139-4bab-bfd3-184b24a70df1"><span class="GINGER_SOFTWARE_mark" id="26188bd8-e58b-492e-9390-b74635a55d78">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="5059cb78-5aba-4110-b155-28b80564efdf"><span class="GINGER_SOFTWARE_mark" id="0a932030-421d-4215-990a-07e1451d26d8"><span class="GINGER_SOFTWARE_mark" id="05d6b7fe-4837-49e7-9285-3aac96212610">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1eef27ce-6656-4a57-9ef9-7bd428ba5097"><span class="GINGER_SOFTWARE_mark" id="9a3d53a2-8aea-4bc8-9390-8e461c3d003a"><span class="GINGER_SOFTWARE_mark" id="41f69b28-b866-44c5-88f7-05e4bdc15492">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-02'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="39303a42-734e-456d-ad3d-c39e38da8617"><span class="GINGER_SOFTWARE_mark" id="5c81225b-5199-47b3-8c5d-f858c2d3aeea"><span class="GINGER_SOFTWARE_mark" id="2f1138ba-86e6-4f57-918d-8e3d88126394">,</span></span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="3942e7cb-e954-4bb7-b639-11c69d332b2a"><span class="GINGER_SOFTWARE_mark" id="54b8d1ef-3263-4aa8-870c-585cc0f7c90a"><span class="GINGER_SOFTWARE_mark" id="0c2b1284-2aac-4e99-89ee-99904aff3b82">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="31a5fe81-39aa-409c-bd5e-f34688d50a6c"><span class="GINGER_SOFTWARE_mark" id="bffc1277-5eae-44f4-9c1a-7c38e1604348"><span class="GINGER_SOFTWARE_mark" id="4af4d3e0-bc7c-4e3d-94f8-41ca9bb1ccb3">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="e857cb65-22f1-44a5-aea6-2dfc1fc55f26"><span class="GINGER_SOFTWARE_mark" id="af9c679c-a7ac-4697-8975-cc0c0537ce67"><span class="GINGER_SOFTWARE_mark" id="449b51c7-4ea8-479e-b98d-d984e7752a27">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-09'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1cfaeb8c-c40f-47d3-a571-9ad50514bafa"><span class="GINGER_SOFTWARE_mark" id="aa977455-5401-443d-ad11-72314f2b92f7"><span class="GINGER_SOFTWARE_mark" id="ccc15cfa-43e4-4399-aa28-3252a7038053">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1a77dedb-592f-4dc2-8350-c957f631499c"><span class="GINGER_SOFTWARE_mark" id="1273860c-3d0d-4ca5-a566-3fbb79494e4b"><span class="GINGER_SOFTWARE_mark" id="6b2409a1-05f7-4db9-a968-7a4a3b672d0c">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="29d9de3a-bb97-4049-8679-6de6a6db90a9"><span class="GINGER_SOFTWARE_mark" id="50afd7de-5140-4a0f-9061-35cb66f9ec0f"><span class="GINGER_SOFTWARE_mark" id="07928de6-acb5-4ad1-ad68-3ea79878e4f4">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a65f367b-316b-4961-9049-c20a46f8066f"><span class="GINGER_SOFTWARE_mark" id="7698f77c-df26-42a3-b15c-0921facd6d40"><span class="GINGER_SOFTWARE_mark" id="4a64a8ff-4d21-476c-9510-5e1b852f514a">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-29'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="94e3fdf9-f9f5-4ced-9c01-93cc83a4193a"><span class="GINGER_SOFTWARE_mark" id="7785ba66-fc2d-41ab-b070-d619cffceb71"><span class="GINGER_SOFTWARE_mark" id="0ac0f87b-2b5e-4912-9070-28938a1741c6">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="97ba0482-2fa6-440f-8e0e-ade1cbad2d20"><span class="GINGER_SOFTWARE_mark" id="f32aaacc-9107-4206-b5a6-855983d8ea80"><span class="GINGER_SOFTWARE_mark" id="b96db037-c48e-4035-b168-6f097453c89c">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="5591b581-ca6f-491f-93da-4720579f01c2"><span class="GINGER_SOFTWARE_mark" id="ce80d561-7add-41d2-b861-aae557a117dd"><span class="GINGER_SOFTWARE_mark" id="f2f14f93-c02a-4baf-9c29-8b700d19dff5">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="7b5e260b-0902-40fd-8fc5-4534ef97b70d"><span class="GINGER_SOFTWARE_mark" id="5787e06b-7583-4fb8-89d2-91617da375bf"><span class="GINGER_SOFTWARE_mark" id="fd030195-73f7-4b57-a702-8965d7f0d4c6">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-11'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="36723e5d-98ec-469e-970a-ea83ebdc49f3"><span class="GINGER_SOFTWARE_mark" id="105fdbfc-dbeb-48f2-888e-eb115f51a25f"><span class="GINGER_SOFTWARE_mark" id="cb3e2b17-d070-44fa-9209-bbfbcf7f5828">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a533a693-9f15-4436-8a77-9c94a07a3640"><span class="GINGER_SOFTWARE_mark" id="aea7ae7a-1bd0-467c-8990-315ccc5476af"><span class="GINGER_SOFTWARE_mark" id="6ddbcc8b-4846-4e8e-b57a-8b5f1efea68c">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="6113109f-dcd7-4695-9983-0a626aab9f4e"><span class="GINGER_SOFTWARE_mark" id="91673fcc-51e7-44b1-89a5-08c94199d5a3"><span class="GINGER_SOFTWARE_mark" id="52a420e9-28b6-4ff5-a93b-04bd03b03e6f">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="532e5ada-6aa2-4714-a747-fe807e7c99fd"><span class="GINGER_SOFTWARE_mark" id="053c9a72-66dc-401d-b542-19f41fd39ded"><span class="GINGER_SOFTWARE_mark" id="ceaeae59-68ab-451f-9959-2604a147df1c">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-16'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="4d0c0df8-e3f3-4de0-9bae-8ea1604094e8"><span class="GINGER_SOFTWARE_mark" id="e93cc3be-a0ec-4af4-a0b3-7746e6e38f3e"><span class="GINGER_SOFTWARE_mark" id="ea288507-e81f-4caa-8f5e-995f6846f425">,</span></span></span></span><span style="color:black;">1200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="fe183f44-68af-4755-9b31-71f1d06f5167"><span class="GINGER_SOFTWARE_mark" id="3d9b9f1a-f55a-4ef1-8f47-dbd4c11a4036"><span class="GINGER_SOFTWARE_mark" id="3df81918-fa00-4c05-a3c3-50efaf4b4c9c">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="05695dd2-fe13-4906-8768-bba63079339e"><span class="GINGER_SOFTWARE_mark" id="c6238d94-cc51-423c-9751-17600f2fcf9d"><span class="GINGER_SOFTWARE_mark" id="ca13a6ea-edfb-40ff-904c-2bf041e8fdbd">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="167d52e7-15dc-45d6-a278-b63defd300bf"><span class="GINGER_SOFTWARE_mark" id="6314005a-a373-4ee9-8439-5ffeb93a462f"><span class="GINGER_SOFTWARE_mark" id="0e044312-cab3-4734-ad3b-f9a63ded12a3">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-16'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="4b5cd281-f72f-4c83-aa88-35c61905a851"><span class="GINGER_SOFTWARE_mark" id="44446836-74d7-4fae-93dc-97edd161a8cf"><span class="GINGER_SOFTWARE_mark" id="39bda487-4897-4630-a5cf-0482552dfa06">,</span></span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="b72d1b7b-f7fb-4c6e-81d9-3e2901ee5d8f"><span class="GINGER_SOFTWARE_mark" id="233d0e09-02e9-4c5d-9123-ecf4410dea0d"><span class="GINGER_SOFTWARE_mark" id="5f455a35-d27a-4aa4-82ec-b18c6d229c34">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="7bac0bb6-7211-4064-9b2f-3b50e817c9c3"><span class="GINGER_SOFTWARE_mark" id="1d682127-cddd-45a2-baf3-d26d015baa40"><span class="GINGER_SOFTWARE_mark" id="53189fa9-d80f-41d2-bbca-9b57ef925a84">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="3581c736-77dd-4bd0-a20d-1b84e0f288c0"><span class="GINGER_SOFTWARE_mark" id="fdf4023c-60b3-482f-995a-efd37deb4d41"><span class="GINGER_SOFTWARE_mark" id="8c816968-1707-4cef-9910-f967fd7d3cb1">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-20'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="4b70d266-7ef1-4108-9993-fc701a8aa49c"><span class="GINGER_SOFTWARE_mark" id="aa4062cf-72fe-42d4-9777-4508e83f66ca"><span class="GINGER_SOFTWARE_mark" id="556689b7-d442-4d8c-b2a7-2f6e633c0a43">,</span></span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="404820d4-0397-4548-93d2-3d37aa27234c"><span class="GINGER_SOFTWARE_mark" id="8265e18a-81f5-4570-98a7-5cde802fd6d2"><span class="GINGER_SOFTWARE_mark" id="bb16af9d-269a-47b7-b1e0-1f8fe053fe33">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="e8768266-74eb-4b70-936f-af0fb2d0ed36"><span class="GINGER_SOFTWARE_mark" id="f094e961-3825-4bea-95a3-de9746e5510d"><span class="GINGER_SOFTWARE_mark" id="b08f635a-3971-4421-a64f-bee72713643c">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="ad96c182-9ae2-4831-8698-3c49146bb6c9"><span class="GINGER_SOFTWARE_mark" id="8ff9e16d-9108-4514-a955-87b9f7680237"><span class="GINGER_SOFTWARE_mark" id="2486c8ea-1612-45ed-9b30-310535a4d565">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-20'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="0b5be207-02c9-4d1d-b420-c3896449bed1"><span class="GINGER_SOFTWARE_mark" id="3e791538-2a08-429d-8ff3-798256ae38c9"><span class="GINGER_SOFTWARE_mark" id="0c6e5e19-0721-4e8f-b53b-92fcd897bec8">,</span></span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="e146f1dc-cd11-4ac8-89b6-8248f3fd2b2d"><span class="GINGER_SOFTWARE_mark" id="446d99e8-cb4d-4816-8da6-866a74747eee"><span class="GINGER_SOFTWARE_mark" id="d6ceb3e7-3aa5-4341-a4bd-7296fdef5b4b">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="23d0ec50-47e8-4976-a78b-99ddb6e8d3f3"><span class="GINGER_SOFTWARE_mark" id="63aaa2b9-732b-4a95-a225-4a24345bcd70"><span class="GINGER_SOFTWARE_mark" id="d27a40b0-8f57-4a69-8d21-363d61a6367f">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="353e95d5-2b02-4e82-b4f1-4649b67fa080"><span class="GINGER_SOFTWARE_mark" id="13824922-f5b7-4e5a-9183-1ca1bd2e5b52"><span class="GINGER_SOFTWARE_mark" id="6769282b-6057-4b58-91ea-166420026cdd">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-22'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="875c73d3-e85f-48dd-bcfe-bb8c8da9754e"><span class="GINGER_SOFTWARE_mark" id="710f4cc1-75cf-4223-b27b-0ca4e3add2e2"><span class="GINGER_SOFTWARE_mark" id="96e5dfb2-73de-4a47-8ac1-5efd2597da7b">,</span></span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1c3bef73-dbbb-42ad-866e-d7d9ea33563b"><span class="GINGER_SOFTWARE_mark" id="f6c552ac-faa0-4976-b84b-05af8fa9b262"><span class="GINGER_SOFTWARE_mark" id="43cc7d2d-2dda-4f60-a6d5-61fd9adbbf46">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="49d24b08-81cc-4dc7-99b9-ae8f81279d5a"><span class="GINGER_SOFTWARE_mark" id="b071e1e6-5783-4a9f-bfff-d8a056503bf1"><span class="GINGER_SOFTWARE_mark" id="1a744a28-8e24-4e37-9317-0198e21b7396">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="b39e2999-2fd4-41d8-a889-7c769cf84f04"><span class="GINGER_SOFTWARE_mark" id="e360aca5-e71c-4967-86aa-ae6e5a97f17c"><span class="GINGER_SOFTWARE_mark" id="3a28abf8-48d0-44c5-8891-767a7b435ca3">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-24'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="80c140e7-13d0-4616-b491-b38e1e436ace"><span class="GINGER_SOFTWARE_mark" id="add58c92-1256-4f0e-b3b8-fc3ac35ae202"><span class="GINGER_SOFTWARE_mark" id="7f149602-c034-461b-8dfd-26b1a25dd421">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="31b05097-0673-45c2-9315-15cfe639f757"><span class="GINGER_SOFTWARE_mark" id="d368ed6f-2213-46ac-80e8-92a849315105"><span class="GINGER_SOFTWARE_mark" id="a368b93e-3db6-40ea-b167-284e7f9570bf">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="35c44a2e-4b5c-4222-a0c4-20c208a5d215"><span class="GINGER_SOFTWARE_mark" id="0cfa03e1-3ac5-4f3d-8cd7-e6ad214ee394"><span class="GINGER_SOFTWARE_mark" id="cb9e39ee-b289-4e77-b9b7-9ca61329ef35">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="9049fb3b-f273-4e90-8e37-6b53a99e12c1"><span class="GINGER_SOFTWARE_mark" id="21ecb9be-8cb9-4a38-9921-47061b97c35d"><span class="GINGER_SOFTWARE_mark" id="9e917b14-11a9-4bd6-a53e-baf6513b1c4f">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-24'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="77775ef5-35e5-410b-9e46-3122e3afe749"><span class="GINGER_SOFTWARE_mark" id="ec833cd7-205d-44c3-a3f0-01f896f0cffa"><span class="GINGER_SOFTWARE_mark" id="091b48f0-71d6-48ce-b3d3-0a8371c5de97">,</span></span></span></span><span style="color:black;">1200</span><span style="color:gray;">);<br />
</span></code></p>
<p style="text-align:justify;">STRAIGHT_JOIN can be used in two methods</p>
<h3 style="text-align:justify;">Method 1 Join tables using STRAIGHT_JOIN</h3>
<p style="text-align:left;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">t1<span class="GINGER_SOFTWARE_mark" id="6639c907-10f8-448f-954b-9426d909915f"><span class="GINGER_SOFTWARE_mark" id="fb20a77e-8d2d-437b-af54-00e4343eff8d">.</span></span>item_description</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="f2149c24-0a3a-42f8-b9cf-a2d8c947b8c6"><span class="GINGER_SOFTWARE_mark" id="732a7e0d-d758-41e4-ae6b-c180c5a6f01e">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="a98c4784-904e-4843-9d6e-878c959647c0"><span class="GINGER_SOFTWARE_mark" id="f5f34149-8dcb-4427-9d49-7db6dc4b447e">.</span></span>sales_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1207cd0b-6066-4d5d-8584-23d693c3df5f"><span class="GINGER_SOFTWARE_mark" id="4ee1132b-9a09-4f19-a274-44db8acba2a1">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="c108769e-8b45-41e1-8d7b-aa9a4c8c7e8b"><span class="GINGER_SOFTWARE_mark" id="78017350-002d-4a49-baa2-7b73c2b391c5">.</span></span>sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1a161dec-3461-4c8e-8cb2-4b367b739f40"><span class="GINGER_SOFTWARE_mark" id="eba59ab0-534e-471e-9b91-98a7c2ba3f2a">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="aef10dae-c516-4f13-9b23-15d28e13a048"><span class="GINGER_SOFTWARE_mark" id="0ad463b8-56b5-410b-9d79-1f8d4cdb8f35">.</span></span>sales_amount<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sales </span><span style="color:blue;">AS </span><span style="color:black;">t2 STRAIGHT_JOIN items </span><span style="color:blue;">AS </span><span style="color:black;">t1  </span><span style="color:blue;">ON </span><span style="color:black;">t1<span class="GINGER_SOFTWARE_mark" id="8c834d41-05e8-4c1a-890a-e8fda3fa355f"><span class="GINGER_SOFTWARE_mark" id="ce05dd99-eb21-4791-afd3-99ca1014c466">.</span></span>item_id</span><span style="color:blue;">=</span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="e6bf2d9c-1268-40f6-97f4-f2b4808747b4"><span class="GINGER_SOFTWARE_mark" id="175e5ff3-9a8a-4de8-bb4f-564e434a329a">.</span></span>item_id</span><span style="color:gray;">;<br />
</span></code></p>
<h2 style="text-align:justify;">Method 2 Use INNER JOIN to join tables and use STRAIGHT_JOIN in the SELECT clause itself</h2>
<p style="text-align:left;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">STRAIGHT_JOIN t1<span class="GINGER_SOFTWARE_mark" id="000e762d-e652-4052-a4f0-9b23a1247fb7"><span class="GINGER_SOFTWARE_mark" id="c0996b62-af6f-4869-8132-e406db5461ca">.</span></span>item_description</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="688e5ab0-c6d5-4897-8c40-6160235d89df"><span class="GINGER_SOFTWARE_mark" id="0bb030d6-eedd-4dbe-904e-299ad46a969b">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="ab3474ea-df26-43ec-8b11-90c110827a22"><span class="GINGER_SOFTWARE_mark" id="6407ef92-f187-4071-9503-ba79812a42d0">.</span></span>sales_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="dca29510-bcd5-4daf-ba11-e277588d21ec"><span class="GINGER_SOFTWARE_mark" id="8e097a1b-82ca-4c93-93e5-03609acc272a">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="bade213d-1fc3-4535-b28a-2bc3a7a1719b"><span class="GINGER_SOFTWARE_mark" id="8150ff8d-814b-4f3c-9b04-24ac8d329654">.</span></span>sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="7585b1ec-329a-4f57-b274-ef46ace865aa"><span class="GINGER_SOFTWARE_mark" id="e9f927a9-f84c-4684-850f-f3732ccbc415">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="9166c213-1b9a-457c-ad88-1744907f17cb"><span class="GINGER_SOFTWARE_mark" id="55621fd6-42a2-4496-b1d5-0bfe8baa8aed">.</span></span>sales_amount<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sales </span><span style="color:blue;">AS </span><span style="color:black;">t2 </span><span style="color:blue;">INNER JOIN </span><span style="color:black;">items </span><span style="color:blue;">AS </span><span style="color:black;">t1  </span><span style="color:blue;">ON </span><span style="color:black;">t1<span class="GINGER_SOFTWARE_mark" id="042149dd-4149-4097-bf41-675251218dd9"><span class="GINGER_SOFTWARE_mark" id="b2fe514c-7bad-4fe7-91cc-58dd35e13ecc">.</span></span>item_id</span><span style="color:blue;">=</span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="3dcb5e54-33e6-485f-9efb-7d3263716592"><span class="GINGER_SOFTWARE_mark" id="0cb500b6-5c67-49ee-94fc-2c68b46846e3">.</span></span>item_id</span><span style="color:gray;">;<br />
</span></code></p>
<p style="text-align:justify;">Both the queries produce the following result</p>
<pre>item_description sales_id sales_date sales_amount
 Television 1 1/1/2014 0:00 1200
 Mobile 2 1/2/2014 0:00 200
 <span class="GINGER_SOFTWARE_mark" id="68acc14f-dc69-4bf6-9835-3eaf2c6c21ab"><span class="GINGER_SOFTWARE_mark" id="b9b70d62-2c77-40d5-a3c5-a832e71b49c5">laptop</span></span> 3 1/9/2014 0:00 1700
 <span class="GINGER_SOFTWARE_mark" id="f45ff16f-a6b9-4b91-889c-5d8665db30fc"><span class="GINGER_SOFTWARE_mark" id="b871abb0-4c5e-42f6-9226-506e2db4445f">laptop</span></span> 4 1/29/2014 0:00 1700
 <span class="GINGER_SOFTWARE_mark" id="6444fe84-757b-4b77-9efe-5af47290e46e"><span class="GINGER_SOFTWARE_mark" id="c1c21b73-3ab7-4419-a10d-177a375791d2">laptop</span></span> 5 2/11/2014 0:00 1700
 Television 6 2/16/2014 0:00 1200
 Mobile 7 2/16/2014 0:00 200
 Mobile 8 2/20/2014 0:00 200
 Mobile 9 2/20/2014 0:00 200
 Mobile 10 2/22/2014 0:00 200
 <span class="GINGER_SOFTWARE_mark" id="98d7565a-a319-4ed3-a2d6-fe985d9fa97d"><span class="GINGER_SOFTWARE_mark" id="05d5c6b7-9e24-4ed7-b7f3-8b083a78b70b">laptop</span></span> 11 2/24/2014 0:00 1700
 Television 12 2/24/2014 0:00 1200</pre>
<p style="text-align:justify;">However the real test is when we execute the STRAIGHT_JOIN syntax with EXPLAIN command before SELECT statement and observe the order of table joined.</p>
<h3 style="text-align:justify;">Method STRAIGHT JOIN</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:black;">EXPLAIN </span><span style="color:blue;">SELECT </span><span style="color:black;">STRAIGHT_JOIN t1<span class="GINGER_SOFTWARE_mark" id="2eb8cce5-baa0-4192-9bd3-151611b3bc1f"><span class="GINGER_SOFTWARE_mark" id="6c6abcb8-8d59-460c-ac05-228bfb54cd71">.</span></span>item_description</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="cac52b80-0f57-430a-a6ac-7783f0688f5f"><span class="GINGER_SOFTWARE_mark" id="f975f903-122d-493e-929d-14b3f4a47919">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="b4e836af-64b3-4fe2-b227-1248e37e6a27"><span class="GINGER_SOFTWARE_mark" id="ade26872-e61a-48de-a91c-2dfb7358a6be">.</span></span>sales_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="43379343-706d-4f58-9ba8-55b147763291"><span class="GINGER_SOFTWARE_mark" id="9097c822-03b2-4eb6-aded-27d2040e61d3">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="e5d8fcc5-2b3c-446d-a437-68c062773cd6"><span class="GINGER_SOFTWARE_mark" id="56462ed2-5ec9-4c9d-bba0-a5c9fb3a7944">.</span></span>sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="05cc1c9d-a5bc-4ff6-8f76-aed05d0c7ee5"><span class="GINGER_SOFTWARE_mark" id="348dc7f5-06ad-488b-ae84-15ee058b6417">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="c34d6614-3ca1-4dfc-bffd-c7b90b4edd34"><span class="GINGER_SOFTWARE_mark" id="d5d76b01-3b75-43bf-9d02-40b98feff803">.</span></span>sales_amount<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sales </span><span style="color:blue;">AS </span><span style="color:black;">t2 </span><span style="color:blue;">INNER JOIN </span><span style="color:black;">items </span><span style="color:blue;">AS </span><span style="color:black;">t1 </span><span style="color:blue;">ON </span><span style="color:black;">t1<span class="GINGER_SOFTWARE_mark" id="8d8dbf85-0a0e-4e1b-8b28-cb3f61e3a686"><span class="GINGER_SOFTWARE_mark" id="1cc96abf-5415-4b14-802c-858ea2df4424">.</span></span>item_id</span><span style="color:blue;">=</span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="a86a8e7d-a808-40fa-9111-8beaaf88b412"><span class="GINGER_SOFTWARE_mark" id="08ec8b14-3e43-42f1-80ac-6d731c24ff06">.</span></span>item_id</span><span style="color:gray;">;</span></code></p>
<p style="text-align:justify;">Now let us see the result where we observe the order of tables used in Join.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/mysql/straightjoin2.jpg" width="850" height="120" /></p>
<p style="text-align:justify;">You will notice that Sales Table which is aliased as t2 is first used in the result set.</p>
<h3 style="text-align:justify;">Method INNER JOIN (without Straight Join)</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:black;">EXPLAIN </span><span style="color:blue;">SELECT </span><span style="color:black;">t1<span class="GINGER_SOFTWARE_mark" id="25b3500e-7dfc-4a34-8170-ec8078a99037"><span class="GINGER_SOFTWARE_mark" id="15242f29-ac15-4074-8508-27632089d70b">.</span></span>item_description</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="16ec79b1-5f53-429d-9094-c3ba68d7772b"><span class="GINGER_SOFTWARE_mark" id="a17351a3-94f6-4d5c-84e3-923d019a5311">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="bb41ad60-caee-4173-adaa-589098b88031"><span class="GINGER_SOFTWARE_mark" id="5579ab58-a35f-4636-80eb-2fec82815d51">.</span></span>sales_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="e6888dad-f4ac-4ab6-9580-49a7834b21f5"><span class="GINGER_SOFTWARE_mark" id="a7cded3c-c6b7-4399-bdbe-4e60db0107dd">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="8f3cc83a-811a-4497-b764-e513a1b32593"><span class="GINGER_SOFTWARE_mark" id="9c1fbc3f-c7f5-4e58-b6fb-81e2b7a40049">.</span></span>sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="4db22320-788d-4ea5-953d-ae9bc772e991"><span class="GINGER_SOFTWARE_mark" id="08ac0c56-8a33-4894-8153-c24ccf048ff3">,</span></span></span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="0b82737f-3eee-4e36-84fc-a42b0cded1c7"><span class="GINGER_SOFTWARE_mark" id="f0e2fc26-c2fc-4028-aa37-fbe563b438c1">.</span></span>sales_amount<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">sales </span><span style="color:blue;">AS </span><span style="color:black;">t2 </span><span style="color:blue;">INNER JOIN </span><span style="color:black;">items </span><span style="color:blue;">AS </span><span style="color:black;">t1 </span><span style="color:blue;">ON </span><span style="color:black;">t1<span class="GINGER_SOFTWARE_mark" id="a8ade3ce-52eb-4be6-b033-2da53599364d"><span class="GINGER_SOFTWARE_mark" id="9f3d9e93-1051-4d73-831a-5fa56763c9cb">.</span></span>item_id</span><span style="color:blue;">=</span><span style="color:black;">t2<span class="GINGER_SOFTWARE_mark" id="52930a99-587d-4464-978e-1b5937652c8e"><span class="GINGER_SOFTWARE_mark" id="cb1cd040-cce2-48ba-b969-64fb3b5d18ff">.</span></span>item_id</span><span style="color:gray;">;</span></code></p>
<p style="text-align:justify;">Now let us see the result where we observe the order of tables used in Join.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/mysql/straightjoin3.jpg" width="844" height="81" /></p>
<p style="text-align:justify;">You will notice that Sales Table which is aliased as t2 is second used in the result set. That means MySQL <span class="GINGER_SOFTWARE_mark" id="0633ddb4-8bd8-4e64-894f-3fb2d1d4045c"><span class="GINGER_SOFTWARE_mark" id="c65313ab-9e77-4468-aece-027a58818bd4">have</span></span> used internal optimizer and re-ordered the table order for maximum performance.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/mysql/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26982/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26982/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26982/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26982/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26982/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26982/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26982/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26982/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26982&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/12/mysql-how-to-do-straight-join-in-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/mysql/straightjoin2.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/mysql/straightjoin3.jpg" medium="image" />
	</item>
		<item>
		<title>SQL Contest &#8211; Win Amazon Gift Cards &#8211; Learn How to Get Started with ClustrixDB</title>
		<link>http://blog.sqlauthority.com/2014/03/11/sql-contest-win-amazon-gift-cards-learn-how-to-get-started-with-clustrixdb/</link>
		<comments>http://blog.sqlauthority.com/2014/03/11/sql-contest-win-amazon-gift-cards-learn-how-to-get-started-with-clustrixdb/#comments</comments>
		<pubDate>Tue, 11 Mar 2014 01:30:41 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Clustrix]]></category>
		<category><![CDATA[ClustrixDB]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26955</guid>
		<description><![CDATA[It has been a long time since we contest where we can learn something new and win something cool. I reached out to the good folks of Clustrix with the request to help me to build a contest where readers can learn and explore new technology, while stand a good chance to win something good. Before [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26955&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;"><img class="alignleft" alt="" src="http://www.pinaldave.com/bimg/wincontest.jpg" width="300" />It has been a long time since we contest where we can learn something new and win something cool. I reached out to the good folks of Clustrix with the request to help me to build a contest where readers can learn and explore new technology, while stand a good chance to win something good.</p>
<p style="text-align:justify;">Before we jump into the contest, let us quickly understand what Clustrix is all about in four simple points:</p>
<ul style="text-align:justify;">
<li><span class="GINGER_SOFTWARE_mark" id="4ab46dad-72d2-4ddb-8aae-b37792eb741c"><span class="GINGER_SOFTWARE_mark" id="1d941593-e0ef-490b-b543-0faeb129e7cf"><span class="GINGER_SOFTWARE_mark" id="ecebd425-a0b7-4e2f-9220-5a5f5fca215b"><span class="GINGER_SOFTWARE_mark" id="b8ba0ce8-697f-456a-bbfd-780921707ed0"><span class="GINGER_SOFTWARE_mark" id="c250a100-36ba-4967-8c37-a7117e2cb27a"><span class="GINGER_SOFTWARE_mark" id="96fc6a15-566b-49e6-ab87-25d5afba6742"><span class="GINGER_SOFTWARE_mark" id="2303a3fd-70dd-41af-807b-00794d7c2c56">ClustrixDB</span></span></span></span></span></span></span> can scale reads, writes, updates and analytics, — near linearly — as you add nodes. The scale-out architecture of the cloud means that the new cloud applications use scale-out NoSQL or SQL databases, and most often a combination of both.</li>
<li>Real-time analytics <span class="GINGER_SOFTWARE_mark" id="3c4b724b-dd4e-47ea-a615-6c5b89c8a9d1"><span class="GINGER_SOFTWARE_mark" id="3d505ce9-20a3-49be-8811-cbc105d8665f"><span class="GINGER_SOFTWARE_mark" id="ceec5cc2-187b-4a72-95dd-e57414ec723c"><span class="GINGER_SOFTWARE_mark" id="78f3769a-ef6b-4808-9cd0-d577b59d5bba"><span class="GINGER_SOFTWARE_mark" id="c51111f1-1ab4-4415-81fb-bc7bf381968a"><span class="GINGER_SOFTWARE_mark" id="50335111-00d8-458d-80d4-0b644635c54a"><span class="GINGER_SOFTWARE_mark" id="b3b019e9-94bb-4692-9840-08df096cd947">is</span></span></span></span></span></span></span> analytics on your live operational database, up to date to the current moment. <span class="GINGER_SOFTWARE_mark" id="c921412f-6f75-4f2d-a981-9804b57ea3a1"><span class="GINGER_SOFTWARE_mark" id="54d82690-a8fd-4523-9b46-7850c54161c1"><span class="GINGER_SOFTWARE_mark" id="d6078627-147e-4f31-844b-8e0133e5d43e"><span class="GINGER_SOFTWARE_mark" id="59e3785d-a711-41f9-9b2c-688f13b852c8"><span class="GINGER_SOFTWARE_mark" id="d6d88fd3-e44b-48e8-8162-ef4ebe110124"><span class="GINGER_SOFTWARE_mark" id="fd96d162-1659-462c-ac3e-0b1b31e8d264"><span class="GINGER_SOFTWARE_mark" id="52a5f052-0fc3-426c-92ec-87bcb3f88656">ClustrixDB</span></span></span></span></span></span></span> allows real-time insights into your business and fast, current reports for your business and self-serve customers.</li>
<li><span class="GINGER_SOFTWARE_mark" id="57dde6f7-585a-48bc-ac51-81ed80f7e7f2"><span class="GINGER_SOFTWARE_mark" id="63db1748-095a-49df-b3dc-f310755eace1"><span class="GINGER_SOFTWARE_mark" id="549cf18a-b864-4ad5-9270-0446aa5dbd09"><span class="GINGER_SOFTWARE_mark" id="73878268-8069-4e8a-a3ee-feeea4eedc88"><span class="GINGER_SOFTWARE_mark" id="05f1ff1b-2873-4499-a928-26ad4721a41b"><span class="GINGER_SOFTWARE_mark" id="6e73540d-a964-4045-84ad-e344648b421a"><span class="GINGER_SOFTWARE_mark" id="3cdcdaf3-efe1-4578-93d1-c8a874d3923e">ClustrixDB</span></span></span></span></span></span></span> has powered mission-critical business applications for more than three years, with trillions of transactions per month running on ClustrixDB. Proven in massive transaction volume environments with an appliance form factor, ClustrixDB is now being used by multiple customers across the globe as software and on public clouds such as AWS.</li>
<li>Several databases and data management platforms are now on the market. We created a series of landscapes to help our customers determine the right solution to their problem. Whether primary or analytics, <span class="GINGER_SOFTWARE_mark" id="407795db-d0ad-420f-b4f8-2d836e1c3b64"><span class="GINGER_SOFTWARE_mark" id="1a763006-bed6-4aba-9246-de191805e983"><span class="GINGER_SOFTWARE_mark" id="4a2f858c-2d52-4fcf-926d-ea29d9c738cb"><span class="GINGER_SOFTWARE_mark" id="d123196e-3268-4387-95a8-fb25226faa12"><span class="GINGER_SOFTWARE_mark" id="2fce2e56-b153-4444-898f-ccd15eca39c3"><span class="GINGER_SOFTWARE_mark" id="8f6c79e0-7c37-486a-9b24-6c420e074472"><span class="GINGER_SOFTWARE_mark" id="575e979d-1085-43a7-9d04-20dd942006b1">SQL or</span></span></span></span></span></span></span> NoSQL–comparing features gives clarity.</li>
</ul>
<p style="text-align:justify;">If you have directly skipped to this statement, I encourage to read the four bullet points above, it is indeed interesting to know that there are solution exists in the market which can help our mission critical problems. Now let us jump to details of the contest.</p>
<h2 style="text-align:justify;">Contest Details</h2>
<p style="text-align:justify;"><b style="text-align:justify;line-height:1.5em;">Step 1: Download and Install ClustrixDB here using the community license</b></p>
<p style="text-align:justify;"><strong><a href="http://bit.ly/clustrix" target="_blank" rel="nofollow">Click Here to Download</a></strong></p>
<p style="text-align:justify;"><b>Step 2: Do one thing with ClustrixDB </b><br />
<span class="GINGER_SOFTWARE_mark" id="af4f708e-a57c-444b-930d-b5fba98f358a"><span class="GINGER_SOFTWARE_mark" id="40a388ed-6717-4942-8737-a8972adac5b2"><span class="GINGER_SOFTWARE_mark" id="21aef894-4e36-4a43-ae60-c383e1829fd6"><span class="GINGER_SOFTWARE_mark" id="eb7b5ad4-9009-44ad-acd8-8d048ec00837"><span class="GINGER_SOFTWARE_mark" id="4cad5ed5-b92b-4358-bb32-f0390fad3a26"><span class="GINGER_SOFTWARE_mark" id="3af5dd60-4a40-4eaf-957a-46401b7339cc"><span class="GINGER_SOFTWARE_mark" id="1f538528-bbd9-466f-ae3d-375eecd32594"><span class="GINGER_SOFTWARE_mark" id="74a1e01b-c677-44c2-833e-8873157d6227">ClustrixDB</span></span></span></span></span></span></span></span> is nearly plug-and-play compatible with MySQL. You can do any of the following tasks:</p>
<ul style="text-align:justify;">
<li>Load Data</li>
<li>Create a Table</li>
<li>Create an online schema change</li>
<li>Run an Analytics query</li>
<li>Or any other task which is a core database task</li>
</ul>
<p style="text-align:justify;"><b>Step 3: Post it on the ClustrixDB forum (<a href="http://bit.ly/clustrix-support" target="_blank" rel="nofollow">http://support.clustrix.com/forums/</a>):</b></p>
<ol style="text-align:justify;">
<li>The current database you use</li>
<li><span class="GINGER_SOFTWARE_mark" id="77f10856-bfbb-49c6-ad70-af6c3607eb6b"><span class="GINGER_SOFTWARE_mark" id="6424935b-32f1-4414-b09f-180909cbf7ae">Snapshot</span></span> (or screenshot) of what you did with ClustrixDB</li>
</ol>
<p style="text-align:justify;">That&#8217;s it! It is that simple and it will also give you exposure how to get going with ClustrixDB as well enable you to Win Amazon Gift Card.</p>
<h2 style="text-align:justify;">Prize for Winner (Total worth USD 200)</h2>
<ul style="text-align:justify;">
<li><img class="alignright" alt="" src="http://www.pinaldave.com/bimg/amazon-gift-cards.jpg" width="300" height="256" />10 Amazon Gift Cards each of USD 20</li>
<li><span style="line-height:1.5em;">3 Gift Cards will go to the first 3 posts and the remaining 7 will be raffled among the other posts.</span></li>
<li>Post your entry before March 20th Midnight EST.</li>
</ul>
<p style="text-align:justify;">Well, if you are an early bird, indeed there is a guaranteed prize for you as you can read the second bullet point above.</p>
<h2 style="text-align:justify;">Hints</h2>
<p style="text-align:justify;">Well, if you want few helps regarding how to do any of the above tasks. Here are a few articles which you can follow:</p>
<ul>
<li><a href="http://docs.clustrix.com/display/CLXDOC/Getting+Started+on+ClustrixDB+Software" target="_blank" rel="nofollow">Getting Started on ClustrixDB Software</a></li>
<li><a href="http://docs.clustrix.com/display/CLXDOC/Importing+Data" target="_blank" rel="nofollow">Importing Data</a></li>
<li><a href="http://docs.clustrix.com/display/CLXDOC/Creating+the+Database+and+Loading+Data" target="_blank" rel="nofollow">Creating the Database and Loading Data</a></li>
<li><a href="http://docs.clustrix.com/display/CLXDOC/Best+Practices+for+Loading+Data+Onto+Clustrix" target="_blank" rel="nofollow">Best Practices for Loading Data Onto Clustrix</a></li>
</ul>
<p style="text-align:justify;">Let me know what you think of this contest and ClustrixDB. I have a surprise prize for one of the participation in this contest. I will announce it <span class="GINGER_SOFTWARE_mark" id="7868bc30-6396-478a-afc9-e95406420cc7"><span class="GINGER_SOFTWARE_mark" id="edeeed97-a979-4fbd-ab7d-cc0dc8c3264c"><span class="GINGER_SOFTWARE_mark" id="577dced1-042b-4948-9c7b-c2bce77e3763"><span class="GINGER_SOFTWARE_mark" id="3431816d-fd20-4d5b-807a-1b2936d079aa"><span class="GINGER_SOFTWARE_mark" id="23d3ab6a-3f39-4c88-8a83-6691f0761a14">with</span></span></span></span></span> the winner list after March 20th.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/clustrix/'>Clustrix</a>, <a href='http://blog.sqlauthority.com/tag/clustrixdb/'>ClustrixDB</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26955/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26955&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/11/sql-contest-win-amazon-gift-cards-learn-how-to-get-started-with-clustrixdb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/wincontest.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/amazon-gift-cards.jpg" medium="image" />
	</item>
		<item>
		<title>MySQL &#8211; How to do Natural Join in MySQL? &#8211; A Key Difference Between Inner Join and Natural Join</title>
		<link>http://blog.sqlauthority.com/2014/03/10/mysql-how-to-do-natural-join-in-mysql-a-key-difference-between-inner-join-and-natural-join/</link>
		<comments>http://blog.sqlauthority.com/2014/03/10/mysql-how-to-do-natural-join-in-mysql-a-key-difference-between-inner-join-and-natural-join/#comments</comments>
		<pubDate>Mon, 10 Mar 2014 01:30:37 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Joins]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26948</guid>
		<description><![CDATA[As you know MySQL supports ANSI JOINs like INNER JOIN, OUTER JOIN, CROSS JOIN etc. Do you know that it supports NATURAL JOIN?. A NATURAL JOIN is a type of JOIN which automatically maps the similar columns from both the tables. Let us create the following tables CREATE TABLE items(item_id INT, item_description VARCHAR(100)); CREATE TABLE [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26948&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">As you know MySQL supports ANSI JOINs like INNER JOIN, OUTER JOIN, CROSS JOIN etc. Do you know that it supports NATURAL JOIN?. A NATURAL JOIN is a type of JOIN which automatically maps the similar columns from both the tables.</p>
<p style="text-align:justify;">Let us create the following tables<br />
<code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">items</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="4b65c0f3-06ae-4e19-a606-8aac9788f93d"><span class="GINGER_SOFTWARE_mark" id="4edbeac8-2cfc-4109-b477-edfe3516d38a"><span class="GINGER_SOFTWARE_mark" id="582c1027-e5b0-4f7e-9745-31e9974544c1">(</span></span></span></span><span style="color:black;">item_id </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">item_description </span><span style="color:blue;">VARCHAR</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="965ad8a5-7503-45da-9f2a-d028cd49830b"><span class="GINGER_SOFTWARE_mark" id="f69cd2fe-0516-4496-86c4-4374c33a0ba5"><span class="GINGER_SOFTWARE_mark" id="688f5d95-52e3-47cc-a0ca-7e88deed954f">(</span></span></span></span><span style="color:black;">100</span><span style="color:gray;">));<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a2536ddd-7b33-4fec-afcf-3b96d83130ad"><span class="GINGER_SOFTWARE_mark" id="bbe7b6e5-68cd-4c0d-b3eb-f61bdc04cdd5"><span class="GINGER_SOFTWARE_mark" id="33018a6b-c450-499f-807e-a6f7102a8c64">(</span></span></span></span><span style="color:black;">sales_id </span><span style="color:blue;">INT </span><span style="color:black;">auto_increment </span><span style="color:blue;">KEY</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="92345d41-625b-4adc-affb-dd233ae834b9"><span class="GINGER_SOFTWARE_mark" id="b71ea58c-9b51-47ea-9e65-368b21f15b0d"><span class="GINGER_SOFTWARE_mark" id="75a7b9d7-2362-4ad1-ab36-ba50893783e3">,</span></span></span></span><span style="color:black;">item_id </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">sales_date </span><span style="color:blue;">DATETIME</span><span style="color:gray;">, </span><span style="color:black;">sales_amount </span><span style="color:blue;">DECIMAL</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="703d7c8a-3d2a-4e88-839c-4fae1601c852"><span class="GINGER_SOFTWARE_mark" id="9761909e-be2e-4008-bdac-1d6075e63b8e"><span class="GINGER_SOFTWARE_mark" id="f4a5ed69-8940-4ffc-9381-9cb37cb4d1d8">(</span></span></span></span><span style="color:black;">12</span><span style="color:gray;">,</span><span style="color:black;">2</span><span style="color:gray;">));<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'Television'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'Mobile'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">items </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'laptop'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="b0a872e1-de5e-47bd-9def-25c87b09b161"><span class="GINGER_SOFTWARE_mark" id="91a31e62-b15d-42d3-9a9b-61b6f8929b5d"><span class="GINGER_SOFTWARE_mark" id="1221e526-0511-4a91-9d08-0c8603d15610">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="42a80413-427f-48aa-946d-896865a8060b"><span class="GINGER_SOFTWARE_mark" id="6fc3aba5-ff51-44fe-a04c-9bff8be653a8"><span class="GINGER_SOFTWARE_mark" id="3b42233f-827c-4d83-bb54-2ba64b6ebffd">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="8499d9f4-f718-4794-a139-eda46395a6af"><span class="GINGER_SOFTWARE_mark" id="f8791c35-809d-48d8-8a2a-a3f86d78be0e"><span class="GINGER_SOFTWARE_mark" id="e8299b51-bf3b-416a-95a8-03fba01511bd">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-01'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="2bb4c64c-dcd4-479c-a4be-e227f853622a"><span class="GINGER_SOFTWARE_mark" id="c6eb8b54-bc9d-4447-9b83-e2b5bbf1b92d"><span class="GINGER_SOFTWARE_mark" id="50b8e01b-4565-4640-a5d1-76b8f5daf0cb">,</span></span></span></span><span style="color:black;">1200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="e968b877-21cb-459d-8672-e7465575a88f"><span class="GINGER_SOFTWARE_mark" id="670840ce-ee74-4a28-b8ef-a1adca937f60"><span class="GINGER_SOFTWARE_mark" id="cff21861-f86a-4bcc-bf6a-17465e031956">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c8dd05f3-3f52-4f94-a292-04f5e8b1c1ec"><span class="GINGER_SOFTWARE_mark" id="5256152e-305f-4c79-9935-d4bab1af6ba3"><span class="GINGER_SOFTWARE_mark" id="d73ff048-6489-45d3-b62f-16a6174e058b">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c04e0e85-8fb0-488f-ae21-97c5ab0cdc8c"><span class="GINGER_SOFTWARE_mark" id="99f8f88c-ae6a-4a39-9864-f301e8fb7288"><span class="GINGER_SOFTWARE_mark" id="6e392a46-b3c1-4b9a-8bc7-4c04e9e07f34">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-02'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="d52a2fbb-39f3-495b-bc19-d0c97ee8fc4b"><span class="GINGER_SOFTWARE_mark" id="a2057058-cae7-4210-9215-def4c11a4bb6"><span class="GINGER_SOFTWARE_mark" id="c60e2f61-1eea-4d51-bf5e-b74ea37898d7">,</span></span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="f2f868c9-a672-4e65-bed1-684dd43f8055"><span class="GINGER_SOFTWARE_mark" id="a2b7da35-351d-455c-b76e-7817ec597d87"><span class="GINGER_SOFTWARE_mark" id="cf87498d-70ca-4fa0-9e57-e32e66edfaca">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="7db08066-41a3-4317-bbba-366fbaecf67b"><span class="GINGER_SOFTWARE_mark" id="c4cb736e-1841-4763-9ddf-44a76845bb86"><span class="GINGER_SOFTWARE_mark" id="c0760d05-fcb3-4a1a-87c7-40bdc0843d51">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="eab1fb4d-48b1-4e68-ad23-994d03057654"><span class="GINGER_SOFTWARE_mark" id="a04c4a2b-189a-4345-b7d3-67a8e5214400"><span class="GINGER_SOFTWARE_mark" id="bccc301c-258a-4a4f-9205-ee10e615c222">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-09'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="dd22e006-4747-4f17-886e-33f3448321c9"><span class="GINGER_SOFTWARE_mark" id="c2044faf-2d97-4665-b5ca-740e80843d33"><span class="GINGER_SOFTWARE_mark" id="b3a27dff-373f-48c7-87e8-d77d728b30ac">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="ab90838d-0ba6-4990-bf0f-c17ccde1d037"><span class="GINGER_SOFTWARE_mark" id="1952f03e-3087-4e56-982c-0ffd7e820e81"><span class="GINGER_SOFTWARE_mark" id="626efa17-5957-40f4-9005-a83899a68a11">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="70ddc49e-9fe9-44a1-a813-3c678b35546d"><span class="GINGER_SOFTWARE_mark" id="5fe526ac-5d7b-4a57-96fa-d68c681b1364"><span class="GINGER_SOFTWARE_mark" id="d874e734-27e0-472c-a700-92df20d821e5">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="2021ca91-aa14-40c5-b4e1-03d1d4cdc2d1"><span class="GINGER_SOFTWARE_mark" id="d2f1aafb-49f8-40c4-a599-0bdd6ed3d6ea"><span class="GINGER_SOFTWARE_mark" id="29081314-12f6-4792-b29a-823d7ca38c94">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-01-29'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a0195a7c-4101-417d-bda7-56e9a479bc7a"><span class="GINGER_SOFTWARE_mark" id="bf7dc0a5-1e94-4d74-8fc5-7eb26ba711cc"><span class="GINGER_SOFTWARE_mark" id="61ef8b5a-0a67-4955-a400-fb4aee693f05">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="822c9842-c09f-446e-a55e-07eba33f9288"><span class="GINGER_SOFTWARE_mark" id="eb7b7658-1614-4224-9b2b-8a491e5f0e60"><span class="GINGER_SOFTWARE_mark" id="3c331d5c-a100-4078-96a1-6a1c700fdb67">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1516d4c7-3f35-4b50-91a3-d8d27061d691"><span class="GINGER_SOFTWARE_mark" id="31a2273d-71b1-431c-9d1e-e076135f1557"><span class="GINGER_SOFTWARE_mark" id="8b8da438-bf6e-435a-8b98-0c83222d6ee9">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a6e1d2cf-1e18-43a7-937f-c08cd5bb50d8"><span class="GINGER_SOFTWARE_mark" id="f71410c1-ff32-4d0e-b4da-e8774b296d9a"><span class="GINGER_SOFTWARE_mark" id="0e304024-48b1-4a54-9634-6acd44ea7988">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-11'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="b8520808-0667-4247-83ba-e71dc205710e"><span class="GINGER_SOFTWARE_mark" id="48a26619-1b1b-4da2-871c-a1f004d0b272"><span class="GINGER_SOFTWARE_mark" id="960a05a5-d823-4c60-97f1-5331aca7647a">,</span></span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="826a5d36-07e3-4268-8000-4581148879b5"><span class="GINGER_SOFTWARE_mark" id="473a0bcc-3db9-4ca9-8694-ca25ea0bcc2f"><span class="GINGER_SOFTWARE_mark" id="d397be2d-aea9-44a0-92f7-b90a9970f3b4">(</span></span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="ccf1c7bd-7437-4891-838e-a228d6346389"><span class="GINGER_SOFTWARE_mark" id="827a4a6b-e3a9-44c9-9b44-b17619cb6790"><span class="GINGER_SOFTWARE_mark" id="7fca4a4b-d445-4a34-9d97-4ce4a2993449">,</span></span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a87ad94a-80c6-4e74-af8b-d7725652d143"><span class="GINGER_SOFTWARE_mark" id="c51e85ca-a64a-4c04-ae91-7d4f695822cd"><span class="GINGER_SOFTWARE_mark" id="e13e95fd-e8fd-4ac5-bd93-8168c966e51b">,</span></span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-16'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="5645e9be-c200-49c6-ad99-4dbcc0e05323"><span class="GINGER_SOFTWARE_mark" id="a482e85f-75f3-43b7-aa7e-fcf2f393991e"><span class="GINGER_SOFTWARE_mark" id="7ab93c57-16f6-4081-b740-dbe4655974b8">,</span></span></span></span><span style="color:black;">1200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="a2c0f67f-5921-4152-85df-974ff7a8f755"><span class="GINGER_SOFTWARE_mark" id="2609671a-a7b8-49cb-a308-6be8aca58783">(</span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="9f009bfe-d045-43f9-9eaa-e5382c8959d3"><span class="GINGER_SOFTWARE_mark" id="db2ccb40-c797-4c4f-ab7d-4301a8a000ba">,</span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="24f8c7ae-13a8-41be-8379-8f30d75411b1"><span class="GINGER_SOFTWARE_mark" id="b5ec3dad-8dc1-468b-9b00-bf70824ce287">,</span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-16'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="6acd10d8-fe5c-404d-8447-3ffaa21548d0"><span class="GINGER_SOFTWARE_mark" id="670006e3-a0df-4e42-aaea-90850a6a2cb5">,</span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="50b7db3d-a3dd-4822-9e55-00d1da47663c"><span class="GINGER_SOFTWARE_mark" id="320cdc45-d989-47b8-b82c-86cbbad17f41">(</span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="18e03185-4b38-416a-8947-0386c8534e1b"><span class="GINGER_SOFTWARE_mark" id="e8612aca-4a01-4959-b36d-14c5656aaa75">,</span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="2243e8ed-a4a1-40ee-8e0a-523618d392c2"><span class="GINGER_SOFTWARE_mark" id="aad8192a-5ab2-4e50-982c-7b8490538bd9">,</span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-20'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="4f098d90-78d7-4886-910d-ffdf1a6ec8a0"><span class="GINGER_SOFTWARE_mark" id="9ece702f-06c4-4197-9105-98e8698343cf">,</span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="267307f2-035d-4184-87f7-a0683cd1bb23"><span class="GINGER_SOFTWARE_mark" id="498ba1c8-4fe8-4ba8-a654-c276945db419">(</span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="f8cf10cd-88b0-4dc0-ac32-dcd121d1a41c"><span class="GINGER_SOFTWARE_mark" id="5fdb1937-5f2b-41c1-84f9-fe2ae8d7bbca">,</span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="71fa31ab-c896-4b26-911c-cf220c0b5eb6"><span class="GINGER_SOFTWARE_mark" id="885db23f-3b68-48b1-a5a1-40a4048b16ff">,</span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-20'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="3dd40274-7a05-4a78-8034-d10640eac843"><span class="GINGER_SOFTWARE_mark" id="7fcd6f19-ff02-44f3-9fe6-0c4325ac2a16">,</span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="100ca604-ef19-4952-a5dc-84407899d321"><span class="GINGER_SOFTWARE_mark" id="931380fc-b5c4-46e5-900a-7e71335397b5">(</span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="06d81dfe-83e2-4b0b-a1d8-37886ada5399"><span class="GINGER_SOFTWARE_mark" id="1e43d07b-f6b1-49c0-b8cc-1c2a760483af">,</span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="fc94f9e1-64be-41e1-ae7c-1e6d14ed5274"><span class="GINGER_SOFTWARE_mark" id="638a59e0-8626-4717-891f-daedf9584572">,</span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">2</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-22'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="f66901d9-aced-486f-9183-2395c10b7238"><span class="GINGER_SOFTWARE_mark" id="3bb05718-9add-4093-93ba-871d73cf491d">,</span></span></span><span style="color:black;">200</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="dbba8031-b75f-4181-aa1f-1fd385f632c5"><span class="GINGER_SOFTWARE_mark" id="fb6fa7d3-c944-45af-84cc-ef26fd7b4429">(</span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="26a64cd3-8ff3-4f36-bfe0-3f3b88874d5d"><span class="GINGER_SOFTWARE_mark" id="9afdeb66-873f-4e7e-854f-1f30bc194413">,</span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="56f7b95f-8cfc-46f7-8ea2-4d90d2ffaecb"><span class="GINGER_SOFTWARE_mark" id="590dea25-50da-42b2-9054-9c10a2869123">,</span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">3</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-24'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1a303651-2795-4543-a671-9c603f8848ab"><span class="GINGER_SOFTWARE_mark" id="6e244729-3c6a-460e-b96e-29870b6ea098">,</span></span></span><span style="color:black;">1700</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">sales</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c2bc27bd-4584-4353-9517-e958e26cdea3"><span class="GINGER_SOFTWARE_mark" id="1c90d4c3-509b-48b1-a405-132aa46f8a67">(</span></span></span><span style="color:black;">item_id</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="be2f2f27-52c5-42d7-9f02-b5c910ed1748"><span class="GINGER_SOFTWARE_mark" id="c4637af6-f889-4625-b4c8-6f277ea2bbfc">,</span></span></span><span style="color:black;">sales_date</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="acc25351-6b03-4871-87f2-5252dfa5463a"><span class="GINGER_SOFTWARE_mark" id="cd28b858-110c-4107-b466-71c2897c75f8">,</span></span></span><span style="color:black;">sales_amount</span><span style="color:gray;">) </span><span style="color:blue;">VALUES </span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">,</span><span style="color:red;">'2014-02-24'</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c4974397-25af-40c4-a75c-7ec5408ff61d"><span class="GINGER_SOFTWARE_mark" id="7cc5a8f0-18b4-45fe-a2fb-7570487b20d4">,</span></span></span><span style="color:black;">1200</span><span style="color:gray;">);<br />
</span></code></p>
<p style="text-align:justify;">By using the NATURAL JOIN, we can select only distinct columns by using * in the SELECT statement.<br />
<code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:gray;">* </span><span style="color:blue;">FROM </span><span style="color:black;">items NATURAL </span><span style="color:blue;">JOIN </span><span style="color:black;">sales</span><span style="color:gray;">;</span></code></p>
<p style="text-align:justify;">The result is</p>
<pre>item_id Item_description sales_id sales_date sales_amount
 1 Television 1 2014-01-01 00:00:00 1200.00
 2 Mobile 2 2014-01-02 00:00:00 200.00
 3 laptop 3 2014-01-09 00:00:00 1700.00
 3 laptop 4 2014-01-29 00:00:00 1700.00
 3 laptop 5 2014-02-11 00:00:00 1700.00
 1 Television 6 2014-02-16 00:00:00 1200.00
 2 Mobile 7 2014-02-16 00:00:00 200.00
 2 Mobile 8 2014-02-20 00:00:00 200.00
 2 Mobile 9 2014-02-20 00:00:00 200.00
 2 Mobile 10 2014-02-22 00:00:00 200.00
 3 laptop 11 2014-02-24 00:00:00 1700.00
 1 Television 12 2014-02-24 00:00:00 1200.00</pre>
<p style="text-align:justify;">As you have noticed, * does not return all the columns from both the tables. The common column item_id is chosen first, followed by other columns in the tables items and sales. But if you use INNER JOIN with SELECT * all the columns will be selected which will result to duplicate columns in the <span class="GINGER_SOFTWARE_mark" id="75f4d4d9-cb2c-446a-8c5a-6461fadef6a3"><span class="GINGER_SOFTWARE_mark" id="e0140502-8288-4678-b3e3-4527e53a69aa"><span class="GINGER_SOFTWARE_mark" id="0beb63eb-8294-4979-9a51-15a61df33e29">resultset</span>.</span></span></p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/naturaljoin.jpg" width="541" height="858" /></p>
<p style="text-align:justify;">You can also use the USING clause with INNER JOIN to produce the same result.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:gray;">* </span><span style="color:blue;">FROM </span><span style="color:black;">items </span><span style="color:blue;">INNER JOIN </span><span style="color:black;">sales USING </span><span style="color:gray;">(</span><span style="color:black;">item_id</span><span style="color:gray;">);</span></code></p>
<p style="text-align:justify;">In the above statement item_id is used to map both the tables.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-joins/'>SQL Joins</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26948/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26948/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26948/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26948/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26948/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26948/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26948/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26948/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26948&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/10/mysql-how-to-do-natural-join-in-mysql-a-key-difference-between-inner-join-and-natural-join/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/naturaljoin.jpg" medium="image" />
	</item>
		<item>
		<title>MySQL &#8211; Reset Row Number for Each Group &#8211; Partition By Row Number</title>
		<link>http://blog.sqlauthority.com/2014/03/09/mysql-reset-row-number-for-each-group-partition-by-row-number/</link>
		<comments>http://blog.sqlauthority.com/2014/03/09/mysql-reset-row-number-for-each-group-partition-by-row-number/#comments</comments>
		<pubDate>Sun, 09 Mar 2014 01:30:34 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Ranking Functions]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26874</guid>
		<description><![CDATA[In earlier post, we have learnt how to generate row number for each row using a variable as MySQL does not have any system function like SQLServer&#8217;s row_number() to generate the row number. In this post we will see how to reset row number for each group (Alternate method for SQL Server&#8217;s row_number() over Partition [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26874&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">In <span class="GINGER_SOFTWARE_mark" id="42a3652e-811e-4305-96bc-fea259d5d01a"><span class="GINGER_SOFTWARE_mark" id="18397f29-afcd-4e2e-af30-98ec4f29a089"><span class="GINGER_SOFTWARE_mark" id="ffc4a897-0e79-4460-8d93-3e79e41d5ebe">earlier post</span></span></span>, we have learnt how to generate <span class="GINGER_SOFTWARE_mark" id="1b3f1d52-0322-45d7-8afe-173fbf123ea3"><span class="GINGER_SOFTWARE_mark" id="820ba545-809a-42e9-88b4-5eb5a526506b"><span class="GINGER_SOFTWARE_mark" id="98c80947-5d4e-4206-98d2-9bbff9ac5816">row number</span></span></span> for each row using a variable as MySQL does not have any system function like <span class="GINGER_SOFTWARE_mark" id="562bbf1a-8ec5-4495-b326-1e0f40839c1f"><span class="GINGER_SOFTWARE_mark" id="c5c22305-a142-4003-be62-86c1d2390e33"><span class="GINGER_SOFTWARE_mark" id="4f2c62f1-d3aa-46ba-aecc-764656cd6a68">SQLServer&#8217;s</span></span></span> row_number<span class="GINGER_SOFTWARE_mark" id="2350a4bd-ab26-47e3-bb0e-bd9a494192b0"><span class="GINGER_SOFTWARE_mark" id="9e014292-a628-4927-92fb-072574ee1913"><span class="GINGER_SOFTWARE_mark" id="94fd2cc7-df16-4ccf-92d1-eac8ca2ae565">(</span></span></span>) to generate the row number. In this post we will see how to reset <span class="GINGER_SOFTWARE_mark" id="e34e5cd4-93df-448a-bc63-f9dbd9bada07"><span class="GINGER_SOFTWARE_mark" id="3729e4ca-d383-4100-86bc-79dce4f81a90"><span class="GINGER_SOFTWARE_mark" id="ba390f86-1b7e-4871-ad79-8127651c1876">row number</span></span></span> for each group (Alternate method for SQL Server&#8217;s row_number<span class="GINGER_SOFTWARE_mark" id="316c15d4-4c0b-4e09-aeca-7b5f0209cf3c"><span class="GINGER_SOFTWARE_mark" id="1553f878-4197-40d5-82ee-8055d62fe5c2"><span class="GINGER_SOFTWARE_mark" id="ba8aa2b2-b1b6-4f4b-a7e2-ada27f61e394">(</span></span></span>) over Partition by method).</p>
<p style="text-align:justify;">Let us use the following data</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">mysql_testing</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="99e0663f-9687-426c-862e-1a4d9335a457"><span class="GINGER_SOFTWARE_mark" id="ea72b0d2-671c-4b01-8702-51a14af48316"><span class="GINGER_SOFTWARE_mark" id="ad7dd3e5-d7eb-4228-bf58-78abe0494a35">(</span></span></span></span><span style="color:black;">db_names </span><span style="color:blue;">VARCHAR</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1b71e0a7-2308-4b76-9770-103a91e99023"><span class="GINGER_SOFTWARE_mark" id="184e424a-95b1-4640-a00b-52e73bd4b266"><span class="GINGER_SOFTWARE_mark" id="d27340f8-04a5-4c95-8622-9e644eeb48a1">(</span></span></span></span><span style="color:black;">100</span><span style="color:gray;">));<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">mysql_testing<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'SQL Server' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MySQL' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'SQL Server' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MongoDB' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'SQL Server' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MySQL' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Oracle' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'PostGreSQL' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MongoDB' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'SQL Server' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'SQL Server' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MongoDB' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MySQL' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Oracle' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MongoDB' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'PostGreSQL'</span><span style="color:gray;">;</span></code></p>
<p style="text-align:justify;">Now you can generate the row number using two variables and reset it for each group of db_names in two methods. The idea is to use two <span class="GINGER_SOFTWARE_mark" id="f4c342be-cced-4d49-9d86-c9a909aa7e29"><span class="GINGER_SOFTWARE_mark" id="54181570-a2e4-409f-b990-4d7980418db4">variables one for</span></span> incrementing the numbers and <span class="GINGER_SOFTWARE_mark" id="ce660b8c-0e5a-4a8f-ade3-42b3d2b80be2"><span class="GINGER_SOFTWARE_mark" id="3a88bb68-86e3-4215-8f13-5be70f5de52e">other</span></span> that can be used to reset the number in to 1 whenever group value changes.</p>
<h3 style="text-align:justify;">Method 1<span class="GINGER_SOFTWARE_mark" id="db361a9d-11e7-4b58-ac9e-38586afbf9c2"><span class="GINGER_SOFTWARE_mark" id="cf93c0a0-3514-4de5-ad89-7b2b8f68b9f2"> :</span></span> Set a variable and use it in a SELECT statement and reset whenever group value changes</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SET </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="c5ac6070-a6bc-4084-a449-91ae3a0218da"><span class="GINGER_SOFTWARE_mark" id="c0173125-628a-4d33-b24d-d6d4cabe9515">:</span></span></span><span style="color:blue;">=</span><span style="color:black;">0</span><span style="color:gray;">;<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@db_names<span class="GINGER_SOFTWARE_mark" id="5a8f3e17-f53a-43d8-bcec-8047c2f204df"><span class="GINGER_SOFTWARE_mark" id="2a5e8f59-6c32-4ea3-a3cf-cd9dc04b1524">:</span></span></span><span style="color:blue;">=</span><span style="color:red;">''</span><span style="color:gray;">;<br />
</span><span style="color:blue;">SELECT </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="af38aada-0c0f-472f-bafe-65799fcb7089"><span class="GINGER_SOFTWARE_mark" id="c2b6ec24-0c7c-45c1-99ad-94c7dfa91e44">:</span></span></span><span style="color:blue;">=</span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:#434343;">@db_names</span><span style="color:blue;">=</span><span style="color:black;">db_names </span><span style="color:blue;">THEN </span><span style="color:#434343;">@row_number</span><span style="color:gray;">+</span><span style="color:black;">1 </span><span style="color:blue;">ELSE </span><span style="color:black;">1 </span><span style="color:blue;">END AS </span><span style="color:black;">row_number</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="d12d1278-56c2-4667-a0c6-ca8e616594dc"><span class="GINGER_SOFTWARE_mark" id="acedad3a-8eec-4cfa-988a-346e60c40c3d">,</span></span></span><span style="color:#434343;">@db_names<span class="GINGER_SOFTWARE_mark" id="9ed8fbd0-3eda-4cd6-b97a-ec6200020607"><span class="GINGER_SOFTWARE_mark" id="e10e6a8e-11b4-4e62-a974-b8b702d6f645">:</span></span></span><span style="color:blue;">=</span><span style="color:black;">db_names </span><span style="color:blue;">AS </span><span style="color:black;">db_names<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">mysql_testing<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">db_names</span><span style="color:gray;">;</span></code></p>
<h3 style="text-align:justify;">Method 2<span class="GINGER_SOFTWARE_mark" id="d5ba4c9e-b588-42b6-a258-55e5a1c2047a"><span class="GINGER_SOFTWARE_mark" id="11a9a6cf-7222-4af0-a760-c39aa96c3d28"> :</span></span> Use a variable as a table and cross join it with the source table and reset whenever group value changes</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="2d08faf8-aa08-4155-8349-bc17a74cb078"><span class="GINGER_SOFTWARE_mark" id="71c83078-3e35-4659-990d-03dc43b2c03d">:</span></span></span><span style="color:blue;">=</span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:#434343;">@db_names</span><span style="color:blue;">=</span><span style="color:black;">db_names </span><span style="color:blue;">THEN </span><span style="color:#434343;">@row_number</span><span style="color:gray;">+</span><span style="color:black;">1 </span><span style="color:blue;">ELSE </span><span style="color:black;">1 </span><span style="color:blue;">END AS </span><span style="color:black;">row_number</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="1177fe91-a40b-4a04-8f55-17cf6d618058"><span class="GINGER_SOFTWARE_mark" id="5f9f1e9b-63f3-45af-8f94-b10e9d1b94fb">,</span></span></span><span style="color:#434343;">@db_names<span class="GINGER_SOFTWARE_mark" id="cd7ec64f-0d4d-481c-9a97-81944c7ceb0b"><span class="GINGER_SOFTWARE_mark" id="c631373f-c149-4be7-bc2f-07d735ee2ba0">:</span></span></span><span style="color:blue;">=</span><span style="color:black;">db_names </span><span style="color:blue;">AS </span><span style="color:black;">db_names<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">mysql_testing</span><span style="color:gray;">, (</span><span style="color:blue;">SELECT </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="1e51a3a1-52cd-47b5-bedb-a8563ce2cf71"><span class="GINGER_SOFTWARE_mark" id="76dfcbc6-c019-4daa-9f56-99c5ac84b056">:</span></span></span><span style="color:blue;">=</span><span style="color:black;">0</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="56b4b1a3-90c3-42bb-821d-eb8435ce5059"><span class="GINGER_SOFTWARE_mark" id="0612d877-9c31-4d1e-a6cd-d92440ff659c">,</span></span></span><span style="color:#434343;">@db_names<span class="GINGER_SOFTWARE_mark" id="e8a5a239-33ab-4487-aa84-d8f8618764b8"><span class="GINGER_SOFTWARE_mark" id="10f00115-244f-4b62-bf5a-cc1ce77d18bc">:</span></span></span><span style="color:blue;">=</span><span style="color:red;">''</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">t<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">db_names</span><span style="color:gray;">;</span></code></p>
<p style="text-align:justify;">Both the above methods return the following result</p>
<pre>row_number db_names
 1 MongoDB
 2 MongoDB
 3 MongoDB
 4 MongoDB
 1 MySQL
 2 MySQL
 3 MySQL
 1 Oracle
 2 Oracle
 1 PostGreSQL
 2 PostGreSQL
 1 SQL Server
 2 SQL <span class="GINGER_SOFTWARE_mark" id="be8d28bd-f4f5-40b9-8d73-b8b6d63bb76a">Server</span>
 3 SQL <span class="GINGER_SOFTWARE_mark" id="797e41a5-365b-4f49-b46c-ae14da1f10ec">Server</span>
 4 SQL <span class="GINGER_SOFTWARE_mark" id="a15668c9-1680-4461-86e4-7e2ebe0c7441">Server</span>
 5 SQL <span class="GINGER_SOFTWARE_mark" id="1b3294d1-5671-481b-984f-c5fa0d8333d3">Server</span></pre>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/ranking-functions/'>Ranking Functions</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26874/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26874/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26874/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26874/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26874/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26874/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26874/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26874/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26874&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/09/mysql-reset-row-number-for-each-group-partition-by-row-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL &#8211; Generating Row Number for Each Row using Variable</title>
		<link>http://blog.sqlauthority.com/2014/03/08/mysql-generating-row-number-for-each-row-using-variable/</link>
		<comments>http://blog.sqlauthority.com/2014/03/08/mysql-generating-row-number-for-each-row-using-variable/#comments</comments>
		<pubDate>Sat, 08 Mar 2014 01:30:41 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Ranking Functions]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26869</guid>
		<description><![CDATA[MySQL does not have any system function like SQL Server&#8217;s row_number () to generate the row number for each row. However, it can be generated using the variable in the SELECT statement. The following table has five rows. CREATE TABLE mysql_testing(db_names VARCHAR(100)); INSERT INTO mysql_testing SELECT 'SQL Server' UNION ALL SELECT 'MySQL' UNION ALL SELECT [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26869&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;"><img class="alignleft" alt="" src="http://www.pinaldave.com/bimg/rankingimage.jpg" width="340" height="174" /></p>
<p style="text-align:justify;">MySQL does not have any system function like SQL Server&#8217;s row_number () to generate the row number for each row. However, it can be generated using the variable in the SELECT statement.</p>
<p style="text-align:justify;">The following table has five rows.<br />
<code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">mysql_testing</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="5b966b03-0390-4347-8c29-bfb5636d6c76"><span class="GINGER_SOFTWARE_mark" id="43c078c0-d04f-4901-a592-9fbb0e0eec41">(</span></span></span><span style="color:black;">db_names </span><span style="color:blue;">VARCHAR</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="6110fd62-7347-4f47-a8b5-78afd98c0626"><span class="GINGER_SOFTWARE_mark" id="d47c0d32-d5ce-4820-b966-202de2b632db">(</span></span></span><span style="color:black;">100</span><span style="color:gray;">));<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">mysql_testing<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'SQL Server' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MySQL' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'Oracle' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'MongoDB' </span><span style="color:blue;">UNION </span><span style="color:gray;">ALL<br />
</span><span style="color:blue;">SELECT </span><span style="color:red;">'PostGreSQL'</span><span style="color:gray;">;</span><span style="color:gray;"><br />
</span></code></p>
<p style="text-align:justify;">Now you can generate the row number using a variable in two methods</p>
<h3 style="text-align:justify;">Method 1<span class="GINGER_SOFTWARE_mark" id="711dc912-d560-4529-95ef-c524b677ab27"><span class="GINGER_SOFTWARE_mark" id="4ef5e601-129f-439d-90c6-877153d3174b"><span class="GINGER_SOFTWARE_mark" id="bc71f86e-c94e-47b3-8da1-795b9e0e40fe"> :</span></span></span> Set a variable and use it in a SELECT statement</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SET </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="86f10d2c-eb8a-4d99-b24e-79267ee12e35"><span class="GINGER_SOFTWARE_mark" id="262c94ea-9428-4a59-9096-0ff5f039a6e1">:</span></span></span><span style="color:blue;">=</span><span style="color:black;">0</span><span style="color:gray;">;<br />
</span><span style="color:blue;">SELECT </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="6ad48a8b-3255-4c71-aa01-c9f3e5432111"><span class="GINGER_SOFTWARE_mark" id="8b74eedc-3a82-43aa-bb94-58dd450278bf">:</span></span></span><span style="color:blue;">=</span><span style="color:#434343;">@row_number</span><span style="color:gray;">+</span><span style="color:black;">1 </span><span style="color:blue;">AS </span><span style="color:black;">row_number</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="f138133a-5d5a-4bd9-ac29-19d235e812c9"><span class="GINGER_SOFTWARE_mark" id="98c68a67-486d-4870-8079-ae62c643dfc6">,</span></span></span><span style="color:black;">db_names </span><span style="color:blue;">FROM </span><span style="color:black;">mysql_testing<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">db_names</span><span style="color:gray;">;<br />
</span></code></p>
<h3 style="text-align:justify;">Method 2<span class="GINGER_SOFTWARE_mark" id="c0d201ea-6402-4d49-9f23-05e569c6d53e"><span class="GINGER_SOFTWARE_mark" id="fec6d744-8058-413f-a3a6-a15dfaaccf48"><span class="GINGER_SOFTWARE_mark" id="fa8efa7f-4644-47a2-872f-34c55db6880f"> :</span></span></span> Use a variable as a table and cross join it with the source table</h3>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="50951485-d5bd-4742-8a26-a246ea7f184c"><span class="GINGER_SOFTWARE_mark" id="ae38d830-261e-4f29-b0c8-59314d513a44">:</span></span></span><span style="color:blue;">=</span><span style="color:#434343;">@row_number</span><span style="color:gray;">+</span><span style="color:black;">1 </span><span style="color:blue;">AS </span><span style="color:black;">row_number</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="c640858c-d03a-4b4f-a151-56647ed884e9"><span class="GINGER_SOFTWARE_mark" id="3196a649-719b-4efb-9f66-e2adbdbe427d">,</span></span></span><span style="color:black;">db_names </span><span style="color:blue;">FROM </span><span style="color:black;">mysql_testing</span><span style="color:gray;">, (</span><span style="color:blue;">SELECT </span><span style="color:#434343;">@row_number<span class="GINGER_SOFTWARE_mark" id="93a7b72c-753a-4951-a5af-e538881675f1"><span class="GINGER_SOFTWARE_mark" id="d46549a6-7a8c-4967-8d6d-010add549b68">:</span></span></span><span style="color:blue;">=</span><span style="color:black;">0</span><span style="color:gray;">) </span><span style="color:blue;">AS </span><span style="color:black;">t<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">db_names</span><span style="color:gray;">;</span></code></p>
<p style="text-align:justify;">Both the above methods return the following result</p>
<pre>row_number db_names
 1 MongoDB
 2 MySQL
 3 Oracle
 4 PostGreSQL
 5 SQL <span class="GINGER_SOFTWARE_mark" id="6191871a-31de-4900-bcd7-f1c3840c5a49"><span class="GINGER_SOFTWARE_mark" id="59f01dcd-6d24-46d5-9583-b92f80a4c8c2">Server</span></span></pre>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank" rel="nofollow">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/ranking-functions/'>Ranking Functions</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26869/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26869/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26869/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26869&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/08/mysql-generating-row-number-for-each-row-using-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/rankingimage.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Retrieve Maximum Length of Object Name with sp_server_info</title>
		<link>http://blog.sqlauthority.com/2014/03/07/sql-server-retrieve-maximum-length-of-object-name-with-sp_server_info/</link>
		<comments>http://blog.sqlauthority.com/2014/03/07/sql-server-retrieve-maximum-length-of-object-name-with-sp_server_info/#comments</comments>
		<pubDate>Fri, 07 Mar 2014 01:30:04 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Stored Procedure]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26890</guid>
		<description><![CDATA[A very common question which I often receive is - &#8220;How big my table name can be?&#8221; The answer is simple 128.  You can figure this out by executing stored procedure sp_server_info on SQL Server. Execute following stored procedure in SQL Server. EXEC sp_server_info It will return following resultset. attribute_id attribute_name attribute_value 1 DBMS_NAME Microsoft SQL [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26890&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">A very common question which I often receive is<span class="GINGER_SOFTWARE_mark" id="03d5cca6-f326-4b3d-8cc7-e2448a78d124"> -</span></p>
<p style="text-align:justify;"><em><strong>&#8220;How big my table name can be?&#8221;</strong></em></p>
<p style="text-align:justify;">The answer is simple <strong>128</strong>.  You can figure this out by executing stored procedure sp_server_info on SQL Server.</p>
<p style="text-align:justify;">Execute following stored procedure in SQL Server.</p>
<p style="text-align:justify;">EXEC sp_server_info</p>
<p style="text-align:justify;">It will return following <span class="GINGER_SOFTWARE_mark" id="3aac6ad5-4064-423f-9ebb-a3d9845ccdab">resultset</span>.</p>
<pre>attribute_id attribute_name attribute_value
1 DBMS_NAME Microsoft SQL Server
2 DBMS_VER Microsoft SQL Server 2012 - 11.0.3000.0
10 OWNER_TERM <span class="GINGER_SOFTWARE_mark" id="efd8a6d4-1691-4066-9d64-071fdf561d41">owner</span>
11 TABLE_TERM <span class="GINGER_SOFTWARE_mark" id="ed93cedc-a927-42fa-a39c-a491174689c1">table</span>
12 MAX_OWNER_NAME_LENGTH 128
<strong>13 TABLE_LENGTH 128</strong>
14 MAX_QUAL_LENGTH 128
15 COLUMN_LENGTH 128
16 IDENTIFIER_CASE MIXED
17 TX_ISOLATION 2
18 COLLATION_SEQ charset=iso_1 sort_order=nocase_iso charset_num=1 sort_order_num=52
19 SAVEPOINT_SUPPORT Y
20 MULTI_RESULT_SETS Y
22 ACCESSIBLE_TABLES Y
100 USERID_LENGTH 128
101 QUALIFIER_TERM <span class="GINGER_SOFTWARE_mark" id="8b68eb81-189a-431c-abd7-5d42a49f5aa7">database</span>
102 NAMED_TRANSACTIONS Y
103 SPROC_AS_LANGUAGE Y
104 ACCESSIBLE_SPROC Y
105 MAX_INDEX_COLS 16
106 RENAME_TABLE Y
107 RENAME_COLUMN Y
108 DROP_COLUMN Y
109 INCREASE_COLUMN_LENGTH Y
110 DDL_IN_TRANSACTION Y
111 DESCENDING_INDEXES Y
112 SP_RENAME Y
113 REMOTE_SPROC Y
500 SYS_SPROC_VERSION 11.00.3000</pre>
<p style="text-align:justify;">In the result set you can notice there is a row with information TABLE_LENGTH and the value is 128. There are few other information related to server is also listed in the result set.</p>
<p style="text-align:justify;">Though, a regular <span class="GINGER_SOFTWARE_mark" id="dc78ac44-125e-4455-9b05-4cee486ae9f1">tablename</span> can be 128 <span class="GINGER_SOFTWARE_mark" id="dd7a8ef5-eb88-4318-a515-28c3d8f1f846">character</span> long, a temporary table cannot be longer than 116 <span class="GINGER_SOFTWARE_mark" id="e8ad6d1f-0b0f-4998-845e-dfe7a8023f14">character</span>. You can read the detailed blog post over here <strong><a href="http://blog.sqlauthority.com/2012/05/01/sql-server-maximum-allowable-length-of-characters-for-temp-objects-is-116-guest-post-by-balmukund-lakhani/" target="_blank">Maximum Allowable Length of Characters for Temp Objects is 116 – Guest Post by Balmukund Lakhani</a></strong>.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/sql-stored-procedure/'>SQL Stored Procedure</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26890/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26890/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26890/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26890/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26890/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26890/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26890/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26890/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26890&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/07/sql-server-retrieve-maximum-length-of-object-name-with-sp_server_info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Performance Statistic Collection &#8211; Notes from the Field #018</title>
		<link>http://blog.sqlauthority.com/2014/03/06/sql-server-performance-statistic-collection-notes-from-the-field-018/</link>
		<comments>http://blog.sqlauthority.com/2014/03/06/sql-server-performance-statistic-collection-notes-from-the-field-018/#comments</comments>
		<pubDate>Thu, 06 Mar 2014 01:30:32 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[Notes from the Field]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26934</guid>
		<description><![CDATA[[Note from Pinal]: This is a 18th episode of Notes from the Field series. Performance is very crucial subject and to come up with the right strategy along with a performance one needs to have more knowledge related to the overall performance of the server. However, most of the organization does not come up with the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26934&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">[Note from Pinal]: This is <span class="GINGER_SOFTWARE_mark" id="a84a6317-9fae-4ea8-9b94-d2fc84f673ca"><span class="GINGER_SOFTWARE_mark" id="e571e17c-ed54-47da-a82c-2247c746487e">a</span></span> 18th episode of <strong>Notes from the Field</strong> series. Performance is very crucial subject and to come up with the right strategy along with a performance one needs to have more knowledge related to the overall performance of the server. However, most of the organization does not come up with the best strategies related to performance. It is very crucial that DBA collects performance statistics of the entire collection methodologically and scientifically.</p>
<p style="text-align:justify;"><img class="alignleft" style="line-height:1.5;" alt="" src="http://www.pinaldave.com/bimg/KleeD.jpg" width="150" /></p>
<p style="text-align:justify;">In this episode of the Notes from the Field series database expert <strong><a href="http://www.davidklee.net/" target="_blank" rel="nofollow">David Klee</a></strong> explains a very crucial issue <span class="GINGER_SOFTWARE_mark" id="ec722212-c31d-4358-90d2-b015a14cd6b9"><span class="GINGER_SOFTWARE_mark" id="555ca963-eb24-4270-ad35-5a027a7dce74"><span class="GINGER_SOFTWARE_mark" id="226323b9-6f7b-461c-bacf-20b81bf078c2"><span class="GINGER_SOFTWARE_mark" id="f64f16aa-6017-410e-af4b-3ec3ef213ee9">DBAs and</span></span></span></span> Developer faces in their career &#8211; how to collect performance statistics. Linchpin People are database coaches and wellness experts for a data driven world. Read the experience of John in his own words.</p>
<hr />
<p style="text-align:justify;">Performance statistics are critically vital for the long-term health and capacity management of an enterprise environment. Ongoing performance metric collection ensures that you, the DBA, have the metrics of a system’s operating state whenever a performance problem is <span class="GINGER_SOFTWARE_mark" id="b3f983ab-1eb5-4032-8a36-e2214e375d31"><span class="GINGER_SOFTWARE_mark" id="3275a5ad-027d-4a1e-9777-52b1e5e95a30"><span class="GINGER_SOFTWARE_mark" id="e9de12ca-31be-4c6f-a7ae-bfd8ce5588c0"><span class="GINGER_SOFTWARE_mark" id="1c798a23-b8bd-4764-bf32-a37f7be130aa"><span class="GINGER_SOFTWARE_mark" id="dadcc9bc-d741-4d31-9ecd-c76c4aec5112">reporter</span></span></span></span></span> – either real-time or historically. Too many times when I am <span class="GINGER_SOFTWARE_mark" id="7956c455-671a-4629-8bc6-8db878bdf700"><span class="GINGER_SOFTWARE_mark" id="1819be05-6c3b-45fc-9176-69cac2143336"><span class="GINGER_SOFTWARE_mark" id="af6b0bb9-2c81-4d03-bab7-c8c7f28afd16"><span class="GINGER_SOFTWARE_mark" id="5bb9ca70-f8e9-4024-a2fb-da12701bf4b0"><span class="GINGER_SOFTWARE_mark" id="55cbc9f5-f2f6-45d0-95b8-66691b0c1307">troubleshooting</span></span></span></span></span> a well-known performance problem, the client has no metrics about the system state during the time window where end users reported performance problems.</p>
<p style="text-align:justify;">Let’s fix that. We need some performance statistic collection.</p>
<h3 style="text-align:justify;">Why Collect Around the Clock?</h3>
<p style="text-align:justify;">Are you able to definitively state that, at 10:48pm tonight, you will have unusually high disk latency on your SQL Server archival data volume? If so, become a consultant and the world is yours! For the rest of us, our reality would be an email tomorrow morning stating that the application was ‘slow’ last night and the customer service reps received complaints. We would normally not have any method to get a clear picture of the state of our system last night, and without the numbers, are now left to start looking at the <i>current</i> system state to see if the issue reported is still lingering in the system.</p>
<p style="text-align:justify;">Constant, around-the-clock performance statistic sampling is the simplest method of achieving this goal. Wouldn’t you like to be able to generate charts like the following at any time to get a simple picture of what your servers were doing at any given time?</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/performancetuning1.png" width="601" height="279" /></p>
<p style="text-align:justify;">A picture says a thousand words, and this simple graph quickly tells the reader the times where the system was busy. The underlying data was collected with Windows Perfmon on a five-minute interval throughout the week, and loaded into a database where an SSRS report is emailed out to the administrators every morning. The reports are quickly reviewed each morning as the DBA performs the usual morning review, and if an anomaly is present, would be quickly discovered.</p>
<h3 style="text-align:justify;">Methods for Collection</h3>
<p style="text-align:justify;">Quite a number of third-party utilities from your favorite tooling vendors exists to assist you with ongoing performance statistic collection. They work great and I highly endorse any tool that makes you more efficient. But, if you do not have one of these utilities, or the price is prohibitive, you already have a tool that can handle this task for you. Windows Performance Monitor, or Perfmon, is built into the Windows Server operating system, and can be configured to constantly record performance statistics for future use.</p>
<p style="text-align:justify;">Use the directions at Technet (link to <a href="http://technet.microsoft.com/en-us/library/cc749249.aspx">http://technet.microsoft.com/en-us/library/cc749249.aspx</a>) to set up an ongoing performance data collector set to collect information around the clock. I generally use a five-minute polling interval to start with. If you know you are experiencing <span class="GINGER_SOFTWARE_mark" id="fe802ee7-0d57-46dd-a2a4-b7d2e3cc323b"><span class="GINGER_SOFTWARE_mark" id="50ad36f1-8426-4b44-ace0-60117f494f98"><span class="GINGER_SOFTWARE_mark" id="be8d73a1-97b1-4b8d-98e1-b78da12388a5"><span class="GINGER_SOFTWARE_mark" id="751e5342-b124-4304-80db-adf977094468"><span class="GINGER_SOFTWARE_mark" id="f316e2a2-e26f-4d31-a3e0-f04086977a1d">undiagnosed</span></span></span></span></span> performance issues, increase the polling interval.</p>
<h3 style="text-align:justify;">What to Collect</h3>
<p style="text-align:justify;">The following list of Windows and SQL Server WMI counters should get you the basics needed to help with troubleshooting current performance problems. Feel free to modify this list according to your environment and your specific needs. The following web site contains a list of the performance counters and their descriptions.</p>
<p style="text-align:justify;"><a href="http://technet.microsoft.com/en-us/library/cc768048.aspx">http://technet.microsoft.com/en-us/library/cc768048.aspx</a></p>
<p style="text-align:justify;"><b>Note:</b> if a counter has multiple instances of a selected object, make sure you select &lt;All instances&gt; so the counters are separated appropriately. This option helps you get individual statistics for objects like CPU cores or disk drive letters.</p>
<h3 style="text-align:justify;"><b>Windows Server Counters</b></h3>
<table width="570" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="bottom" nowrap="nowrap" width="233"><b>Counter Group</b></td>
<td valign="bottom" nowrap="nowrap" width="336"><b><span class="GINGER_SOFTWARE_mark" id="e32a3924-ed36-41c8-a092-f4530cd7c968"><span class="GINGER_SOFTWARE_mark" id="2010883d-9a4c-48d1-a735-22074d73059b"><span class="GINGER_SOFTWARE_mark" id="b0f58ded-020e-4d70-b71d-0d42718288b6"><span class="GINGER_SOFTWARE_mark" id="65d2d1ca-00f1-4466-abe2-e619538a089a"><span class="GINGER_SOFTWARE_mark" id="eb24778c-b272-471b-9734-400622515784">Counter</span></span></span></span></span> Set</b></td>
</tr>
<tr>
<td rowspan="3" valign="top" nowrap="nowrap" width="233">Memory</td>
<td valign="top" nowrap="nowrap" width="336">Available Mbytes</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Page Faults / <span class="GINGER_SOFTWARE_mark" id="77adc5f8-42e5-4f34-aa8b-91f2bca00fee"><span class="GINGER_SOFTWARE_mark" id="2215e82c-44ca-4173-84eb-03c30ba9fc47"><span class="GINGER_SOFTWARE_mark" id="37183943-53d3-4550-8ceb-4b2c29d12b03"><span class="GINGER_SOFTWARE_mark" id="7c4a3c04-6da9-48f2-a7a6-2b1919e04b72"><span class="GINGER_SOFTWARE_mark" id="8e9192cc-cb70-44f3-bbb3-38d8ad08d355">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Pages / <span class="GINGER_SOFTWARE_mark" id="2b93dd22-ca3a-4be3-bc47-45a278da223a"><span class="GINGER_SOFTWARE_mark" id="e507ec97-cd3d-4f3d-a8e5-902f249cc71d"><span class="GINGER_SOFTWARE_mark" id="6e8ae1c6-2656-4840-99cf-9335b9a35c58"><span class="GINGER_SOFTWARE_mark" id="18157ad6-be75-4a60-a760-19190c7bae82"><span class="GINGER_SOFTWARE_mark" id="05b4e3d8-08d1-45ea-a11d-bb07c1463e25">sec</span></span></span></span></span></td>
</tr>
<tr>
<td rowspan="2" valign="top" nowrap="nowrap" width="233">Network Interface</td>
<td valign="top" nowrap="nowrap" width="336">Bytes Received / <span class="GINGER_SOFTWARE_mark" id="a3f28590-448b-4af3-a69b-37f75f7a1478"><span class="GINGER_SOFTWARE_mark" id="4a3fe9c1-dd70-40c6-a7d2-4e282747ef0a"><span class="GINGER_SOFTWARE_mark" id="b65d27f2-32c0-4ab2-b151-aabd964f1793"><span class="GINGER_SOFTWARE_mark" id="5fd95bbb-0849-478c-b64c-6e0c52e7710f"><span class="GINGER_SOFTWARE_mark" id="c8b30bf6-7235-43c7-ad8d-597f337c82de">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Bytes Sent / <span class="GINGER_SOFTWARE_mark" id="b62cba95-7df7-461c-8333-f98262246c16"><span class="GINGER_SOFTWARE_mark" id="0c5b79d7-0af1-40a7-b451-66ebfff4b7c3"><span class="GINGER_SOFTWARE_mark" id="14359f4d-ef0a-4641-ae8e-112d70787d2d"><span class="GINGER_SOFTWARE_mark" id="06e852dc-3764-4ca1-80ca-3ac220a07bea"><span class="GINGER_SOFTWARE_mark" id="bdb19a88-0134-40e7-82cb-e5f6927611bf">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="233">Paging File</td>
<td valign="top" nowrap="nowrap" width="336">% Usage</td>
</tr>
<tr>
<td rowspan="9" valign="top" nowrap="nowrap" width="233"><span class="GINGER_SOFTWARE_mark" id="384f2401-4632-4850-ace6-9be4ba1c6a3b"><span class="GINGER_SOFTWARE_mark" id="9d4cad1b-e950-4bbb-8138-1cd2cb4db147"><span class="GINGER_SOFTWARE_mark" id="af8fe1e8-a9f9-49ef-bafe-f919ccdb7547"><span class="GINGER_SOFTWARE_mark" id="cd796b7b-8dcd-4dcd-b26e-ac6a90c2f3f9"><span class="GINGER_SOFTWARE_mark" id="2bacec16-f5d2-4646-9bd4-d73c13dc9d9d">PhysicalDisk</span></span></span></span></span></td>
<td valign="top" nowrap="nowrap" width="336">% Idle Time</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Average Disk Bytes / Read</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Average Disk Bytes / Write</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Average Disk <span class="GINGER_SOFTWARE_mark" id="ef955367-a017-44e8-b402-276dc83b33ec"><span class="GINGER_SOFTWARE_mark" id="03ec7183-8553-495f-84f7-1c57d0bb6eab"><span class="GINGER_SOFTWARE_mark" id="66ebbc29-e3ea-453f-b30a-57e3982dbc37"><span class="GINGER_SOFTWARE_mark" id="b336dc21-e50b-4fd3-9cac-4548d85b7023"><span class="GINGER_SOFTWARE_mark" id="a06e5e87-f9d6-42d8-80ca-c37a678e5550">sec</span></span></span></span></span> / Read</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Average Disk <span class="GINGER_SOFTWARE_mark" id="0d1ec00f-819b-41ba-8a9c-c47feebab0f2"><span class="GINGER_SOFTWARE_mark" id="4e92038e-1fff-4ed9-90f7-37e4bf26587f"><span class="GINGER_SOFTWARE_mark" id="b9bc90d8-ee4c-4940-80ad-183ebc674451"><span class="GINGER_SOFTWARE_mark" id="54dc8978-8ce7-48ab-84ae-45600721e3ee"><span class="GINGER_SOFTWARE_mark" id="a049a816-c7f9-4019-85f7-f198676465fd">sec</span></span></span></span></span> / Write</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Disk Read Bytes / <span class="GINGER_SOFTWARE_mark" id="238cf288-0b30-49b1-b0bc-1306e60b38df"><span class="GINGER_SOFTWARE_mark" id="be3ae5dc-a99e-43d8-a2e3-af9c0324ec26"><span class="GINGER_SOFTWARE_mark" id="1895831b-be33-4481-8110-a8ee919fbd1e"><span class="GINGER_SOFTWARE_mark" id="fc550bd3-1094-48e1-9dd7-5ec65d0fb22c"><span class="GINGER_SOFTWARE_mark" id="d42abbb9-3cda-4bd9-aef5-c4129ce4c439">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Disk Reads / <span class="GINGER_SOFTWARE_mark" id="826d0e14-1ff6-4826-9294-f8a571036abb"><span class="GINGER_SOFTWARE_mark" id="3662e25c-27ed-4dc7-b726-c153909c4fc3"><span class="GINGER_SOFTWARE_mark" id="3a209b3f-04e1-44fe-9d99-2bf22113e825"><span class="GINGER_SOFTWARE_mark" id="3cdbe08a-af7b-4a3a-84bd-1521a5b626d7"><span class="GINGER_SOFTWARE_mark" id="1ba6fffe-eaa9-4d3e-924e-e1dc84044b6c">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Disk Write Bytes / <span class="GINGER_SOFTWARE_mark" id="4c0bbeba-6cf1-4329-802e-7d097aa5b126"><span class="GINGER_SOFTWARE_mark" id="087c9415-f556-4e01-9910-33f1508771c4"><span class="GINGER_SOFTWARE_mark" id="926af6ab-b9d0-4427-8e82-57e023bc9798"><span class="GINGER_SOFTWARE_mark" id="14a41694-ecf9-4eac-80e5-dbe82a2251b2"><span class="GINGER_SOFTWARE_mark" id="2831b89b-9b62-4126-9b7e-81e3efdeab56">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">Disk Writes / <span class="GINGER_SOFTWARE_mark" id="88344c2d-d974-4b72-9262-441e676f717c"><span class="GINGER_SOFTWARE_mark" id="816c92ea-5761-431c-9b49-0a94eaf9a6b5"><span class="GINGER_SOFTWARE_mark" id="1b13dacc-1f49-4200-8718-90779a53acaa"><span class="GINGER_SOFTWARE_mark" id="767972b1-67b6-4dc4-86bd-3b6447f80a41"><span class="GINGER_SOFTWARE_mark" id="98f4230d-d733-4e36-8839-f4167c72eef1">sec</span></span></span></span></span></td>
</tr>
<tr>
<td rowspan="3" valign="top" nowrap="nowrap" width="233">Processor</td>
<td valign="top" nowrap="nowrap" width="336">% Privileged Time</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">% Processor Time</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="336">% User Time</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="233">System</td>
<td valign="top" nowrap="nowrap" width="336">Processor Queue Length</td>
</tr>
</tbody>
</table>
<h3 style="text-align:justify;"><b>SQL Server Counters</b></h3>
<table width="570" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" nowrap="nowrap" width="262"><b>Counter Group</b></td>
<td valign="top" nowrap="nowrap" width="308"><b><span class="GINGER_SOFTWARE_mark" id="649bcf79-982a-46c5-a090-a7069ff57329"><span class="GINGER_SOFTWARE_mark" id="b1d17683-d3f7-4066-bc70-29ef36e236dc"><span class="GINGER_SOFTWARE_mark" id="747feda5-4b55-43cd-85cc-26fe2e39f491"><span class="GINGER_SOFTWARE_mark" id="a8bec268-9e91-479f-8054-4892462d130a"><span class="GINGER_SOFTWARE_mark" id="cad4662d-a748-49b0-8614-d917d9ebdae8">Counter</span></span></span></span></span> Set</b></td>
</tr>
<tr>
<td rowspan="2" valign="top" nowrap="nowrap" width="262">Process (sqlserver.exe)</td>
<td valign="top" nowrap="nowrap" width="308">% Processor Time</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">% Privileged Time</td>
</tr>
<tr>
<td rowspan="4" valign="top" nowrap="nowrap" width="262">SQL Server<span class="GINGER_SOFTWARE_mark" id="ca7f03ce-d50d-4928-b014-09ea4dcad5f2"><span class="GINGER_SOFTWARE_mark" id="4a580a22-bdd5-4206-91ff-fdfa9eba2f3a"><span class="GINGER_SOFTWARE_mark" id="134ba45f-ab69-4206-8c6b-94d19955c6f9"><span class="GINGER_SOFTWARE_mark" id="518622e4-02fc-4254-a9f7-7f325fb93295"><span class="GINGER_SOFTWARE_mark" id="f7559058-f17e-4b5e-934d-1572c9b2d1e2">:</span></span></span></span></span>Buffer Manager</td>
<td valign="top" nowrap="nowrap" width="308">Lazy writes/<span class="GINGER_SOFTWARE_mark" id="adc322ce-abf8-422a-b750-873e4b6b6e78"><span class="GINGER_SOFTWARE_mark" id="bfbf03a8-6c2c-454c-86b5-4756e72ee547"><span class="GINGER_SOFTWARE_mark" id="51b1237a-761b-4578-b666-026cbe987dc2"><span class="GINGER_SOFTWARE_mark" id="8cd4d388-a6f9-47e8-99b6-2bcdc0c8059a"><span class="GINGER_SOFTWARE_mark" id="fd37cbd6-f19b-4c24-abb2-c02ff9fd309b">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Page life expectancy</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Page reads/<span class="GINGER_SOFTWARE_mark" id="9f4ebdaf-dc39-4714-a1a5-5c514a6aeea0"><span class="GINGER_SOFTWARE_mark" id="3847c284-60c3-4ca3-8d76-e380f3a75c1d"><span class="GINGER_SOFTWARE_mark" id="9a30b9dc-d351-4b2f-9108-54064a59fec5"><span class="GINGER_SOFTWARE_mark" id="1d232fa6-f081-4ea7-a318-b1c6f9f8ba44"><span class="GINGER_SOFTWARE_mark" id="084ec1fd-d3b8-4418-9594-0669e15617ac">sec</span></span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Page writes/<span class="GINGER_SOFTWARE_mark" id="0c2caff7-3cc1-492a-bfe4-f7127b9c5007"><span class="GINGER_SOFTWARE_mark" id="029b1be2-b91f-4c5b-b7bd-bf3ed7651ee0"><span class="GINGER_SOFTWARE_mark" id="fdd3271d-2791-46e3-8e2f-c807707d8dc7"><span class="GINGER_SOFTWARE_mark" id="21ab62aa-36eb-40a9-b580-a5a0bbc56c85"><span class="GINGER_SOFTWARE_mark" id="4e8b1577-afd7-4554-b342-f399d1cbaf32">sec</span></span></span></span></span></td>
</tr>
<tr>
<td rowspan="3" valign="top" nowrap="nowrap" width="262">SQL Server<span class="GINGER_SOFTWARE_mark" id="5f53ce5f-751c-446a-bbe3-fa89fcc7eeb0"><span class="GINGER_SOFTWARE_mark" id="0167bc83-89b6-4b40-81aa-91b9497f7d99"><span class="GINGER_SOFTWARE_mark" id="5bb0c5db-cb1d-4144-bb10-9ce808020bd7"><span class="GINGER_SOFTWARE_mark" id="591266bf-fa6d-43ca-80d6-bd8f2f504d90"><span class="GINGER_SOFTWARE_mark" id="25c185d6-d9cb-4dc2-84e6-7c13aa070ca3">:</span></span></span></span></span>Memory Manager</td>
<td valign="top" nowrap="nowrap" width="308">Total Server Memory (KB)</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Target Server Memory (KB)</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Memory Grants Pending</td>
</tr>
<tr>
<td rowspan="4" valign="top" nowrap="nowrap" width="262">SQL Server<span class="GINGER_SOFTWARE_mark" id="f79358dd-af0b-49d3-8fab-60be399953c3"><span class="GINGER_SOFTWARE_mark" id="3f0252f4-1a91-4575-88b6-3f8c42953958"><span class="GINGER_SOFTWARE_mark" id="ac3cc77f-cb23-4db8-a41a-2d8244ff81cf"><span class="GINGER_SOFTWARE_mark" id="5b92726f-a9b6-4dd5-af42-5096a920486d">:</span></span></span></span>Access Methods</td>
<td valign="top" nowrap="nowrap" width="308">Forwarded Records/<span class="GINGER_SOFTWARE_mark" id="e68edd31-7ed4-41b1-b966-466acb89b5e6"><span class="GINGER_SOFTWARE_mark" id="6b295893-2fec-4b55-ae9d-6b8364d1a714"><span class="GINGER_SOFTWARE_mark" id="14756622-c116-44ca-80d6-0089a5f6b678"><span class="GINGER_SOFTWARE_mark" id="867c0edc-7a80-4111-ad5f-057b6ee04b3d">sec</span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Full Scans/<span class="GINGER_SOFTWARE_mark" id="c8422894-de9f-4ad2-8705-ef13cd7f8dbe"><span class="GINGER_SOFTWARE_mark" id="237675a5-8925-43a2-8ec3-e11b70f17ac2"><span class="GINGER_SOFTWARE_mark" id="17502938-7fa6-46dd-83d5-83fc4e5da8fc"><span class="GINGER_SOFTWARE_mark" id="a3eb5213-21fc-4ef7-b4ba-97f9b302f00e">sec</span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Index Searches/<span class="GINGER_SOFTWARE_mark" id="fa903afe-3538-4e91-bf25-e661521d1c67"><span class="GINGER_SOFTWARE_mark" id="97e64af4-c493-4710-a9ef-2fe5b4707bbb"><span class="GINGER_SOFTWARE_mark" id="7da06556-9348-4dd5-a651-cdb71cf6ef8c"><span class="GINGER_SOFTWARE_mark" id="1b6c8049-1018-4c88-9912-08cb6f7d4264">sec</span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Page Splits/<span class="GINGER_SOFTWARE_mark" id="155d72f0-495c-451a-9258-965ec4ba1859"><span class="GINGER_SOFTWARE_mark" id="73082a40-af65-4998-8cbc-16377778ec54"><span class="GINGER_SOFTWARE_mark" id="f4e91de5-ca21-4fdc-80c0-e1581a70901c"><span class="GINGER_SOFTWARE_mark" id="81557fdd-7de9-4846-9418-51734e52b762">sec</span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="262">SQL Server<span class="GINGER_SOFTWARE_mark" id="517d0732-7331-45b2-8ce1-b40bce9bbcfe"><span class="GINGER_SOFTWARE_mark" id="51f82e4f-a771-4ea3-b9c9-96850654bb48"><span class="GINGER_SOFTWARE_mark" id="f9f52b4c-09cb-441f-961d-5e24426e9de7"><span class="GINGER_SOFTWARE_mark" id="e766e3a5-ecbc-41b2-b06b-59e16b205690">:</span></span></span></span>Locks</td>
<td valign="top" nowrap="nowrap" width="308">Number of Deadlocks/<span class="GINGER_SOFTWARE_mark" id="0c307cb6-6f59-4e5f-9ed0-1dbc7eafe0b3"><span class="GINGER_SOFTWARE_mark" id="41bb541e-d82f-40c2-8653-aedc6b4bd703"><span class="GINGER_SOFTWARE_mark" id="fedf36e7-917e-4534-aecc-5e59f8ca3e9e"><span class="GINGER_SOFTWARE_mark" id="2519191f-b756-45ee-8708-e80d3a7d9903">sec</span></span></span></span></td>
</tr>
<tr>
<td rowspan="3" valign="top" nowrap="nowrap" width="262">SQL Server<span class="GINGER_SOFTWARE_mark" id="8438e313-f3a5-4399-9a19-4fcd567caf95"><span class="GINGER_SOFTWARE_mark" id="403aaf5e-c5d5-4288-b973-6b49ac65d927"><span class="GINGER_SOFTWARE_mark" id="aa96b79d-1c38-464d-baab-cdd892825d88"><span class="GINGER_SOFTWARE_mark" id="cad2aa59-5273-468b-ba8e-ed9aeaf32507">:</span></span></span></span>SQL Statistics</td>
<td valign="top" nowrap="nowrap" width="308">Batch Requests / <span class="GINGER_SOFTWARE_mark" id="ab898cd1-113e-4e24-9cad-fd27ba2b3fed"><span class="GINGER_SOFTWARE_mark" id="d5b9b35b-155f-4a79-a12c-1f8a115ad546"><span class="GINGER_SOFTWARE_mark" id="2b83db3a-3165-4c99-89c7-1dbda8fd75e2"><span class="GINGER_SOFTWARE_mark" id="62d46867-8d53-4ae4-82ca-5ebf1638ac95">sec</span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308">Compilations / <span class="GINGER_SOFTWARE_mark" id="7f69b1b8-7e54-4481-addb-d8a8620134c7"><span class="GINGER_SOFTWARE_mark" id="dcbad8f6-8303-4bf0-8492-4c24187af1a3"><span class="GINGER_SOFTWARE_mark" id="37552f62-2c14-44d4-af74-a567ac56e421"><span class="GINGER_SOFTWARE_mark" id="2efe2dc8-514d-430d-915e-27369f8dedbf">sec</span></span></span></span></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap" width="308"><span class="GINGER_SOFTWARE_mark" id="35652568-e389-444d-a440-e6e17694c8e1"><span class="GINGER_SOFTWARE_mark" id="3838835d-99d6-4a66-8b74-5c9d4e8de563"><span class="GINGER_SOFTWARE_mark" id="db9e96a7-8825-4179-a492-7c639af6885b"><span class="GINGER_SOFTWARE_mark" id="5d26c62f-06a0-4fe9-8f22-9dc7f129a503">Recompilations</span></span></span></span> / <span class="GINGER_SOFTWARE_mark" id="c7c80631-c42d-411b-99aa-b2f8b27e4052"><span class="GINGER_SOFTWARE_mark" id="ecae1fd9-e51e-45f0-a8f1-c06f96796ce3"><span class="GINGER_SOFTWARE_mark" id="ed256ff0-969c-4942-ab21-6fd07e5d81bf"><span class="GINGER_SOFTWARE_mark" id="cc0ec4bb-4d2b-4641-a02f-f42df7523bf0">sec</span></span></span></span></td>
</tr>
</tbody>
</table>
<p style="text-align:justify;">You can also build custom collectors for SQL Server-specific items that WMI will not serve. Use your favorite job scheduler to routinely execute queries against system DMOs and store the results into custom tables in a utility database. To get a good idea of the sort of metrics that you can collect, reference some of the many objects in Glenn Berry’s fantastic diagnostic queries, available at <a href="http://sqlserverperformance.wordpress.com/">http://sqlserverperformance.wordpress.com</a>. Items such as disk stall rates, instance and database level CPU, memory, and disk consumption metrics, and background CPU activity can all be sampled with these queries.</p>
<h3 style="text-align:justify;">Now what?</h3>
<p style="text-align:justify;">Now, what do you do with this data that you are collecting? Let’s make some sense of it! Stay tuned until next time when we discuss how to start sifting through the great quantities of data that we are gathering.</p>
<p style="text-align:justify;"><span style="font-size:14px;line-height:1.5;">If you want to get started with performance statistics SQL Servers with the help of experts, read more over at </span><strong style="font-size:14px;line-height:1.5;"><a href="http://blog.sqlauthority.com/fix-your-sql-server/" target="_blank">Fix Your SQL Server</a></strong><span style="font-size:14px;line-height:1.5;">.</span></p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/notes-from-the-field/'>Notes from the Field</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26934/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26934/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26934/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26934/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26934/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26934/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26934/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26934/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26934&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/06/sql-server-performance-statistic-collection-notes-from-the-field-018/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/KleeD.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/performancetuning1.png" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; SQL Report Builder in dbForge Studio for SQL Server</title>
		<link>http://blog.sqlauthority.com/2014/03/05/sql-server-sql-report-builder-in-dbforge-studio-for-sql-server/</link>
		<comments>http://blog.sqlauthority.com/2014/03/05/sql-server-sql-report-builder-in-dbforge-studio-for-sql-server/#comments</comments>
		<pubDate>Wed, 05 Mar 2014 01:30:55 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Devart]]></category>
		<category><![CDATA[SQL Reporting]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26863</guid>
		<description><![CDATA[Modern opportunities of electronic document management systems can significantly simplify the process of decision-making at an enterprise. Along with the opportunities they provide, the traditional printed documentation still plays an important role by allowing to conveniently operate the required information by means of reports. Creation of such reports, depending on the degree of complexity, can [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26863&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">Modern opportunities of electronic document management systems can significantly simplify the process of decision-making at an enterprise.</p>
<p style="text-align:justify;">Along with the opportunities they provide, the traditional printed documentation still plays an important role by allowing to conveniently operate the required information by means of reports.</p>
<p style="text-align:justify;">Creation of such reports, depending on the degree of complexity, can take a long time, therefore, to accelerate their creation, visual editors are traditionally used.</p>
<p style="text-align:justify;">Some of these editors have only basic functionality. Others have extended reporting capabilities. The latter group of products includes the <strong><a href="http://bit.ly/da-reportbuilder" target="_blank">SQL report builder</a></strong> built-in to <a href="http://bit.ly/devart-reports" target="_blank">dbForge Studio for SQL Server</a><strong>.</strong></p>
<p style="text-align:justify;">The editor&#8217;s capabilities allow you to build a report according your SQL query, literally, within a few minutes. For this, it&#8217;s enough to call the Report Designer command from the main menu.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i01.png" /></p>
<p style="text-align:justify;">Select a report type in the opened dialog.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i02.png" /></p>
<p style="text-align:justify;">Select a connection and a data source.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i03.png" /></p>
<p style="text-align:justify;">Herewith, tables and views can be selected as a source.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i04.png" /></p>
<p style="text-align:justify;">In case if data, for example, from several tables should be returned by a query, a user query can be written.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i05.png" /></p>
<p style="text-align:justify;">After selecting a data source, specify the columns, by which the report will be built.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i06.png" /></p>
<p style="text-align:justify;">You should also specify how this data will be presented in the report.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i07.png" /></p>
<p style="text-align:justify;">At the final stage, it <span class="GINGER_SOFTWARE_mark" id="aa39d722-c146-4189-bdb7-71fc7098d704"><span class="GINGER_SOFTWARE_mark" id="9aa6b2db-d939-47ba-8ff7-65fb0d49d6c3"><span class="GINGER_SOFTWARE_mark" id="28db37c1-af4d-4d21-b637-2a89ec54801e"><span class="GINGER_SOFTWARE_mark" id="87a6d33e-60a6-4dac-a8a5-54cb2e4dad65">remains just to</span></span></span></span> specify the name for the report and click the Finish button.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i08.png" /></p>
<p style="text-align:justify;">After the wizard is finished, the report editor opens, in which it is possible to fine-tune the appearance of the report.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i09.png" /></p>
<p style="text-align:justify;">To preview the report, there is the Preview button provided.</p>
<p style="text-align:justify;">After the report is generated, it can be both printed and exported to one of the supported formats.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/devartreport/i10.png" /></p>
<p style="text-align:justify;">As you can see, creating and editing the report in <strong><a href="http://bit.ly/da-reportbuilder" target="_blank">SQL report builder</a></strong> does not take a lot of time, allowing to streamline the process and reduce development time.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank" rel="nofollow">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/sql-utility/'>SQL Utility</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/devart/'>Devart</a>, <a href='http://blog.sqlauthority.com/tag/sql-reporting/'>SQL Reporting</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26863/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26863/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26863/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26863&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/05/sql-server-sql-report-builder-in-dbforge-studio-for-sql-server/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i01.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i02.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i03.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i04.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i05.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i06.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i07.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i08.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i09.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/devartreport/i10.png" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; How to Synchronize Data Across Databases and Servers</title>
		<link>http://blog.sqlauthority.com/2014/03/04/sql-server-how-to-synchronize-data-across-databases-and-servers/</link>
		<comments>http://blog.sqlauthority.com/2014/03/04/sql-server-how-to-synchronize-data-across-databases-and-servers/#comments</comments>
		<pubDate>Tue, 04 Mar 2014 01:30:16 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26908</guid>
		<description><![CDATA[If you are developer you must have faced situations which I am going to mention next. A Developer&#8217;s Wish Have you ever built a database application where you are driving your navigation with the help of Data? Have you ever realized that you are running query much faster on your local server, but when you move them [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26908&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">If you are <span class="GINGER_SOFTWARE_mark" id="9bdba3ff-92d1-4cc1-8a95-9efff29d0ea4">developer</span> you must have faced situations which I am going to mention next.</p>
<h3 style="text-align:justify;">A Developer&#8217;s Wish</h3>
<p style="text-align:justify;">Have you ever built a database application where you are driving your navigation with the help of Data?</p>
<p style="text-align:justify;">Have you ever realized that you are running query much faster on your local server, but when you move them to your test/staging server they are suddenly running slow?</p>
<p style="text-align:justify;">Have you ever wished that you can sync your local machine with the master database so you can run your queries in your near real time scenario so you do not have surprise when you go live on production?</p>
<p style="text-align:justify;">The matter of the fact is that every developer faces such situation when they wish that they can directly work on the live data instead of old historical data on their local machine. If an organization care about the experience of the developer and their product, they will always thrive to provide a tool which makes their developer&#8217;s life very easy.</p>
<h3 style="text-align:justify;">Wish Granted</h3>
<p style="text-align:justify;">If you ask me what is a good tool which can help you to synchronize data across multiple databases and servers, I will suggest you to take a look at the DB Change Manager. It is a very powerful tool which can do quite a number of different tasks. Here are a few of your daily chores which you can rely on DB Change Manager to comply.</p>
<ul style="text-align:justify;">
<li>Schema Archive and Compare</li>
<li>Synchronization and Roll-back</li>
<li>Schema Auto-Synchronization</li>
<li>Data Compare and Synchronization</li>
<li>Data Masking</li>
</ul>
<h3 style="text-align:justify;">Click, Click and Go!</h3>
<p style="text-align:justify;">If you are a developer and given a task to make a tool to synchronize data across two different databases, how difficult it would be creating such a tool. Honestly, very difficult as we need to take care of so many different things besides data, for example &#8211; schema, configuration, security and what not. However, when we are using the <a href="http://bit.ly/emb-dbchm" target="_blank"><b>Embarcadero DB Change Manager</b></a> all the problems are taken care of by the tool.</p>
<p style="text-align:justify;">If you have followed my earlier blog post about <a href="http://blog.sqlauthority.com/2014/01/31/sql-server-synchronize-schema-across-multiple-environment-how-to-overcome-database-migration-challenge/" target="_blank"><b>Synchronize Schema across Multiple Environment – How to Overcome Database Migration Challenge</b></a>. All the steps are very similar to that demonstration. The only difference between Schema Compare and Data Compare is the very first step when we start the job. Here is the image where I demonstrate how we can start the Data Comparison Job.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/dbdatamgr.jpg" width="693" height="562" /></p>
<p style="text-align:justify;">Once you start the Data Comparison Job, it will take you to a very simple wizard with few steps. Each step is extremely easy to follow and most of the time, you just have to accept everything as a default and click on <b>go</b>.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/dbdatamgr1.jpg" width="481" height="67" /></p>
<p style="text-align:justify;">Once you follow the few quick steps of the wizard, you will land upon the final report page where you will notice a grid is placed with details related your change data. You can export the difference or synchronize the data across your server.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/dbdatamgr2.jpg" width="849" height="619" /></p>
<p style="text-align:justify;"><em><strong>That&#8217;s it!</strong></em></p>
<p style="text-align:justify;">I wish I can write more about this entire process, but as I mentioned earlier, this tool is extremely simple to use and follow. Most of the time, I just do Click, Click and Go and I am done!</p>
<p style="text-align:justify;">You can download <a href="http://bit.ly/emb-dbchm" target="_blank"><b>Embarcadero DB Change Manager</b></a> from here. I am eagerly waiting for your feedback about this product.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/sql-utility/'>SQL Utility</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26908/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26908/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26908/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26908/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26908/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26908/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26908/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26908/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26908&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/04/sql-server-how-to-synchronize-data-across-databases-and-servers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/dbdatamgr.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/dbdatamgr1.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/dbdatamgr2.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Images and media file management in SQL Server and MySQL &#8211; Coding Media Management Tools is Never Easy</title>
		<link>http://blog.sqlauthority.com/2014/03/03/sql-server-images-and-media-file-management-in-sql-server-and-mysql-coding-media-management-tools-is-never-easy/</link>
		<comments>http://blog.sqlauthority.com/2014/03/03/sql-server-images-and-media-file-management-in-sql-server-and-mysql-coding-media-management-tools-is-never-easy/#comments</comments>
		<pubDate>Mon, 03 Mar 2014 01:30:17 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26895</guid>
		<description><![CDATA[A core element to both web and mobile app development is rich media management. How you approach the control of images in particular can be tricky. In most cases you have two avenues: You either save it as a database BLOB or simply link to it as a file. Going the BLOB route does have [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26895&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">A core element to both web and mobile app development is rich media management. How you approach the control of images in particular can be tricky. In most cases you have two avenues: You either save it as a database BLOB or simply link to it as a file. Going the BLOB route does have <span class="GINGER_SOFTWARE_mark" id="c199ed77-b3fb-40d4-8227-73b7f6183672">it</span> disadvantages: Saving it as a BLOB in the database inflates it, thereby robbing you of easier access to the media files. You also have to consider that databases are far more expensive than storage, especially when using the resources of the cloud.</p>
<p style="text-align:justify;"><img class="alignleft" alt="" src="http://www.pinaldave.com/bimg/bamedia1.jpg" width="435" height="244" /></p>
<p style="text-align:justify;">That&#8217;s not to say however this approach doesn’t have its advantages: Once stored any media is protected by the database integrity so you don’t find yourself suffering from corrupt or lost files and media. Not to mention all your precious media is protected by the inherent security of the database. That being said most developers I know prefer avoid BLOB&#8217;ing and instead link to the media file location in the database. This brings us naturally to the core concern for Business and Developers: Coding an effective Media Management web tool.</p>
<p style="text-align:justify;">It&#8217;s going to need an upload UI with restrictions on file types and sizes. It will need to save files in either local or cloud storage like Amazon S3 or Azure (and create an authorized download URL if you want the files stored on private storage). The upload should also save the appropriate link in the database for the <span class="GINGER_SOFTWARE_mark" id="599a5965-7880-457d-833d-9424b5b3f930">frontend</span> application as well. You may also need the capability to run additional processing on the uploaded image such as image manipulation or assign it a name or path according to additional information in the row.</p>
<p style="text-align:justify;">Take a simple example: You have an employee with a photo. You want to save each photo with the employee <img class="alignright" alt="" src="http://www.pinaldave.com/bimg/bamedia2.jpg" width="406" height="280" />name and the auto identifier key of the row so that every time an employee the employee uploads his photo it will overwrite his old photo &#8211; but ensure than employees with the same name will not overwrite each other. On top of that, you want to manage your media files with all the other textual content of the frontend app, implement additional business rules much like the photo example and edit and filter the database as well. An effective media <span class="GINGER_SOFTWARE_mark" id="b6af6d0a-5833-47c6-bf77-e35c986185ed">management web</span> tool deployed in a business environment will also require <span class="GINGER_SOFTWARE_mark" id="d03101cb-8b3d-4750-85dd-fd8847701784">robust role security</span> if it’s to be of any use. What initially started out as <span class="GINGER_SOFTWARE_mark" id="c434e0ee-453c-4862-9731-a86ca74d86b4">seemingly simple development task</span> has quite quickly become a complicated, never mind time-consuming and expensive project.</p>
<p style="text-align:justify;"><span style="line-height:1.5em;">Many businesses don’t have the resources to implement an effective web management solution (never mind the needed in-house expertise). It&#8217;s why the </span><span style="line-height:1.5em;"> </span><a style="line-height:1.5em;" href="http://bit.ly/backandsql" target="_blank"><b>Back&amp;</b> platform</a><span style="line-height:1.5em;"> provides a web management for databases including media files. For one </span><span class="GINGER_SOFTWARE_mark" id="592d5cf1-9594-4d67-985c-212bb1801808" style="line-height:1.5em;"><span class="GINGER_SOFTWARE_mark" id="eeb8c4a5-fcb3-49c7-87d3-8d89ea8bd9ee"><span class="GINGER_SOFTWARE_mark" id="82458b5e-7259-4335-866f-367da054081f"><span class="GINGER_SOFTWARE_mark" id="ca80f9fb-8bba-4cb1-b0c3-61cf6ee37bfa"><span class="GINGER_SOFTWARE_mark" id="38bc7896-6dee-4b0b-b53f-c6450408b7d9"><span class="GINGER_SOFTWARE_mark" id="22a01b21-25a9-42b4-80f8-8748de84ebbe"><span class="GINGER_SOFTWARE_mark" id="15b5d9d8-b09b-4789-921c-18539a8f16c1">thing it&#8217;s</span></span></span></span></span></span></span><span style="line-height:1.5em;"> simple: Here&#8217;s a </span><strong style="line-height:1.5em;"><a href="http://bit.ly/backvideos" target="_blank">how-to video</a></strong><span style="line-height:1.5em;"> where set up takes a few clicks.  In addition to managing media files it&#8217;s replete with additional features like smart entry forms that automatically take into consideration the relations and data types, charts reports and dashboards, data driven actions and a ton of other great options that set business up with an instant ready to use web administration for an application database. A service like this is perfect for me compared to when I have to develop an admin tool myself. I have to adjust it each time I/ add a new feature to my <span class="GINGER_SOFTWARE_mark" id="07575ac6-2fd8-49e7-bcd5-f1ca71d41b65">frontend</span> app. With <b>Back&amp;</b> however, changes in the schema are done automatically. Further adjustments like label renaming, <span class="GINGER_SOFTWARE_mark" id="793632ed-e0da-4bcd-9198-7cbae19a9d0b">colour</span> schema, column orders and so much more can be easily adjusted by the user himself. Not only does it save me a ton of development time it gives my users a far better administration tool. Empowering users to <span class="GINGER_SOFTWARE_mark" id="e5c3a799-f943-4577-9392-c5a7bf307b1c">do</span> their work easier and <span class="GINGER_SOFTWARE_mark" id="34f1fd68-2f95-4da3-8f47-19a4e66ca57e">more effectively</span> is after <span class="GINGER_SOFTWARE_mark" id="81322869-4ff1-48b0-9789-47b61c3a684e">all the</span> core concern for developers and businesses alike. </span></p>
<p style="text-align:justify;">Why spend money and time away from front end business concerns developing tools when a feature rich platform like <a href="http://bit.ly/ba-video" target="_blank"><b>Back&amp;</b></a> is just a free click away?</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26895/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26895&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/03/sql-server-images-and-media-file-management-in-sql-server-and-mysql-coding-media-management-tools-is-never-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/bamedia1.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/bamedia2.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Listing Primary Key of Table with Stored Procedure sp_pkeys</title>
		<link>http://blog.sqlauthority.com/2014/03/02/sql-server-listing-primary-key-of-table-with-stored-procedure-sp_pkeys/</link>
		<comments>http://blog.sqlauthority.com/2014/03/02/sql-server-listing-primary-key-of-table-with-stored-procedure-sp_pkeys/#comments</comments>
		<pubDate>Sun, 02 Mar 2014 01:30:29 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Constraint and Keys]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26887</guid>
		<description><![CDATA[Here is a follow up blog post of my earlier blog post on very similar subject Listing Foreign Key Relationships of Table with Stored Procedure sp_fkeys. In previous blog post we listed foreign keys and now we will list the primary key of the table with the help of Stored Procedure sp_fkeys. Here is a quick script how [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26887&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">Here is a follow up blog post <span class="GINGER_SOFTWARE_mark" id="d93d2cf3-c42c-4cbb-82a1-c480060c790a">of</span> my earlier blog post on very similar subject <strong><a href="http://blog.sqlauthority.com/2014/03/01/sql-server-listing-foreign-key-relationships-of-table-with-stored-procedure-sp_fkeys/" target="_blank">Listing Foreign Key Relationships of Table with Stored Procedure sp_fkeys</a></strong>. In previous blog <span class="GINGER_SOFTWARE_mark" id="3978c202-cf70-4b51-a311-8ba08298f1b5">post</span> we listed foreign keys and now we will list the primary key of the table with the help of Stored Procedure sp_fkeys.</p>
<p style="text-align:justify;">Here is a quick script how you can use stored procedure sp_pkeys to list the primary key. This stored procedure takes a minimum of two parameters a) name of the table, b) name of the schema.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks2012</span><span style="color:gray;">;<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">EXEC </span><span style="color:darkred;">sp_pkeys </span><span style="color:#434343;">@table_name </span><span style="color:blue;">= </span><span style="color:red;">N'Employee'</span><span style="color:gray;">,</span><span style="color:gray;"><br />
</span><span style="color:#434343;">@table_owner </span><span style="color:blue;">= </span><span style="color:red;">N'HumanResources'</span><span style="color:gray;">;</span><span style="color:gray;"><br />
</span></code><br />
Here is the output generated from the script listed above:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/sp_pkeys.jpg" /></p>
<p style="text-align:justify;">Here is an alternate way to list the keys as well - <strong><a href="http://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/">Two Methods to Retrieve List of Primary Keys and Foreign Keys of Database</a></strong>.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-constraint-and-keys/'>SQL Constraint and Keys</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26887/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26887/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26887/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26887/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26887/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26887/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26887/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26887/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26887&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/02/sql-server-listing-primary-key-of-table-with-stored-procedure-sp_pkeys/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/sp_pkeys.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Listing Foreign Key Relationships of Table with Stored Procedure sp_fkeys</title>
		<link>http://blog.sqlauthority.com/2014/03/01/sql-server-listing-foreign-key-relationships-of-table-with-stored-procedure-sp_fkeys/</link>
		<comments>http://blog.sqlauthority.com/2014/03/01/sql-server-listing-foreign-key-relationships-of-table-with-stored-procedure-sp_fkeys/#comments</comments>
		<pubDate>Sat, 01 Mar 2014 01:30:54 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Constraint and Keys]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26883</guid>
		<description><![CDATA[A very cool trick which I have previously not shared on my blog regarding how to list all the foreign key relationship of table with the help of Stored Procedure sp_fkeys. Here is a quick script how you can use stored procedure sp_fkeys to list all the foreign key relationship. This stored procedure takes a [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26883&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">A very cool trick which I have previously not shared on my blog regarding how to list all the foreign key relationship of table with the help of Stored Procedure sp_fkeys.</p>
<p style="text-align:justify;">Here is a quick script how you can use stored procedure sp_fkeys to list all the foreign key relationship. This stored procedure takes a minimum of two parameters a) name of the table, b) name of the schema.</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">AdventureWorks2012</span><span style="color:gray;">;<br />
</span><span style="color:black;">GO<br />
</span><span style="color:blue;">EXEC </span><span style="color:darkred;">sp_fkeys </span><span style="color:#434343;">@pktable_name </span><span style="color:blue;">= </span><span style="color:red;">N'Employee'</span><span style="color:gray;">,<br />
</span><span style="color:#434343;">@pktable_owner </span><span style="color:blue;">= </span><span style="color:red;">N'HumanResources'</span><span style="color:gray;">;<br />
</span></code><br />
Here is the output generated from the script listed above:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/sp_fkeys.jpg" width="505" height="328" /></p>
<p style="text-align:justify;">Here is an alternate way to list the keys as well - <strong><a href="http://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/">Two Methods to Retrieve List of Primary Keys and Foreign Keys of Database</a></strong>.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-constraint-and-keys/'>SQL Constraint and Keys</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26883/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26883/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26883/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26883&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/03/01/sql-server-listing-foreign-key-relationships-of-table-with-stored-procedure-sp_fkeys/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/sp_fkeys.jpg" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; 28 Links for Learning SQL Wait Stats from Beginning</title>
		<link>http://blog.sqlauthority.com/2014/02/28/sql-server-28-links-for-learning-sql-wait-stats-from-beginning/</link>
		<comments>http://blog.sqlauthority.com/2014/02/28/sql-server-28-links-for-learning-sql-wait-stats-from-beginning/#comments</comments>
		<pubDate>Fri, 28 Feb 2014 01:30:24 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[Pinal Dave]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Optimization]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Scripts]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Wait Stats]]></category>
		<category><![CDATA[SQL Wait Types]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26878</guid>
		<description><![CDATA[It has been exact two years since I have written series on SQL Wait Statistics and Queues. I often received quite a few questions related to this subject. Here are my answers to the questions. Q: The series which you have written two years ago, is it still relevant to latest SQL Server? A: Yes, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26878&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">It has been <span class="GINGER_SOFTWARE_mark" id="4abc9fa6-8590-4ae2-bfd7-ef5cef724dd3">exact</span> two years since I have written series on SQL Wait Statistics and Queues. I often received quite a few questions related to this subject. Here are my answers to the questions.</p>
<p style="text-align:justify;"><strong>Q:</strong> The series which you have written two years ago, is it still relevant to latest SQL Server?<br />
<strong>A:</strong> Yes, absolutely. Everything which I have written earlier is still relevant to the latest version of SQL Server. The matter of the fact, most of it will remain relevant forever.</p>
<p style="text-align:justify;"><strong>Q:</strong> Is there anyway, I can read everything together in an eBook format?<br />
<strong>A:</strong> Yes, you can get SQL Wait Stats on <a href="http://amzn.to/waitstatskindle" target="_blank">Kindle</a> over here.</p>
<p style="text-align:justify;"><strong>Q:</strong> Is SQL Wait Stats a good logical starting point for SQL Performance Tuning?<br />
<strong>A:</strong> I believe so. It gives you a good idea where exactly your bottleneck is <span class="GINGER_SOFTWARE_mark" id="29bfe029-1345-4799-889c-5a74051e75d0">in</span> your server.</p>
<p style="text-align:justify;"><strong>Q:</strong> I have previously not learned about SQL Wait Stats, can I start now?<br />
<strong>A:</strong> Absolutely, Yes, here are the links:</p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2011/02/01/sql-server-introduction-to-wait-stats-and-wait-types-wait-type-day-1-of-28/" target="_blank">SQL SERVER – Introduction to Wait Stats and Wait Types – Wait Type – Day 1 of 28</a></p>
<p style="text-align:justify;"><a href="http://blog.sqlauthority.com/2011/02/02/sql-server-signal-wait-time-introduction-with-simple-example-day-2-of-28/" target="_blank">SQL SERVER – Signal Wait Time Introduction with Simple Example – Wait Type – Day 2 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – DMV – sys.dm_os_wait_stats Explanation – Wait Type – Day 3 of 28" href="http://blog.sqlauthority.com/2011/02/03/sql-server-dmv-sys-dm_os_wait_stats-explanation-wait-type-day-3-of-28/" rel="bookmark">SQL SERVER – DMV – <span class="GINGER_SOFTWARE_mark" id="52100790-87a6-481c-a0ce-b35eeaf20f8d">sys</span><span class="GINGER_SOFTWARE_mark" id="ce20e177-48a7-41b6-84e8-c8fd998101c7">.</span>dm_os_wait_stats Explanation – Wait Type – Day 3 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – DMV – sys.dm_os_waiting_tasks and sys.dm_exec_requests – Wait Type – Day 4 of 28" href="http://blog.sqlauthority.com/2011/02/04/sql-server-dmv-sys-dm_os_waiting_tasks-and-sys-dm_exec_requests-wait-type-day-4-of-28/" rel="bookmark">SQL SERVER – DMV – <span class="GINGER_SOFTWARE_mark" id="8f66e0ea-88be-4a9a-a878-cf125ed3c788">sys</span><span class="GINGER_SOFTWARE_mark" id="658cc51d-a090-4daa-95c2-b8271148ad57">.</span>dm_os_waiting_tasks and <span class="GINGER_SOFTWARE_mark" id="aac36d1f-4ad6-4e13-aaed-e27f4e7fe010">sys</span><span class="GINGER_SOFTWARE_mark" id="06d2b098-4d2d-4c0e-b333-89d02a9d8672">.</span>dm_exec_requests – Wait Type – Day 4 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Capturing Wait Types and Wait Stats Information at Interval – Wait Type – Day 5 of 28" href="http://blog.sqlauthority.com/2011/02/05/sql-server-capturing-wait-types-and-wait-stats-information-at-interval-wait-type-day-5-of-28/" rel="bookmark">SQL SERVER – Capturing Wait Types and Wait Stats Information at Interval – Wait Type – Day 5 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – CXPACKET – Parallelism – Usual Solution – Wait Type – Day 6 of 28" href="http://blog.sqlauthority.com/2011/02/06/sql-server-cxpacket-parallelism-usual-solution-wait-type-day-6-of-28/" rel="bookmark">SQL SERVER – CXPACKET – Parallelism – Usual Solution – Wait Type – Day 6 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – CXPACKET – Parallelism – Advanced Solution – Wait Type – Day 7 of 28" href="http://blog.sqlauthority.com/2011/02/07/sql-server-cxpacket-parallelism-advanced-solution-wait-type-day-7-of-28/" rel="bookmark">SQL SERVER – CXPACKET – Parallelism – Advanced Solution – Wait Type – Day 7 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – SOS_SCHEDULER_YIELD – Wait Type – Day 8 of 28" href="http://blog.sqlauthority.com/2011/02/08/sql-server-sos_scheduler_yield-wait-type-day-8-of-28/" rel="bookmark">SQL SERVER – SOS_SCHEDULER_YIELD – Wait Type – Day 8 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – PAGEIOLATCH_DT, PAGEIOLATCH_EX, PAGEIOLATCH_KP, PAGEIOLATCH_SH, PAGEIOLATCH_UP – Wait Type – Day 9 of 28" href="http://blog.sqlauthority.com/2011/02/09/sql-server-pageiolatch_dt-pageiolatch_ex-pageiolatch_kp-pageiolatch_sh-pageiolatch_up-wait-type-day-9-of-28/" rel="bookmark">SQL SERVER – PAGEIOLATCH_DT, PAGEIOLATCH_EX, PAGEIOLATCH_KP, PAGEIOLATCH_SH, PAGEIOLATCH_UP – Wait Type – Day 9 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – IO_COMPLETION – Wait Type – Day 10 of 28" href="http://blog.sqlauthority.com/2011/02/10/sql-server-io_completion-wait-type-day-10-of-28/" rel="bookmark">SQL SERVER – IO_COMPLETION – Wait Type – Day 10 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – ASYNC_IO_COMPLETION – Wait Type – Day 11 of 28" href="http://blog.sqlauthority.com/2011/02/11/sql-server-async_io_completion-wait-type-day-11-of-28/" rel="bookmark">SQL SERVER – ASYNC_IO_COMPLETION – Wait Type – Day 11 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – PAGELATCH_DT, PAGELATCH_EX, PAGELATCH_KP, PAGELATCH_SH, PAGELATCH_UP – Wait Type – Day 12 of 28" href="http://blog.sqlauthority.com/2011/02/12/sql-server-pagelatch_dt-pagelatch_ex-pagelatch_kp-pagelatch_sh-pagelatch_up-wait-type-day-12-of-28/" rel="bookmark">SQL SERVER – PAGELATCH_DT, PAGELATCH_EX, PAGELATCH_KP, PAGELATCH_SH, PAGELATCH_UP – Wait Type – Day 12 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – FT_IFTS_SCHEDULER_IDLE_WAIT – Full Text – Wait Type – Day 13 of 28" href="http://blog.sqlauthority.com/2011/02/13/sql-server-ft_ifts_scheduler_idle_wait-full-text-wait-type-day-13-of-28/" rel="bookmark">SQL SERVER – FT_IFTS_SCHEDULER_IDLE_WAIT – Full Text – Wait Type – Day 13 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – BACKUPIO, BACKUPBUFFER – Wait Type – Day 14 of 28" href="http://blog.sqlauthority.com/2011/02/14/sql-server-backupio-backupbuffer-wait-type-day-14-of-28/" rel="bookmark">SQL SERVER – BACKUPIO, BACKUPBUFFER – Wait Type – Day 14 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – LCK_M_XXX – Wait Type – Day 15 of 28" href="http://blog.sqlauthority.com/2011/02/15/sql-server-lck_m_xxx-wait-type-day-15-of-28/" rel="bookmark">SQL SERVER – LCK_M_XXX – Wait Type – Day 15 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Guest Post – Jonathan Kehayias – Wait Type – Day 16 of 28" href="http://blog.sqlauthority.com/2011/02/16/sql-server-guest-post-jonathan-kehayias-wait-type-day-16-of-28/" rel="bookmark">SQL SERVER – Guest Post – Jonathan Kehayias – Wait Type – Day 16 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – WRITELOG – Wait Type – Day 17 of 28" href="http://blog.sqlauthority.com/2011/02/17/sql-server-writelog-wait-type-day-17-of-28/" rel="bookmark">SQL SERVER – WRITELOG – Wait Type – Day 17 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – LOGBUFFER – Wait Type – Day 18 of 28" href="http://blog.sqlauthority.com/2011/02/18/sql-server-logbuffer-wait-type-day-18-of-28/" rel="bookmark">SQL SERVER – LOGBUFFER – Wait Type – Day 18 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – PREEMPTIVE and Non-PREEMPTIVE – Wait Type – Day 19 of 28" href="http://blog.sqlauthority.com/2011/02/19/sql-server-preemptive-and-non-preemptive-wait-type-day-19-of-28/" rel="bookmark">SQL SERVER – PREEMPTIVE and Non-PREEMPTIVE – Wait Type – Day 19 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – MSQL_XP – Wait Type – Day 20 of 28" href="http://blog.sqlauthority.com/2011/02/20/sql-server-msql_xp-wait-type-day-20-of-28/" rel="bookmark">SQL SERVER – MSQL_XP – Wait Type – Day 20 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Guest Posts – Feodor Georgiev – The Context of Our Database Environment – Going Beyond the Internal SQL Server Waits – Wait Type – Day 21 of 28" href="http://blog.sqlauthority.com/2011/02/21/sql-server-the-context-of-our-database-environment-going-beyond-the-internal-sql-server-waits-wait-type-day-21-of-28/" rel="bookmark">SQL SERVER – Guest Posts – Feodor Georgiev – The Context of Our Database Environment – Going Beyond the Internal SQL Server Waits – Wait Type – Day 21 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Guest Post – Jacob Sebastian – Filestream – Wait Types – Wait Queues – Day 22 of 28" href="http://blog.sqlauthority.com/2011/02/22/sql-server-filestream-wait-types-wait-queues-day-22-of-28/" rel="bookmark">SQL SERVER – Guest Post – Jacob Sebastian – Filestream – Wait Types – Wait Queues – Day 22 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – OLEDB – Link Server – Wait Type – Day 23 of 28" href="http://blog.sqlauthority.com/2011/02/23/sql-server-oledb-link-server-wait-type-day-23-of-28/" rel="bookmark">SQL SERVER – OLEDB – Link Server – Wait Type – Day 23 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – 2000 – DBCC SQLPERF(waitstats) – Wait Type – Day 24 of 28" href="http://blog.sqlauthority.com/2011/02/24/sql-server-2000-dbcc-sqlperfwaitstats-wait-type-day-24-of-28/" rel="bookmark">SQL SERVER – 2000 – DBCC SQLPERF<span class="GINGER_SOFTWARE_mark" id="55ef2036-4f8b-4cff-a368-b4f9a2bf2148">(</span><span class="GINGER_SOFTWARE_mark" id="f2067c65-45f8-48eb-846d-84b055f03909">waitstats</span>) – Wait Type – Day 24 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – 2011 – Wait Type – Day 25 of 28" href="http://blog.sqlauthority.com/2011/02/25/sql-server-2011-wait-type-day-25-of-28/" rel="bookmark">SQL SERVER – 2011 – Wait Type – Day 25 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Guest Post – Glenn Berry – Wait Type – Day 26 of 28" href="http://blog.sqlauthority.com/2011/02/26/sql-server-guest-post-glenn-berry-wait-type-day-26-of-28/" rel="bookmark">SQL SERVER – Guest Post – Glenn Berry – Wait Type – Day 26 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Best Reference – Wait Type – Day 27 of 28" href="http://blog.sqlauthority.com/2011/02/27/sql-server-best-reference-wait-type-day-27-of-28/" rel="bookmark">SQL SERVER – Best Reference – Wait Type – Day 27 of 28</a></p>
<p style="text-align:justify;"><a title="Permanent Link to SQL SERVER – Summary of Month – Wait Type – Day 28 of 28" href="http://blog.sqlauthority.com/2011/02/28/sql-server-summary-of-month-wait-type-day-28-of-28/" rel="bookmark">SQL SERVER – Summary <span class="GINGER_SOFTWARE_mark" id="8b70e41c-e770-4e96-bb75-73198a9a4bc7">of</span> Month – Wait Type – Day 28 of 28</a></p>
<p style="text-align:justify;">Reference:<strong> Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.SQLAuthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/pinal-dave/'>Pinal Dave</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-optimization/'>SQL Optimization</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/sql-scripts/'>SQL Scripts</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/sql-wait-stats/'>SQL Wait Stats</a>, <a href='http://blog.sqlauthority.com/category/sql-wait-types/'>SQL Wait Types</a>, <a href='http://blog.sqlauthority.com/category/sqlserver/'>SQLServer</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/'>Technology</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26878/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26878/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26878/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26878/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26878/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26878/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26878/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26878/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26878&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/02/28/sql-server-28-links-for-learning-sql-wait-stats-from-beginning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL SERVER &#8211; Dude, Where is the SQL Agent Job History? &#8211; Notes from the Field #017</title>
		<link>http://blog.sqlauthority.com/2014/02/27/sql-server-dude-where-is-the-sql-agent-job-history-notes-from-the-field-017/</link>
		<comments>http://blog.sqlauthority.com/2014/02/27/sql-server-dude-where-is-the-sql-agent-job-history-notes-from-the-field-017/#comments</comments>
		<pubDate>Thu, 27 Feb 2014 01:30:52 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[Notes from the Field]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Backup and Restore]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26921</guid>
		<description><![CDATA[[Note from Pinal]: Everybody knows what is SQL Agent Jobs. We know that they run at regular interval and does the task assigned. However, there are way many more things we should know about SQL Jobs but do not know it or never learnt to care about it. One of the most essential elements of [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26921&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">[Note from Pinal]: Everybody knows what is SQL Agent Jobs. We know that they run at regular interval and does the task assigned. However, there are way many more things we should know about SQL Jobs but do not know it or never learnt to care about it. One of the most essential elements of SQL Agent Job is history.</p>
<p style="text-align:justify;"><img class="alignleft" style="line-height:1.5;" alt="" src="http://www.pinaldave.com/bimg/JohnSterrett.jpg" /></p>
<p style="text-align:justify;">In this episode of the Notes from the Field series database expert <a href="http://johnsterrett.com/" rel="nofollow"><b>John <span class="GINGER_SOFTWARE_mark" id="29b1a250-9f97-4631-bbd6-f5d6ded69cfc">Sterrett</span></b> </a>(Group Principal at Linchpin People) discusses about SQL Agent Job History in this blog post. Linchpin People are database coaches and wellness experts for a data driven world. Read the experience of John in his own words.</p>
<hr />
<p>In this tip of the week, I want to cover a common problem I see too often in the field. Multiple times I have been asked, <em><strong>“Dude, where is the SQL Agent Job History?”</strong></em> I had a job <span class="GINGER_SOFTWARE_mark" id="8037603d-afb2-41e5-908c-e57bbed9d46e"><span class="GINGER_SOFTWARE_mark" id="a54e6645-7cb9-4b8a-9ac3-02a2979a7f2b"><span class="GINGER_SOFTWARE_mark" id="18155f15-b3fb-4dca-8ab3-f841a5e4aa67"><span class="GINGER_SOFTWARE_mark" id="81ab79cc-4001-4b45-b3cc-d23d40de0a55"><span class="GINGER_SOFTWARE_mark" id="78b6400e-0784-4908-8a79-f5a2b49d15ab">fail but</span></span></span></span></span> I cannot view the history and get details towards why it failed. Today, I am going to cover why the job history is most likely disappearing on you.</p>
<p><span class="GINGER_SOFTWARE_mark" id="b2d573ca-565f-444b-875d-14f55a07da50"><span class="GINGER_SOFTWARE_mark" id="ab30d738-38e8-4178-b3fa-99f26d0ea5b0"><span class="GINGER_SOFTWARE_mark" id="f0f24319-da13-42ce-b805-8f37d58f00d2"><span class="GINGER_SOFTWARE_mark" id="bdebd629-c21c-4791-8c5d-d0e294862760">Typically there</span></span></span></span> are two reasons why your SQL Agent Job History is missing. First, someone or a process is running <a href="http://technet.microsoft.com/en-us/library/ms175044.aspx" rel="nofollow">sp_purge_jobhistory</a> to purge the history. Typically, I find that this isn’t the reason why your history is disappearing randomly.  Normally, it’s the default settings for the SQL Agent Job History that is purging your history. In this week’s tip <span class="GINGER_SOFTWARE_mark" id="95acc0b5-cd9b-419e-83a0-f268651f5dc9"><span class="GINGER_SOFTWARE_mark" id="27544ac9-b12e-4f2e-b6ab-c8622a424986"><span class="GINGER_SOFTWARE_mark" id="6738a9a7-394e-46c8-8ecf-ee610cff641c"><span class="GINGER_SOFTWARE_mark" id="654534b7-7d83-4f65-b57f-d778e123b450"><span class="GINGER_SOFTWARE_mark" id="d372f19e-d3db-43c2-a3de-bf1dad4f6c69">were</span></span></span></span></span> going to focus on the cause and effect of the default <span class="GINGER_SOFTWARE_mark" id="76b3af58-2426-4520-9d28-180469e0268d"><span class="GINGER_SOFTWARE_mark" id="d290eaba-6bb6-48cf-bac6-feb4ae61d6ef"><span class="GINGER_SOFTWARE_mark" id="120fe13c-49bb-4d47-9b32-d59a7ac1a88d"><span class="GINGER_SOFTWARE_mark" id="045b49e9-819d-4ac5-80d6-8633f7195ae3"><span class="GINGER_SOFTWARE_mark" id="a9e16eea-a3a3-45e6-b5d8-767ea74475ab">settings focusing</span></span></span></span></span> on why you might need to change them.</p>
<h3>Setup Demo</h3>
<p>This tip is going to utilize two <a href="http://johnsterrett.com/wp-content/uploads/downloads/2014/02/SQLAgentJobHistory.zip" rel="nofollow">SQL Agent jobs that you need to download</a> if you want to walk through step by step through the demo. The first job is “JobHistoryDemo – Divide by Zero” and the second is “JobHistoryDemo – Batch Process.” In this demo, <span class="GINGER_SOFTWARE_mark" id="6ae29ac3-ecd0-4888-9ea1-b4a0810d902c"><span class="GINGER_SOFTWARE_mark" id="1455d450-5c32-4d81-8c63-81801943d7ce"><span class="GINGER_SOFTWARE_mark" id="bc2b88ce-6763-4d2f-b849-fbbae15d0837"><span class="GINGER_SOFTWARE_mark" id="46b54282-27ca-43a5-874c-9bfaff8dd0df"><span class="GINGER_SOFTWARE_mark" id="171a3fdd-761b-4439-aa9f-519de7a513e9">were</span></span></span></span></span> going to execute a job that will fail (Divide by Zero) and then <span class="GINGER_SOFTWARE_mark" id="74732285-d627-408e-b270-19bdfee74b31"><span class="GINGER_SOFTWARE_mark" id="eb6b6c95-d514-48ad-9df8-66426ca5988f"><span class="GINGER_SOFTWARE_mark" id="872bc15f-fe1e-4cbb-b91d-a378b2b95c42"><span class="GINGER_SOFTWARE_mark" id="6da6d55d-8922-47cc-8e6f-2180ed71e080"><span class="GINGER_SOFTWARE_mark" id="28ed2e17-e67a-42d0-9350-4019b9fbd740">were</span></span></span></span></span> going to execute another job (Batch Process) over a 1,000 times.  For the purpose of this demo, the batch process job just does “SELECT 1” from <span class="GINGER_SOFTWARE_mark" id="990e2dc7-819b-43ea-8fb0-1038bb967d8f"><span class="GINGER_SOFTWARE_mark" id="3dc5ff62-fc3a-4aec-b38f-ed7b220e81b2"><span class="GINGER_SOFTWARE_mark" id="39b85e98-f4cf-433b-a450-dc0c35eb4168"><span class="GINGER_SOFTWARE_mark" id="8ef1b880-277b-4453-883d-a58f4eefe593"><span class="GINGER_SOFTWARE_mark" id="4c9c1ec6-4d16-4642-8513-fc458a0714c2">tempdb</span></span></span></span></span>.</p>
<p>For the purpose of this demo, <span class="GINGER_SOFTWARE_mark" id="fbeb6527-17a5-4f28-bae0-85687fc7e208"><span class="GINGER_SOFTWARE_mark" id="0dd890d5-0a28-4fed-9eab-042e1d8e87a9"><span class="GINGER_SOFTWARE_mark" id="dc428b82-1d22-4afc-b7f7-648a375fcc93"><span class="GINGER_SOFTWARE_mark" id="1d35e022-5134-4367-b926-c8c275319cc2"><span class="GINGER_SOFTWARE_mark" id="d5563baa-921d-4a7f-a257-0d1fafacf2ac">were</span></span></span></span></span> going to tweak the default setting for max rows per job. By default, this is set to 100. We are modifying this to be 1000 so we only need two jobs for the purpose of this demo. We will go into more detail about SQL Agent properties later in this tip.</p>
<p><code style="font-size:12px;"><span style="color:blue;">USE </span><span style="color:black;">[msdb]<br />
GO<br />
</span><span style="color:blue;">EXEC </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="942344f8-de5e-4863-9dd6-8c2fa6fa0715"><span class="GINGER_SOFTWARE_mark" id="be6c5329-f3b7-44d1-856c-84e0bcd51baf"><span class="GINGER_SOFTWARE_mark" id="2fbc618a-975d-4345-9282-dce314e7c0b9"><span class="GINGER_SOFTWARE_mark" id="153b7b76-c7cc-44b5-b1ca-21afa8ca285c">msdb</span></span></span></span><span class="GINGER_SOFTWARE_mark" id="1491c623-25ce-4767-a26f-e2699d50bae3"><span class="GINGER_SOFTWARE_mark" id="af2e1012-c8e2-4fc5-96b7-eaf1519ec389"><span class="GINGER_SOFTWARE_mark" id="6f94d3e9-177a-4d60-98fb-9193e305d4d3"><span class="GINGER_SOFTWARE_mark" id="1e736312-0a67-4851-9f78-bc3933480149">.</span></span></span></span><span class="GINGER_SOFTWARE_mark" id="825eb701-8e1f-4a2c-ac93-56a885e45e0a"><span class="GINGER_SOFTWARE_mark" id="bbfdfca2-4300-493d-94d0-394d5d1dc727"><span class="GINGER_SOFTWARE_mark" id="c530a629-5242-4b42-a6fd-8469fd6bbd21"><span class="GINGER_SOFTWARE_mark" id="5672a7f9-bdee-40b0-94e7-071efd4bf0ba">dbo</span></span></span></span><span class="GINGER_SOFTWARE_mark" id="1d0e982a-1aab-4977-81e8-0a7b6d4eeae0"><span class="GINGER_SOFTWARE_mark" id="cc698a28-cbb7-4328-8cf6-4625389453bf"><span class="GINGER_SOFTWARE_mark" id="a3d24200-5a07-43e5-80bb-af000be3fb0c"><span class="GINGER_SOFTWARE_mark" id="522ec2f9-53be-48b9-b40d-ac52d3310b31">.</span></span></span></span></span><span style="color:darkred;">sp_set_sqlagent_properties </span><span style="color:#434343;">@jobhistory_max_rows_per_job</span><span style="color:blue;">=</span><span style="color:black;">1000<br />
GO<br />
</span></code></p>
<h3>Run Demo Code</h3>
<p>After <a href="http://johnsterrett.com/wp-content/uploads/downloads/2014/02/SQLAgentJobHistory.zip" rel="nofollow">downloading and running the scripts</a> you will have the two new “JobHistoryDemo” SQL Agent Jobs shown below.</p>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/nftf17-1.png" width="293" height="99" /></p>
<p>Run the following <span class="GINGER_SOFTWARE_mark" id="4ebc537a-3222-4804-a850-0cfc22f1842d"><span class="GINGER_SOFTWARE_mark" id="52333924-20c3-4983-bdbe-fd05b3726dfe"><span class="GINGER_SOFTWARE_mark" id="0587ea19-13b9-4cc1-9cf5-6e688be7010e"><span class="GINGER_SOFTWARE_mark" id="5710ab1a-d566-445e-8103-21f0b18bc2cc"><span class="GINGER_SOFTWARE_mark" id="4d474905-8833-4d45-abe5-b942291b536f">script it</span></span></span></span></span> will take about 30 minutes to complete. You will notice that it will start to automatically purge the history for all the SQL Agent jobs. We will dive into why during the next section of the tip.</p>
<p><code style="font-size:12px;"><span style="color:green;">/* Job fails */<br />
</span><span style="color:blue;">EXEC </span><span style="color:darkred;">sp_start_job </span><span style="color:#434343;">@job_name </span><span style="color:blue;">= </span><span style="color:red;">'JobHistoryDemo - Divide by Zero'</span><span style="color:gray;">;<br />
</span><span style="color:blue;">DECLARE </span><span style="color:#434343;">@i </span><span style="color:blue;">INT</span><span style="color:gray;">;<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@i </span><span style="color:blue;">= </span><span style="color:black;">1200</span><span style="color:gray;">; </span><span style="color:green;">-- default history retention for job history records<br />
</span><span style="color:blue;">WHILE </span><span style="color:#434343;">@i </span><span style="color:gray;">&gt; </span><span style="color:black;">0 </span><span style="color:blue;">BEGIN<br />
EXEC </span><span style="color:darkred;">sp_start_job </span><span style="color:#434343;">@job_name </span><span style="color:blue;">=</span><span style="color:red;">'JobHistoryDemo - Batch Process'<br />
</span><span style="color:blue;">WAITFOR </span><span style="color:black;">DELAY </span><span style="color:red;">'00:00:02'</span><span style="color:gray;">;<br />
</span><span style="color:blue;">SET </span><span style="color:#434343;">@i</span><span style="color:blue;">=</span><span style="color:#434343;">@i</span><span style="color:gray;">-</span><span style="color:black;">1<br />
</span><span style="color:blue;">END<br />
</span></code></p>
<p>If you want to monitor the progress you can execute the following script. You will notice that the history gets purged once the “JobHistoryDemo – Divide by Zero” executes 1,000 times.</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="b0aec515-6604-4f8d-bea3-192e77a4981f"><span class="GINGER_SOFTWARE_mark" id="c3d04b27-9379-4a98-91e0-9877a739fd34">j.</span></span>name</span><span style="color:gray;">, </span><span style="color:magenta;">COUNT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="229f5d46-c4bf-4917-957c-ae97b5d074b3"><span class="GINGER_SOFTWARE_mark" id="3c75b877-0b06-4e20-89de-a0039468489d">(</span></span>*) </span><span style="color:black;">Executions<br />
</span><span style="color:blue;">FROM </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="510eed47-fd6f-4ed1-a26e-d758300cb044"><span class="GINGER_SOFTWARE_mark" id="1add5c15-2ece-4eda-9dab-5263fb5b5b6c">msdb</span></span><span class="GINGER_SOFTWARE_mark" id="8d7b9139-80a2-4dba-a8b2-c3af4e4aed03"><span class="GINGER_SOFTWARE_mark" id="3badba35-c1bd-4d4b-8066-38ba51523796">.</span></span><span class="GINGER_SOFTWARE_mark" id="ef8ff983-85b9-4312-81d3-5d0b1d1094a8"><span class="GINGER_SOFTWARE_mark" id="49f2cfce-e654-4b14-ae0e-9904055990bb">dbo</span></span><span class="GINGER_SOFTWARE_mark" id="5ba55bee-027b-424d-bf03-e49a898ceca8"><span class="GINGER_SOFTWARE_mark" id="071efc2a-1716-4de6-b407-2568c9006550">.</span></span><span class="GINGER_SOFTWARE_mark" id="17c02d4f-4b1a-4bc5-b692-17c77872fdce"><span class="GINGER_SOFTWARE_mark" id="039c8cdd-21a7-41aa-9cea-6756ee5de5a3">sysjobs</span></span> j<br />
</span><span style="color:blue;">INNER JOIN </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="dc97209d-793f-4a82-b927-047fd6586d38"><span class="GINGER_SOFTWARE_mark" id="b010e8ef-88f4-4bf0-84fc-5c42a6a4db7c">msdb</span></span><span class="GINGER_SOFTWARE_mark" id="4182eedd-769b-4066-ae8d-9a857edef6b5"><span class="GINGER_SOFTWARE_mark" id="5b86c138-b527-48ac-b3c3-b138bb8f8617">.</span></span><span class="GINGER_SOFTWARE_mark" id="6d60d2eb-0654-4c58-abf3-d4a8cf60c783"><span class="GINGER_SOFTWARE_mark" id="3c295b03-8147-4b6a-b50b-6004686ece9a">dbo</span></span><span class="GINGER_SOFTWARE_mark" id="4f33b58d-e8ad-4415-b407-407c7e0da13a"><span class="GINGER_SOFTWARE_mark" id="2aa70ff3-0ed3-4240-b8ca-112b70bd52e5">.</span></span><span class="GINGER_SOFTWARE_mark" id="c60c49ef-02ca-44f8-9323-b0514ca6784b"><span class="GINGER_SOFTWARE_mark" id="a929da90-bcf8-4959-85e8-c22bb12d50bc">sysjobhistory</span></span> h<br />
</span><span style="color:blue;">ON </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="94f3106c-1bb2-401a-9018-33ca130de790"><span class="GINGER_SOFTWARE_mark" id="5d49c62d-4552-420a-8d36-b12fcf94e28e">j.</span></span>job_id </span><span style="color:blue;">= </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="eeb29caa-82ce-4ef1-a085-cd24c60fe340"><span class="GINGER_SOFTWARE_mark" id="4f4bdd81-e885-41ab-bdd3-1d16e958b38b">h.</span></span>job_id<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;"><span class="GINGER_SOFTWARE_mark" id="6f59afee-f4a7-4180-93f7-577536f470f7"><span class="GINGER_SOFTWARE_mark" id="bdccbfa8-ddc4-498c-a97d-dcf351b36ad8">j.</span></span>name<br />
</span><span style="color:blue;">ORDER BY </span><span style="color:black;">Executions </span><span style="color:blue;">DESC</span></code></p>
<p>Here is a screen shot just right before we hit 1,000 executions.</p>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/nftf17-2.png" width="347" height="161" /></p>
<p>Here is a screen shot just right after we had a 1,000 executions. Notice, that just 1,000 total SQL Agent job executions <span class="GINGER_SOFTWARE_mark" id="1aeb8941-855a-4895-bad0-dd81026257d8"><span class="GINGER_SOFTWARE_mark" id="2ef9a815-2ed8-4b60-a8bf-4eeff60fbbfd"><span class="GINGER_SOFTWARE_mark" id="74e7cff5-7f02-4c8b-b50f-1b3ed1ac5cf0"><span class="GINGER_SOFTWARE_mark" id="a388e85e-a083-45ba-bc29-586da6753e2d">triggers</span></span></span></span> the purging process. It doesn’t have to be limited to just a specific job.</p>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/nftf17-3.png" width="293" height="48" /></p>
<h3>Where did the history go?</h3>
<p>Now we have the scenario described in the first paragraph of this tip. In this scenario, we have a controlled scenario where job history is missing. This can be very frustrating if you have multiple jobs executing frequently as it will seem like the data is being purged randomly.</p>
<p>Let’s take a look at the SQL Agent Job Activity monitor.   We can clearly see that the “JobHistoryDemo – Divide by Zero” job failed. Right click on the job and select view history.</p>
<p><img class="alignnone" style="line-height:1.5em;" alt="" src="http://www.pinaldave.com/bimg/nftf17-4.png" width="625" height="195" /></p>
<p>You will notice all the job history is gone. Next we will show you most likely why you don’t see the job history.</p>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/nftf17-5.png" width="798" height="408" /></p>
<h3>How do we resolve the problem?</h3>
<p>The first step to solving the problem is to identify the root cause. <span class="GINGER_SOFTWARE_mark" id="ede2716c-47f7-4fd4-a7dc-64a5e58c37b0"><span class="GINGER_SOFTWARE_mark" id="70a9f500-d1ab-4f27-911a-3b96d398f591"><span class="GINGER_SOFTWARE_mark" id="260d3b2d-1a3c-49d7-9ac1-2ce458cb7ed5"><span class="GINGER_SOFTWARE_mark" id="828b8849-526e-4ee5-baf5-ee2ecffb0d52">Reading along</span></span></span></span> you might already know why the history is gone. Let’s drill down to the properties of the SQL Agent and focus on the history tab.</p>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/nftf17-6.png" width="328" height="258" /></p>
<p>You will notice that the default setting is to only keep the last 1,000 history records for all the SQL Agent Jobs. The SQL Agent will also only keep 100 history records for a single job. It’s why we modified the Maximum job history rows per job property above for this demo.</p>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/nftf17-7.png" width="683" height="268" /></p>
<p>Now that we have identified a root cause <span class="GINGER_SOFTWARE_mark" id="c3d96636-2b7f-4f83-a53f-06a19cb5be2b"><span class="GINGER_SOFTWARE_mark" id="21e12388-e88a-468c-8639-346db1e77b71"><span class="GINGER_SOFTWARE_mark" id="1682f9a4-bb6a-478b-afbc-c4d4d47dd038"><span class="GINGER_SOFTWARE_mark" id="b0c4321f-19fe-475c-9cf0-5a7c60fd8d25">to</span></span></span></span> this <span class="GINGER_SOFTWARE_mark" id="9281b5af-7162-4577-a305-4f66ffd61c96"><span class="GINGER_SOFTWARE_mark" id="53fd47fd-53de-46eb-a116-5f5ceb0d898a"><span class="GINGER_SOFTWARE_mark" id="1dcb8957-a92a-4c83-8bdf-690cb84bcd68"><span class="GINGER_SOFTWARE_mark" id="f471fb84-247e-4fd2-b4d3-e1e91a97f917">problem here</span></span></span></span> is how you resolve it. Disable the limit size of job history log and utilize sp_purge_jobhistory to purge as needed to meet your storage and business requirements for maintaining agent job history.</p>
<p>Finally, if you need to maintain the results of SQL Agent jobs I recommend using the native functionality built-in to store message details. We will cover this in a future tip.</p>
<p style="text-align:justify;">Are your servers running at optimal speed or are you facing any SQL Server Performance Problems? If you want to get started with the help of experts read more over here: <strong><a href="http://blog.sqlauthority.com/fix-your-sql-server/" target="_blank" rel="nofollow">Fix Your SQL Server</a></strong>.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/notes-from-the-field/'>Notes from the Field</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/sql-backup-and-restore/'>SQL Backup and Restore</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26921/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26921/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26921/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26921/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26921/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26921/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26921/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26921/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26921&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/02/27/sql-server-dude-where-is-the-sql-agent-job-history-notes-from-the-field-017/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/JohnSterrett.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-1.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-2.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-3.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-4.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-5.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-6.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/nftf17-7.png" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Find Anything in Object Explorer in SSMS</title>
		<link>http://blog.sqlauthority.com/2014/02/26/sql-server-find-anything-in-object-explorer-in-ssms/</link>
		<comments>http://blog.sqlauthority.com/2014/02/26/sql-server-find-anything-in-object-explorer-in-ssms/#comments</comments>
		<pubDate>Wed, 26 Feb 2014 01:30:59 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Management Studio]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26917</guid>
		<description><![CDATA[This blog post is a follow up post of an excellent write up by my friend Vinod Kumar. I suggest you read his blog post here SSMS Tips–Object Explorer Details. After reading his blog post, I called him up and had an interesting conversation with him. Here is our conversation: Pinal: It is easy to [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26917&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">This blog post is a follow up post <span class="GINGER_SOFTWARE_mark" id="7cc074b5-b52f-4ca1-9e7d-27ad184b10de"><span class="GINGER_SOFTWARE_mark" id="00cb808d-6a0c-48b2-bf04-0c6469e7300f"><span class="GINGER_SOFTWARE_mark" id="85b43408-6d24-47b6-8324-3617353dc247">of</span></span></span> an excellent write up by my friend <a href="http://blogs.extremeexperts.com/" target="_blank"><strong>Vinod Kumar</strong></a>. I suggest you read his blog post here <strong><a title="Permanent Link to SSMS Tips–Object Explorer Details" href="http://blogs.extremeexperts.com/2014/02/05/ssms-tipsobject-explorer-details/" target="_blank" rel="bookmark">SSMS Tips–Object Explorer Details</a></strong>. After reading his blog post, I called him up and had an interesting conversation with him. Here is our conversation:</p>
<p style="text-align:justify;">Pinal: It is easy to find anything in Object Explorer but it is not possible to find everything in Object Explorer.</p>
<p style="text-align:justify;">Vinod: What do you mean? Explain me with example.</p>
<p style="text-align:justify;">Pinal: For example, if I want to find anything related to any schema or table, I can go to Object Explorer and can search about that schema and find relevant information.<img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/objectsearch1.jpg" width="523" height="232" /></p>
<p style="text-align:justify;">
<p style="text-align:justify;">However, if I want every single object where any string exists, how do I find all of those objects.</p>
<p style="text-align:justify;">Vinod: That is easy <span class="GINGER_SOFTWARE_mark" id="e6edd39b-3a57-475b-81ad-83460971fbb6"><span class="GINGER_SOFTWARE_mark" id="083b3f77-4e22-40ca-b34a-c5042b741ebb"><span class="GINGER_SOFTWARE_mark" id="c6c63aa7-ae9a-4246-89f4-bcb045d5aabe">as well</span></span></span>, remember SQL Server is Microsoft product and will follow the simple rules of the search which you are familiar. Just try to wrap your string with % and see the magic.</p>
<p style="text-align:justify;">Pinal: Never thought of it. Let me try.</p>
<p style="text-align:justify;">After the conversation was over, I tried to wrap my search string with % and it works, indeed it works. SSMS retrieved every single object where the string appeared.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/objectsearch2.jpg" width="521" height="369" /></p>
<p style="text-align:justify;">Thanks Vinod. It is so cool that when we have questions we can reach out to experts.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank" rel="nofollow">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/sql-server-management-studio/'>SQL Server Management Studio</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26917/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26917/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26917/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26917&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/02/26/sql-server-find-anything-in-object-explorer-in-ssms/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/objectsearch1.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/objectsearch2.jpg" medium="image" />
	</item>
		<item>
		<title>MySQL &#8211; Profiler : A Simple and Convenient Tool for Profiling SQL Queries</title>
		<link>http://blog.sqlauthority.com/2014/02/25/mysql-profiler-a-simple-and-convenient-tool-for-profiling-sql-queries/</link>
		<comments>http://blog.sqlauthority.com/2014/02/25/mysql-profiler-a-simple-and-convenient-tool-for-profiling-sql-queries/#comments</comments>
		<pubDate>Tue, 25 Feb 2014 01:30:13 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[SQL Utility]]></category>
		<category><![CDATA[T SQL]]></category>
		<category><![CDATA[Devart]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26849</guid>
		<description><![CDATA[In terms of working with highly loaded databases, any badly-designed request can cause significant performance degradation. Depending on the used DBMS features, various methods are used for query optimization. However, a general rule can be pointed out for all types of DBMS: the fewer server resources are expended when executing a query, the more effective [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26849&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">In terms of working with highly loaded databases, any badly-designed request can cause significant performance degradation. Depending on the used DBMS features, various methods are used for query optimization.</p>
<p style="text-align:justify;">However, a general rule can be pointed out for all types of DBMS: the fewer server resources are expended when executing a query, the more effective will be the query itself.</p>
<p style="text-align:justify;">To detect bottlenecks, MySQL provides the EXPLAIN command. It will help tell you what exactly the database server does, when you execute the query.</p>
<p style="text-align:justify;">To obtain data on executing a query, it is enough to set EXPLAIN before each targeted query. However, putting EXPLAIN for a large number of constructs can become rather tedious.</p>
<p style="text-align:justify;">To simplify search for a problem query let us use <strong><a href="http://bit.ly/mysql-profiler" target="_blank">MySQL Profiler</a></strong> in <span class="GINGER_SOFTWARE_mark" id="c21e0b0f-82d9-4caa-8f38-65f695e3941b">dbForge</span> Studio for MySQL. It provides such commands as <span class="GINGER_SOFTWARE_mark" id="e5e552c7-2b53-465a-951f-b2a9ba865fad"><span class="GINGER_SOFTWARE_mark" id="4540c0ba-db77-47ae-af4f-cb4dfa0a865f"><span class="GINGER_SOFTWARE_mark" id="794cbf48-67e6-436c-b38b-833b8055b303"><span class="GINGER_SOFTWARE_mark" id="56c09457-bb2b-41b9-a9ba-baca34039a71">a Query Profiling Mode</span></span></span></span> and Generate Execution Plan.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/MySQL-Profiler-01.png" width="450" height="111" /></p>
<p style="text-align:justify;">To demonstrate work with execution plan, let&#8217;s consider a small sample. Suppose we need to find vendors of PCs, but not laptops, basing on the following data:</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">models </span><span style="color:gray;">(<br />
</span><span style="color:black;">model_id </span><span style="color:blue;">INT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="f1e38198-1e97-44ed-9e17-786d5dfc3510"><span class="GINGER_SOFTWARE_mark" id="89d4c462-8f09-4455-87b3-c4b6385a3393"><span class="GINGER_SOFTWARE_mark" id="b76908c3-23b8-4866-8c4b-af7dba54657d"><span class="GINGER_SOFTWARE_mark" id="171b0388-4405-403e-ada1-eadaed9638ea"><span class="GINGER_SOFTWARE_mark" id="d0109362-abbe-475a-bcac-2a9e8aeb291c"><span class="GINGER_SOFTWARE_mark" id="be394706-dd20-45a6-bb4d-2e1301549e4e"><span class="GINGER_SOFTWARE_mark" id="cdd5fd0f-3e3c-45a2-b8ca-39e426d4671a"><span class="GINGER_SOFTWARE_mark" id="944d5ab2-52b1-4565-8811-2a1dac3bf1c4"><span class="GINGER_SOFTWARE_mark" id="65665fcf-b9ce-486d-9b11-091e3ac373bd">(</span></span></span></span></span></span></span></span></span></span><span style="color:black;">11</span><span style="color:gray;">) NOT </span><span class="GINGER_SOFTWARE_mark" id="ad38acb8-aa8f-4676-821e-a8839c1b9aaf"><span style="color:gray;">NULL </span><span style="color:blue;">PRIMARY</span><span class="GINGER_SOFTWARE_mark" id="a63f1fce-4105-4dad-a759-db60ded4091e"></span></span><span style="color:blue;"> KEY</span><span style="color:gray;">,<br />
</span><span style="color:black;">model_type </span><span style="color:blue;">VARCHAR</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="00297ea5-f8ea-42dc-aaf3-f551337f7dda"><span class="GINGER_SOFTWARE_mark" id="7e5835b9-dfbc-4038-bb61-de3b3700a2a2"><span class="GINGER_SOFTWARE_mark" id="b89e3b50-e4e8-4841-a050-06224897ec3f"><span class="GINGER_SOFTWARE_mark" id="fe717dd5-b0f4-425d-9a81-8ee160d441e0"><span class="GINGER_SOFTWARE_mark" id="6443e3fa-dc9e-4a0d-8511-9f3776944393"><span class="GINGER_SOFTWARE_mark" id="2f07e023-de03-4d4e-933d-79d894b9538f"><span class="GINGER_SOFTWARE_mark" id="8c0c9935-445e-4ce0-9243-5b4463fbbd45"><span class="GINGER_SOFTWARE_mark" id="0dc56497-92c0-467b-8f69-d9972240689b"><span class="GINGER_SOFTWARE_mark" id="ba3de4bb-0b72-48d5-b927-5c92e604b1e0">(</span></span></span></span></span></span></span></span></span></span><span style="color:black;">10</span><span style="color:gray;">) NOT NULL<br />
) </span><span style="color:black;">ENGINE </span><span style="color:blue;">= </span><span style="color:black;">INNODB</span><span style="color:gray;">;<br />
</span><span style="color:blue;">CREATE TABLE </span><span style="color:black;">products </span><span style="color:gray;">(<br />
</span><span style="color:black;">maker_id </span><span style="color:blue;">INT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="de8eabe1-0b18-4107-88ea-77f4eb809eb4"><span class="GINGER_SOFTWARE_mark" id="a8d0a8bd-d317-4bc7-ba4f-36a2152706f1"><span class="GINGER_SOFTWARE_mark" id="bcf32113-ee20-4304-b059-b124b066b103"><span class="GINGER_SOFTWARE_mark" id="534d3bb6-3cc6-4509-9f42-6d467ada4c76"><span class="GINGER_SOFTWARE_mark" id="caa4a50f-3b68-460c-97da-00babf454a3a"><span class="GINGER_SOFTWARE_mark" id="3b5e4d4b-5156-4f56-b2ec-12d085c36403"><span class="GINGER_SOFTWARE_mark" id="17a906e7-7425-426e-bea5-62add23b7822"><span class="GINGER_SOFTWARE_mark" id="e3f4a5aa-42d3-4cc8-a5a1-3bf7e62ff7d8"><span class="GINGER_SOFTWARE_mark" id="24ef6026-6c46-4edf-9ec1-25e3f32de28f">(</span></span></span></span></span></span></span></span></span></span><span style="color:black;">11</span><span style="color:gray;">) NOT NULL,<br />
</span><span style="color:black;">model_id </span><span style="color:blue;">INT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="ce75c3f9-defd-41cd-9fc5-54e1c6cf48b1"><span class="GINGER_SOFTWARE_mark" id="27d4bfb8-702a-4223-92dd-29c5e4aab514"><span class="GINGER_SOFTWARE_mark" id="2deb9237-9a08-40fa-8756-2a73f8fc0e88"><span class="GINGER_SOFTWARE_mark" id="9cc47e33-84bd-4e22-addc-fd5791351647"><span class="GINGER_SOFTWARE_mark" id="b7d6e5cc-68cd-4801-aaa8-7b29a620155f"><span class="GINGER_SOFTWARE_mark" id="bf598fdc-1a13-4dfb-99ee-424931160c60"><span class="GINGER_SOFTWARE_mark" id="c6d54b39-a4fa-4c5c-9f64-272f2d9acf00"><span class="GINGER_SOFTWARE_mark" id="ec6f0d84-cbe1-4b34-b6b6-42685bed336e"><span class="GINGER_SOFTWARE_mark" id="030c24c9-abe5-4584-96cd-6d57fdc09b05">(</span></span></span></span></span></span></span></span></span></span><span style="color:black;">11</span><span style="color:gray;">) NOT NULL,<br />
</span><span style="color:blue;">PRIMARY KEY </span><span style="color:gray;">(</span><span style="color:black;">maker_id</span><span style="color:gray;">, </span><span style="color:black;">model_id</span><span style="color:gray;">),<br />
</span><span style="color:blue;">CONSTRAINT </span><span style="color:black;">FK_products_models_model_id<br />
</span><span style="color:blue;">FOREIGN KEY </span><span style="color:gray;">(</span><span style="color:black;">model_id</span><span style="color:gray;">)<br />
</span><span style="color:blue;">REFERENCES </span><span style="color:black;">models </span><span style="color:gray;">(</span><span style="color:black;">model_id</span><span style="color:gray;">)<br />
</span><span style="color:blue;">ON DELETE CASCADE ON UPDATE CASCADE<br />
</span><span style="color:gray;">) </span><span style="color:black;">ENGINE </span><span style="color:blue;">= </span><span style="color:black;">INNODB</span><span style="color:gray;">;<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">models</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="bfd29e6f-31a7-4f9b-9dea-7b3bcbfffbfb"><span class="GINGER_SOFTWARE_mark" id="ed1bdeee-aca2-4f1d-9823-b53d16a90e01"><span class="GINGER_SOFTWARE_mark" id="8ba4bbd1-f47f-45c7-9cf6-db002246e065"><span class="GINGER_SOFTWARE_mark" id="2f9ce312-caae-49df-9108-636b0f31f1cd"><span class="GINGER_SOFTWARE_mark" id="1b0368e5-401a-4ac4-84c2-b5b1e7840897"><span class="GINGER_SOFTWARE_mark" id="76c08a31-d6c6-4f8a-bc94-977e987dc6c1"><span class="GINGER_SOFTWARE_mark" id="fd564678-5fa8-4179-9ea9-e69c7324c2f7"><span class="GINGER_SOFTWARE_mark" id="f037aa4e-2c54-48d7-a62c-0c645488b286"><span class="GINGER_SOFTWARE_mark" id="e4f5da68-efb2-48e3-b6c0-444718aa58dd">(</span></span></span></span></span></span></span></span></span></span><span style="color:black;">model_id</span><span style="color:gray;">, </span><span style="color:black;">model_type</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES<br />
</span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">'PC'</span><span style="color:gray;">), (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">'Laptop'</span><span style="color:gray;">), (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">'Tablet'</span><span style="color:gray;">),<br />
(</span><span style="color:black;">4</span><span style="color:gray;">, </span><span style="color:red;">'Phone'</span><span style="color:gray;">), (</span><span style="color:black;">5</span><span style="color:gray;">, </span><span style="color:red;">'PC'</span><span style="color:gray;">), (</span><span style="color:black;">6</span><span style="color:gray;">, </span><span style="color:red;">'Laptop'</span><span style="color:gray;">);<br />
</span><span style="color:blue;">INSERT INTO </span><span style="color:black;">products</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="17b4c19b-eac8-4160-8202-0b28f787c8e0"><span class="GINGER_SOFTWARE_mark" id="1a5a6abb-8f90-458f-8f33-a57b1e991111"><span class="GINGER_SOFTWARE_mark" id="3085c8cb-5c5b-4300-87f8-3a7a78780fb2"><span class="GINGER_SOFTWARE_mark" id="0b7c4026-1cba-4a09-afc9-f9f6dd3519bd"><span class="GINGER_SOFTWARE_mark" id="f2623b7e-da94-4467-98df-ebe92d06738c"><span class="GINGER_SOFTWARE_mark" id="142dae2d-37d3-4533-810a-c388086fff20"><span class="GINGER_SOFTWARE_mark" id="ecd3dbad-ba66-46b4-80e0-be7c2195f382"><span class="GINGER_SOFTWARE_mark" id="a54a2a0e-22e2-4ec8-afb1-d9542b66a4d3"><span class="GINGER_SOFTWARE_mark" id="2033845d-49fb-43a0-a8b8-c7ddb4881d5c">(</span></span></span></span></span></span></span></span></span></span><span style="color:black;">maker_id</span><span style="color:gray;">, </span><span style="color:black;">model_id</span><span style="color:gray;">)<br />
</span><span style="color:blue;">VALUES<br />
</span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">1</span><span style="color:gray;">), (</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">2</span><span style="color:gray;">), (</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:black;">3</span><span style="color:gray;">), (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:black;">4</span><span style="color:gray;">),<br />
(</span><span style="color:black;">4</span><span style="color:gray;">, </span><span style="color:black;">4</span><span style="color:gray;">), (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:black;">5</span><span style="color:gray;">), (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:black;">5</span><span style="color:gray;">), (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:black;">6</span><span style="color:gray;">);<br />
</span></code></p>
<p style="text-align:justify;">This task can be solved quite trivial:</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT DISTINCT </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="cecb90ad-a57d-47be-a907-0e84f72343ab"><span class="GINGER_SOFTWARE_mark" id="dbcae39d-0fc7-4a26-8701-e9e927daadb3"><span class="GINGER_SOFTWARE_mark" id="007c63aa-0f0a-41c1-9d3f-b66ed3387aa0"><span class="GINGER_SOFTWARE_mark" id="ddc34b21-8baf-41e5-96f6-aecc5f53a7e2"><span class="GINGER_SOFTWARE_mark" id="d8fd1721-48f4-451c-8f5d-ea9b882c77e9"><span class="GINGER_SOFTWARE_mark" id="53ce199b-6bc9-4e84-a859-738d8e25175d"><span class="GINGER_SOFTWARE_mark" id="143cdfac-0a92-4309-9636-6c17dddb3623"><span class="GINGER_SOFTWARE_mark" id="98b42da4-252d-46d2-89a1-3834d1b2737a">.</span></span></span></span></span></span></span></span>maker_id<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">products </span><span class="GINGER_SOFTWARE_mark" id="cca0cc15-4347-429f-8247-cb0b719a23b8"><span style="color:blue;">AS </span><span style="color:black;">p</span><span class="GINGER_SOFTWARE_mark" id="3977f636-f0c8-4c2d-b39a-929272c755c4"></span><span class="GINGER_SOFTWARE_mark" id="1759fe59-8741-4e2f-b833-9ed8149b3f6f"></span></span><span style="color:black;"><br />
</span><span style="color:blue;">JOIN </span><span style="color:black;">models m </span><span style="color:blue;">ON </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="d9df045e-178b-4645-8724-9cb7c08f1a53"><span class="GINGER_SOFTWARE_mark" id="eb276225-b973-4521-a93d-6180b54c175e"><span class="GINGER_SOFTWARE_mark" id="5c8e0651-db38-4105-8776-5ea8ca64adc8"><span class="GINGER_SOFTWARE_mark" id="d7559aaf-2e65-4d46-9dca-7c8fef1e1996"><span class="GINGER_SOFTWARE_mark" id="918110a9-9a06-400b-b003-a2c97b6c604e"><span class="GINGER_SOFTWARE_mark" id="11381f56-ff08-44cc-8969-f6d8c285b967"><span class="GINGER_SOFTWARE_mark" id="69a2038a-1d6e-4558-8030-89b9f5885078">.</span></span></span></span></span></span></span>model_id </span><span style="color:blue;">= </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="761fbe88-9b6c-46f3-8e0a-e01b9b14ccff"><span class="GINGER_SOFTWARE_mark" id="e5b45085-baf3-4fb1-a973-6b9bd1149141"><span class="GINGER_SOFTWARE_mark" id="ddb258ef-dc32-4560-a4d9-c322589abf6f"><span class="GINGER_SOFTWARE_mark" id="14b44bbc-ec4e-46b5-947b-adad0c9ff197"><span class="GINGER_SOFTWARE_mark" id="be7996ac-6925-4d12-a187-2efb53bb74f0"><span class="GINGER_SOFTWARE_mark" id="b7214ba9-44bb-46d8-94c5-e28f5a0da446"><span class="GINGER_SOFTWARE_mark" id="98eb67f2-293b-47ee-bf98-39a4b5c024e8">.</span></span></span></span></span></span></span>model_id<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="04d7a5c6-a04c-4a17-b11d-6eaafadd2942"><span class="GINGER_SOFTWARE_mark" id="3ea46dce-39d2-43a7-880c-6c2c3aee4de6"><span class="GINGER_SOFTWARE_mark" id="b7830f67-53f7-4069-9211-9c203fe71eb5"><span class="GINGER_SOFTWARE_mark" id="305111a7-45cb-4cc9-beb9-0bda6585a39c"><span class="GINGER_SOFTWARE_mark" id="bf3967c0-83ca-430e-9302-1d9f6c3f9070"><span class="GINGER_SOFTWARE_mark" id="ff1369fa-fcf1-44cb-8239-fa8ed418ba6a"><span class="GINGER_SOFTWARE_mark" id="5fe0f50f-cf85-4df1-a47c-8f1ed4b1d1dc"><span class="GINGER_SOFTWARE_mark" id="fe0f5203-586d-4f29-9e26-42b469ec75b7">.</span></span></span></span></span></span></span></span>model_type </span><span style="color:blue;">= </span><span style="color:red;">'PC'<br />
</span><span style="color:gray;">AND NOT EXISTS (<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">p2<span class="GINGER_SOFTWARE_mark" id="aed3ec6d-de21-4e56-ae71-d73a1ce45298"><span class="GINGER_SOFTWARE_mark" id="ab5a17d8-6c4e-46bd-9e4c-b811d53e5957"><span class="GINGER_SOFTWARE_mark" id="1fbb58a9-541e-4d7c-9eba-a4cb2daddefa"><span class="GINGER_SOFTWARE_mark" id="d2449dd7-d4a7-4ea7-8300-26326ee29139"><span class="GINGER_SOFTWARE_mark" id="2aed6db8-8cbc-49e4-b69a-40eb62285707"><span class="GINGER_SOFTWARE_mark" id="cc492f45-3053-4b79-b3d4-0ad07d331cf2"><span class="GINGER_SOFTWARE_mark" id="ee3da952-2985-4add-85d9-f891607f4e7f">.</span></span></span></span></span></span></span>maker_id<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">products </span><span style="color:blue;">AS </span><span style="color:black;">p2<br />
</span><span style="color:blue;">JOIN </span><span style="color:black;">models m2 </span><span style="color:blue;">ON </span><span style="color:black;">p2<span class="GINGER_SOFTWARE_mark" id="a13a9209-e901-42a1-ae17-613562cda50c"><span class="GINGER_SOFTWARE_mark" id="e2558ea6-9e56-4147-94c8-526663facf8d"><span class="GINGER_SOFTWARE_mark" id="3e69227b-89ed-49cf-ab2e-43062a253197"><span class="GINGER_SOFTWARE_mark" id="ab3e9736-129c-457b-a941-65b0fce60350"><span class="GINGER_SOFTWARE_mark" id="593045f4-76cc-472c-a6cd-7670c12597fd"><span class="GINGER_SOFTWARE_mark" id="0a99a601-1fd1-4386-88b0-e60fc24f654d"><span class="GINGER_SOFTWARE_mark" id="05ef6f8e-8350-4210-9ec5-ea69deb89a45">.</span></span></span></span></span></span></span>model_id </span><span style="color:blue;">= </span><span style="color:black;">m2<span class="GINGER_SOFTWARE_mark" id="61bab8c4-5f4b-4efe-8724-46f4a698a42b"><span class="GINGER_SOFTWARE_mark" id="846355c0-a954-46fc-9430-0c08a50f1298"><span class="GINGER_SOFTWARE_mark" id="3ca6cf23-9b98-407d-85fa-2c926934442b"><span class="GINGER_SOFTWARE_mark" id="d270e812-5327-4b9b-857b-25606bb52b33"><span class="GINGER_SOFTWARE_mark" id="a7f7bdeb-ca00-449d-8bb9-639600c84e5d"><span class="GINGER_SOFTWARE_mark" id="f0482600-e143-40b4-91e3-360a107d409c"><span class="GINGER_SOFTWARE_mark" id="1db01fc0-962b-4462-aed9-4d3a1892f9af">.</span></span></span></span></span></span></span>model_id<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">m2<span class="GINGER_SOFTWARE_mark" id="d538ad19-49c5-4365-ad4c-1a6b6ef7846e"><span class="GINGER_SOFTWARE_mark" id="0d40e088-ea13-48a1-a1e0-bb47121dccf6"><span class="GINGER_SOFTWARE_mark" id="7f1eb9f6-14be-4295-8ef5-910762420ad8"><span class="GINGER_SOFTWARE_mark" id="a4173665-6a2a-43e1-91a1-c1f056b844e0"><span class="GINGER_SOFTWARE_mark" id="2c724a62-149f-4859-94a1-4d56a864efed"><span class="GINGER_SOFTWARE_mark" id="8562a599-eb04-48cd-bd61-7190dd57aad5"><span class="GINGER_SOFTWARE_mark" id="a967e4fe-c0bd-48f6-a15c-685d0ef01ee8">.</span></span></span></span></span></span></span>model_type </span><span style="color:blue;">= </span><span style="color:red;">'Laptop'<br />
</span><span style="color:gray;">AND </span><span style="color:black;">p2<span class="GINGER_SOFTWARE_mark" id="3a08e568-8ea1-4487-bf9d-12c619c59a3a"><span class="GINGER_SOFTWARE_mark" id="e242546d-de0b-4b82-b31c-35d87711f554"><span class="GINGER_SOFTWARE_mark" id="fd78641d-b18f-482b-82ec-79e925eb80f6"><span class="GINGER_SOFTWARE_mark" id="07d30143-a999-40be-9bf0-de9099af9a15"><span class="GINGER_SOFTWARE_mark" id="d8f1a88e-468e-4170-a0d3-1ce23753b51d"><span class="GINGER_SOFTWARE_mark" id="bd5cf793-8a81-4ef2-aae2-e0b40389ff94"><span class="GINGER_SOFTWARE_mark" id="46cf118d-ac31-447c-be8c-f53d208369a6">.</span></span></span></span></span></span></span>maker_id </span><span style="color:blue;">= </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="72a31e42-b6e1-45ec-9fa8-8ed5a807ad15"><span class="GINGER_SOFTWARE_mark" id="20264ac2-9176-4b0c-9318-fee50e91f885"><span class="GINGER_SOFTWARE_mark" id="ebb9d47e-4490-47fd-aed9-fc41a10df2a4"><span class="GINGER_SOFTWARE_mark" id="32c54c9c-6b35-40ff-8d2f-3b256c9ca215"><span class="GINGER_SOFTWARE_mark" id="ab7eb743-952b-4031-92cf-dc9339a689a8"><span class="GINGER_SOFTWARE_mark" id="9b0b2e9c-9632-4ce2-8127-5c1626ffc73f"><span class="GINGER_SOFTWARE_mark" id="c1760689-f52f-4426-88fe-15973b2e565e">.</span></span></span></span></span></span></span>maker_id<br />
</span><span style="color:gray;">);<br />
</span></code></p>
<p style="text-align:justify;">When designing a query, one always  ought to pay attention to re-readings from the same tables, since they bear an additional load on the database server disk subsystem:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/MySQL-Profiler-02.png" width="704" height="158" /></p>
<p style="text-align:justify;">The query can be rewritten with no re-readings, using <span class="GINGER_SOFTWARE_mark" id="c6e7dee2-751a-4156-80f8-f6c16174e285"><span class="GINGER_SOFTWARE_mark" id="1ef6e42b-1c26-43c8-a161-21ffb0fa5ad7"><span class="GINGER_SOFTWARE_mark" id="db195c30-feac-4020-83a0-133f919cd578"><span class="GINGER_SOFTWARE_mark" id="328a9103-256d-467c-9216-61ba1543b130"><span class="GINGER_SOFTWARE_mark" id="affaf5a2-66cf-451c-8b71-c3dc8a5e9fe8"><span class="GINGER_SOFTWARE_mark" id="20bbd73f-d2f0-45a6-a2e8-0ff0605c7009"><span class="GINGER_SOFTWARE_mark" id="24dd8f2c-2cb9-4ddc-b1c5-07130356efcb"><span class="GINGER_SOFTWARE_mark" id="3e7f3a8f-96bf-4fb0-ab8e-f561b513e291"><span class="GINGER_SOFTWARE_mark" id="1a53efe3-aee6-4121-8c5d-7988e0bb4669"><span class="GINGER_SOFTWARE_mark" id="06ebd07a-ff8c-4eb7-b777-70174f337313">aggregating</span></span></span></span></span></span></span></span></span></span> functions:</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="094bc886-ce46-45e6-8996-c2b6e61b7af5"><span class="GINGER_SOFTWARE_mark" id="3dc9a3d8-81ba-482a-b576-44c7d9476e63"><span class="GINGER_SOFTWARE_mark" id="7c1239ea-eaee-4b9a-903b-16ca182686ea"><span class="GINGER_SOFTWARE_mark" id="61354aba-530b-43d4-97dd-c5078a02ab3e"><span class="GINGER_SOFTWARE_mark" id="4b854508-4bc4-4c50-b6fc-8f7a738854f3"><span class="GINGER_SOFTWARE_mark" id="8fdb3264-1d30-404b-89da-79163ada37c6"><span class="GINGER_SOFTWARE_mark" id="5d48befc-8654-4332-aafd-61e8615a2eff">.</span></span></span></span></span></span></span>maker_id<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">products </span><span class="GINGER_SOFTWARE_mark" id="30c50eaf-146c-4082-8761-699f86b64ae9"><span style="color:blue;">AS </span><span style="color:black;">p</span><span class="GINGER_SOFTWARE_mark" id="6213e9e1-0830-46d2-a6d6-caad0329fb39"></span><span class="GINGER_SOFTWARE_mark" id="aa72464f-6ce3-4114-8af9-d374dc3dad71"></span></span><span style="color:black;"><br />
</span><span style="color:blue;">JOIN </span><span style="color:black;">models </span><span style="color:blue;">AS </span><span style="color:black;">m </span><span style="color:blue;">ON </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="766730be-cf86-41a0-9e30-19e0113b351f"><span class="GINGER_SOFTWARE_mark" id="6cac370c-6792-45b6-9ebe-1b285bbf6c5c"><span class="GINGER_SOFTWARE_mark" id="e6afa7fc-f9e8-4a34-b300-1ac3cf276b3b"><span class="GINGER_SOFTWARE_mark" id="622ef06e-a40d-485e-916f-4aa40716d910"><span class="GINGER_SOFTWARE_mark" id="8bfaadd3-fef7-438b-8221-23b73975aad7"><span class="GINGER_SOFTWARE_mark" id="5b64b1de-72d8-44a2-9db0-02207bef47d3"><span class="GINGER_SOFTWARE_mark" id="fdd2fe21-2b4b-43d9-b2f7-cae5ffa6e0a0">.</span></span></span></span></span></span></span>model_id </span><span style="color:blue;">= </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="9c9565e0-5e1d-43df-974d-728b39ce037f"><span class="GINGER_SOFTWARE_mark" id="010c27e6-5f11-4877-ba5b-ba689c9e44a7"><span class="GINGER_SOFTWARE_mark" id="db5ed521-0fd6-4453-9472-01f737407457"><span class="GINGER_SOFTWARE_mark" id="36664bf5-c78a-44a5-9588-7c42c853e112"><span class="GINGER_SOFTWARE_mark" id="daf9f407-7cc5-4cfe-82bc-a000b1427865"><span class="GINGER_SOFTWARE_mark" id="d88e2e6d-8f9e-4fb1-ac43-4a66105a7a3f"><span class="GINGER_SOFTWARE_mark" id="37c63b4e-0de5-41b8-890f-12263ed6f4b6">.</span></span></span></span></span></span></span>model_id<br />
</span><span style="color:blue;">WHERE </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="6902ea04-a973-4523-a63e-de1147d725d6"><span class="GINGER_SOFTWARE_mark" id="3b706fd0-c4ca-48f4-88c1-ecba8bcfe075"><span class="GINGER_SOFTWARE_mark" id="d44baff4-18c1-4597-ae95-483383626394"><span class="GINGER_SOFTWARE_mark" id="8fd4701b-a0ba-48c8-bf64-4474a812a97b"><span class="GINGER_SOFTWARE_mark" id="66c2289d-08d7-486b-bef0-07c246c9f8e8"><span class="GINGER_SOFTWARE_mark" id="5cd06955-a03a-495a-a992-259e1272a8c5"><span class="GINGER_SOFTWARE_mark" id="f3e41b01-a455-4fde-8350-dac1df51dfc3">.</span></span></span></span></span></span></span>model_type </span><span style="color:blue;">IN </span><span style="color:gray;">(</span><span style="color:red;">'PC'</span><span style="color:gray;">, </span><span style="color:red;">'Laptop'</span><span style="color:gray;">)<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="a725c43a-aa47-4672-82f2-71401931d30f"><span class="GINGER_SOFTWARE_mark" id="313e67c1-f5da-48c1-9bf3-1ff7aceba383"><span class="GINGER_SOFTWARE_mark" id="ec893b11-01e4-45e0-ac65-44f6a5850347"><span class="GINGER_SOFTWARE_mark" id="01454ad6-22c2-44bb-b0e7-3d5e76bb7d9b"><span class="GINGER_SOFTWARE_mark" id="4b4c326c-f50e-4dae-9be1-4f9c17490740"><span class="GINGER_SOFTWARE_mark" id="6907ad04-8197-4d2f-8891-4f4f167e9d33"><span class="GINGER_SOFTWARE_mark" id="07ac21bb-f463-46f6-9966-f8d6987f01e3">.</span></span></span></span></span></span></span>maker_id<br />
</span><span style="color:blue;">HAVING </span><span style="color:magenta;">COUNT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="aee021ad-c20a-4422-aa21-1a2a0b0a4ec0"><span class="GINGER_SOFTWARE_mark" id="035c49e5-7bc2-4064-8a2f-14d96e2af9f1"><span class="GINGER_SOFTWARE_mark" id="5c37af05-e899-41ca-9547-331832e70cd3"><span class="GINGER_SOFTWARE_mark" id="8b2321c9-eca3-4651-89dc-9855e3b87f8d"><span class="GINGER_SOFTWARE_mark" id="aa3f72f5-403a-4f3a-ab73-b36ba2dd665d"><span class="GINGER_SOFTWARE_mark" id="e0a28bf2-131b-4693-9fa6-d803fac68191"><span class="GINGER_SOFTWARE_mark" id="dbe9dab5-2d60-44ba-bc73-29e3be28a70e">(</span></span></span></span></span></span></span></span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="99ac8088-746e-41d4-96a6-e1590aefcdab"><span class="GINGER_SOFTWARE_mark" id="6591426d-9799-4530-8fc5-72db550cbce1"><span class="GINGER_SOFTWARE_mark" id="4c4d3a97-cd28-499b-995f-5fd6428ebddf"><span class="GINGER_SOFTWARE_mark" id="c138edec-9459-46fc-8b58-67aea8bfdfa7"><span class="GINGER_SOFTWARE_mark" id="39173147-28e0-4a02-b87f-e9c4eee6a7ad"><span class="GINGER_SOFTWARE_mark" id="fe89f848-1e87-4181-9fa4-49ff4b972133"><span class="GINGER_SOFTWARE_mark" id="b47db753-891f-447f-aaf5-9fc5f23d4de6">.</span></span></span></span></span></span></span>model_type </span><span style="color:blue;">= </span><span style="color:red;">'PC' </span><span style="color:blue;">THEN </span><span style="color:black;">1 </span><span style="color:blue;">END</span><span style="color:gray;">) &gt; </span><span style="color:black;">0<br />
</span><span style="color:gray;">AND </span><span style="color:magenta;">COUNT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="162557c0-126d-461b-a31f-46ba9906a4ad"><span class="GINGER_SOFTWARE_mark" id="b1faf685-ea23-49db-8cb2-96d89dac4d82"><span class="GINGER_SOFTWARE_mark" id="7075bb2e-67b9-46bd-a29b-891aeaf0a104"><span class="GINGER_SOFTWARE_mark" id="22e75c18-a87a-4862-81cc-5acc2f56a9ec"><span class="GINGER_SOFTWARE_mark" id="afa2cfb5-73e6-4969-9c95-2ae4b3cdbd46"><span class="GINGER_SOFTWARE_mark" id="b5376ec3-3ee7-4bc0-b1ac-af6495e62a5a"><span class="GINGER_SOFTWARE_mark" id="b640ceb9-df7d-44a9-8b8c-ec7b25dc363e">(</span></span></span></span></span></span></span></span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="0b231fc1-a705-44de-892c-4a70a42d48c8"><span class="GINGER_SOFTWARE_mark" id="2c3caeb5-b533-4637-a2e6-0febe5a00538"><span class="GINGER_SOFTWARE_mark" id="ed439071-2992-4340-8193-be3ecb05ff4a"><span class="GINGER_SOFTWARE_mark" id="7319f31a-89ce-4abb-9b06-7cfd0cf0723e"><span class="GINGER_SOFTWARE_mark" id="6914bcb2-d519-47c1-b90e-e08ac71ce626"><span class="GINGER_SOFTWARE_mark" id="6968c71a-5134-4b94-89f4-48b5c2d53000"><span class="GINGER_SOFTWARE_mark" id="a04f36b4-6169-4877-8371-5440a0e0ca4b">.</span></span></span></span></span></span></span>model_type </span><span style="color:blue;">= </span><span style="color:red;">'Laptop' </span><span style="color:blue;">THEN </span><span style="color:black;">1 </span><span style="color:blue;">END</span><span style="color:gray;">) </span><span style="color:blue;">= </span><span style="color:black;">0</span><span style="color:gray;">;<br />
</span></code></p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/MySQL-Profiler-03.png" width="706" height="185" /></p>
<p style="text-align:justify;">However, having a large number of records, JOIN to the <span class="GINGER_SOFTWARE_mark" id="3d79ed6a-c54a-46de-be85-3b9ed334f968"><span class="GINGER_SOFTWARE_mark" id="5f137067-29d6-4288-866d-b4d956d26417"><span class="GINGER_SOFTWARE_mark" id="6a5d7e90-7757-43a4-94ba-52685a1263c4"><span class="GINGER_SOFTWARE_mark" id="00d89a16-916d-4554-99c2-7504613815d5"><span class="GINGER_SOFTWARE_mark" id="80634e8e-f389-4a17-9f10-1c592765c70a"><span class="GINGER_SOFTWARE_mark" id="42614b7b-55ff-4be2-98fa-d3fa09fbdeaf"><span class="GINGER_SOFTWARE_mark" id="0f7f8d26-0ab9-4207-ad7e-15c4a2da75be"><span class="GINGER_SOFTWARE_mark" id="b7fa0bfd-4286-4dab-a069-d3219a7e3898"><span class="GINGER_SOFTWARE_mark" id="234b9847-1003-48db-80de-3d37fd61e3f8"><span class="GINGER_SOFTWARE_mark" id="401aac49-5a2c-4d85-8e05-8e5ee2be913f">models</span></span></span></span></span></span></span></span></span></span> table can still affect performance.</p>
<p style="text-align:justify;">To speed up the query, <span class="GINGER_SOFTWARE_mark" id="00587d5d-b5a2-4da6-afa0-796b77296bb7"><span class="GINGER_SOFTWARE_mark" id="63e98a9f-4d06-4214-aee6-72f04c3d1c26"><span class="GINGER_SOFTWARE_mark" id="47bf7280-0abb-4965-85f7-d711ed4d128c"><span class="GINGER_SOFTWARE_mark" id="dc621568-3e10-479e-908d-fa6bd601ceb2"><span class="GINGER_SOFTWARE_mark" id="daffa8c1-370d-4645-8957-40b50558f820"><span class="GINGER_SOFTWARE_mark" id="dfa411bd-5e76-41bf-9be9-e68e497833f6"><span class="GINGER_SOFTWARE_mark" id="0e1cbf7e-00e4-4cad-b9a5-8ef194f89367"><span class="GINGER_SOFTWARE_mark" id="7d86073f-0fe6-4491-ab52-15334d2ae689"><span class="GINGER_SOFTWARE_mark" id="86e70fb1-9bb2-43b5-be1a-d15763d534fb">denormalization</span></span></span></span></span></span></span></span></span> of the scheme can be performed by duplicating data from the model_type column of the products table:</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">UPDATE </span><span style="color:black;">products </span><span class="GINGER_SOFTWARE_mark" id="d86077e9-e18a-405a-a41e-9d256639dfe3"><span style="color:blue;">AS </span><span style="color:black;">p</span><span class="GINGER_SOFTWARE_mark" id="06fde75f-c96d-4176-9f80-7525e1211495"></span></span><span style="color:black;"><br />
</span><span style="color:blue;">JOIN </span><span style="color:black;">models </span><span style="color:blue;">AS </span><span style="color:black;">m </span><span style="color:blue;">ON </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="aa1e057e-63d0-436a-af22-9259ff8a80bf"><span class="GINGER_SOFTWARE_mark" id="053c89f3-055f-4888-802c-1c392d6bf437"><span class="GINGER_SOFTWARE_mark" id="a8e02dcd-fe67-475d-84ad-7e7d0a4f7c7b"><span class="GINGER_SOFTWARE_mark" id="f0e4d5b4-93b7-4a52-a5ce-338e6507c302"><span class="GINGER_SOFTWARE_mark" id="3b6ebd3c-d002-4a00-8c09-948e716a4400"><span class="GINGER_SOFTWARE_mark" id="b49a9d79-ab22-41fe-b094-c383b47605a6"><span class="GINGER_SOFTWARE_mark" id="b31ad119-fb9d-4a94-b8c7-fcef9033d428">.</span></span></span></span></span></span></span>model_id </span><span style="color:blue;">= </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="9fa20335-bdd9-47c6-abc9-15401b24fcaf"><span class="GINGER_SOFTWARE_mark" id="69e54739-291c-4364-ae1b-5d9e85a0912e"><span class="GINGER_SOFTWARE_mark" id="b0d0d542-d5be-4087-a843-5f30f6fb106b"><span class="GINGER_SOFTWARE_mark" id="25cc363e-13a9-493c-8ae8-fac024fb779f"><span class="GINGER_SOFTWARE_mark" id="15cfa267-74ef-47b4-8609-2b569100b13d"><span class="GINGER_SOFTWARE_mark" id="90e2afe3-234a-4ab1-a842-2ad30cc790b9"><span class="GINGER_SOFTWARE_mark" id="4f06c1de-33a8-47a9-9193-de4ec1030075">.</span></span></span></span></span></span></span>model_id<br />
</span><span style="color:blue;">SET </span><span style="color:black;">p<span class="GINGER_SOFTWARE_mark" id="30e78616-1484-44b4-b63b-e6a26b36ed75"><span class="GINGER_SOFTWARE_mark" id="0c69d6ff-dad4-4979-b341-7555e380d513"><span class="GINGER_SOFTWARE_mark" id="7e4f0b0f-ae55-4534-bd1e-beb3aaf02c76"><span class="GINGER_SOFTWARE_mark" id="ecb5c3de-f552-44a5-80b4-d33de800fbf9"><span class="GINGER_SOFTWARE_mark" id="35b55ec8-ffe0-4943-b472-436b97875cd2"><span class="GINGER_SOFTWARE_mark" id="a6941374-ce7d-405a-b4a2-832457ee2e36"><span class="GINGER_SOFTWARE_mark" id="0e955ff5-668b-4318-a95e-2ffbe68798a9">.</span></span></span></span></span></span></span>model_type </span><span style="color:blue;">= </span><span style="color:black;">m<span class="GINGER_SOFTWARE_mark" id="71f0b058-f5c6-48cf-b1c8-11059b3833e8"><span class="GINGER_SOFTWARE_mark" id="bd7e5580-80bd-4515-9391-a19efa4d29c4"><span class="GINGER_SOFTWARE_mark" id="b9119d9c-5ac3-4292-8a37-391c22b62236"><span class="GINGER_SOFTWARE_mark" id="ebd2d6ea-f555-43f8-a00c-c2efe2fad227"><span class="GINGER_SOFTWARE_mark" id="2577d4ad-794f-4992-aa7d-6f9db7f6e0ca"><span class="GINGER_SOFTWARE_mark" id="1c4cc329-f852-44a8-acd8-2b397c1d9c85"><span class="GINGER_SOFTWARE_mark" id="038667b9-c216-4fea-aa7e-aba099ce3b3e">.</span></span></span></span></span></span></span>model_type</span><span style="color:gray;">;<br />
</span></code></p>
<p style="text-align:justify;">Also, pay attention to the fact that the model_type column is filtered by, so it is recommended to index it.</p>
<p style="text-align:justify;">At that,  <span class="GINGER_SOFTWARE_mark" id="08af3330-931a-4e41-ba76-0c7e96ea7670"><span class="GINGER_SOFTWARE_mark" id="e8cd7e79-62b9-45d1-bb53-ef5987036be4"><span class="GINGER_SOFTWARE_mark" id="299f26c2-ff4d-4566-9839-eaf64602d5f5"><span class="GINGER_SOFTWARE_mark" id="81fdffe3-9b66-4e59-9a04-a53e4ae8f23f"><span class="GINGER_SOFTWARE_mark" id="b70d1752-5748-4b14-b0b2-5988cd088521"><span class="GINGER_SOFTWARE_mark" id="e2304fd2-ade1-491a-8c70-c690eb5c26b8"><span class="GINGER_SOFTWARE_mark" id="ed9cec42-52d0-44f1-afa3-d169a145bdf9"><span class="GINGER_SOFTWARE_mark" id="4f175b72-d64c-4758-a3d5-be8cd7d3b48a"><span class="GINGER_SOFTWARE_mark" id="2ef97ea4-7735-45c0-8fea-6db58301cc3e"><span class="GINGER_SOFTWARE_mark" id="c5907271-db9e-4fde-9d78-6a31ceef29f9">selection</span></span></span></span></span></span></span></span></span></span> of columns, that will be included <span class="GINGER_SOFTWARE_mark" id="77d4a4ec-5391-418e-bf2e-799188a11cbe"><span class="GINGER_SOFTWARE_mark" id="efe462bb-e58e-4c1f-8237-812f38c003e4"><span class="GINGER_SOFTWARE_mark" id="1022ed02-1e54-4004-b82d-8bcf941263bb"><span class="GINGER_SOFTWARE_mark" id="8dbe2ccb-8d6e-47fb-ab83-30260c626712"><span class="GINGER_SOFTWARE_mark" id="791445ee-9426-478f-89f8-950352f13598"><span class="GINGER_SOFTWARE_mark" id="31b2916a-56da-4981-85e1-bcbb705124d0"><span class="GINGER_SOFTWARE_mark" id="01b0df21-94af-4eee-8eec-a2eaa79d9bb3"><span class="GINGER_SOFTWARE_mark" id="3754d41e-3358-4d8b-89ca-2318462f620c"><span class="GINGER_SOFTWARE_mark" id="eae871b0-5ccb-4696-a892-1613e570b7a7"><span class="GINGER_SOFTWARE_mark" id="e022e482-2791-43f6-8f4b-87e5b9264cc5">to</span></span></span></span></span></span></span></span></span></span> the primary key,  should be approached carefully. Since columns <span class="GINGER_SOFTWARE_mark" id="4424af75-cdce-4b16-82bf-dca9660c1036"><span class="GINGER_SOFTWARE_mark" id="3db3fe83-eff5-45d5-b6c6-7f8defb026ad"><span class="GINGER_SOFTWARE_mark" id="ee2c6282-8c5c-4cee-8056-c7b35adb07f7"><span class="GINGER_SOFTWARE_mark" id="7f56edb4-1346-49b8-9e5d-69415000af35"><span class="GINGER_SOFTWARE_mark" id="0e536513-421c-45ae-953d-4f4883c18c4a"><span class="GINGER_SOFTWARE_mark" id="b5ecb522-bc12-439f-bff0-c03aa6e6b1d0"><span class="GINGER_SOFTWARE_mark" id="36debf65-e7fb-4c65-bca1-34e495ada5f2"><span class="GINGER_SOFTWARE_mark" id="41c705bd-3966-4f4d-8fc4-21af67e0d5a8"><span class="GINGER_SOFTWARE_mark" id="04fa5047-184e-455a-b4db-a1fdbda42151"><span class="GINGER_SOFTWARE_mark" id="cc70bec4-13e2-4f9f-9f49-9f61a58d1f31">from</span></span></span></span></span></span></span></span></span></span> the primary key are included <span class="GINGER_SOFTWARE_mark" id="bf5f56ee-43a7-445f-8beb-d373bed89363"><span class="GINGER_SOFTWARE_mark" id="b57725f7-03a2-4182-9a82-c7738af171d0"><span class="GINGER_SOFTWARE_mark" id="d523f817-7636-4310-af68-30aac3aafdfa"><span class="GINGER_SOFTWARE_mark" id="bd8c1f56-e385-4852-9a47-402c88e1ae1a"><span class="GINGER_SOFTWARE_mark" id="c9778b4e-9dee-49be-88a7-017ce79c27ac"><span class="GINGER_SOFTWARE_mark" id="52ece303-acda-47de-86a8-5ea179d2c194"><span class="GINGER_SOFTWARE_mark" id="ca4284c9-d33a-4f14-9ba7-4ea1ba403b4d"><span class="GINGER_SOFTWARE_mark" id="d0d0d4c5-d437-4100-a78e-5d0eb6fff176"><span class="GINGER_SOFTWARE_mark" id="de9e857c-bbe8-421d-b184-61a2f7616d0d"><span class="GINGER_SOFTWARE_mark" id="c7a026af-9da1-444d-9cc3-4a9b45fe4016">to</span></span></span></span></span></span></span></span></span></span> the <span class="GINGER_SOFTWARE_mark" id="fa44ccf9-1a88-4291-9dc2-165d1f394774"><span class="GINGER_SOFTWARE_mark" id="75688086-a4a4-4d2d-9186-8e32838beaaa"><span class="GINGER_SOFTWARE_mark" id="6f8cf6b9-fe4c-438d-ae5b-3038b1712612"><span class="GINGER_SOFTWARE_mark" id="78e14336-fcee-4851-8f01-db8a24e38d6b"><span class="GINGER_SOFTWARE_mark" id="83941e0e-3929-4bb4-a279-28cef59929f4"><span class="GINGER_SOFTWARE_mark" id="94c89fc9-a609-4cee-b7a9-b3b2a64e94bb"><span class="GINGER_SOFTWARE_mark" id="555dfbe9-7c7b-4e8a-a35c-2256f1edd705"><span class="GINGER_SOFTWARE_mark" id="52e14bb7-6688-4834-b293-6808cddae0d3"><span class="GINGER_SOFTWARE_mark" id="f19d8212-a38a-4c05-b51d-b69c91527bd3"><span class="GINGER_SOFTWARE_mark" id="2bccd067-ee7e-4333-a011-75a18578f599">nonclustered</span></span></span></span></span></span></span></span></span></span> index, this can increase database size.</p>
<p style="text-align:justify;">As a result, selection is significantly simplified:</p>
<p style="text-align:justify;"><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">maker_id<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">products<br />
</span><span style="color:blue;">GROUP BY </span><span style="color:black;">maker_id<br />
</span><span style="color:blue;">HAVING </span><span style="color:magenta;">COUNT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="db95ee49-fc4f-4601-8768-00b3bc081364"><span class="GINGER_SOFTWARE_mark" id="ff0a57f6-c0c3-416d-ba7d-290d6ee03454"><span class="GINGER_SOFTWARE_mark" id="6d92604c-81c8-42c6-a524-d99ba8d03103"><span class="GINGER_SOFTWARE_mark" id="ba5d04d2-7ffd-43b9-8700-28aaecb317ae"><span class="GINGER_SOFTWARE_mark" id="38b0ea98-5ec5-40a1-9aea-e9cebbfcea57"><span class="GINGER_SOFTWARE_mark" id="d5edcb94-aa57-4af8-a5be-5861b89c4951"><span class="GINGER_SOFTWARE_mark" id="57a10d24-daae-4448-b723-2f894ecf8912">(</span></span></span></span></span></span></span></span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">model_type </span><span style="color:blue;">= </span><span style="color:red;">'PC' </span><span style="color:blue;">THEN </span><span style="color:black;">1 </span><span style="color:blue;">END</span><span style="color:gray;">) &gt; </span><span style="color:black;">0<br />
</span><span style="color:gray;">AND </span><span style="color:magenta;">COUNT</span><span style="color:gray;"><span class="GINGER_SOFTWARE_mark" id="ebec730e-2458-4601-af6d-4b5b6bd80dd6"><span class="GINGER_SOFTWARE_mark" id="ac44aa61-32d7-404b-b50e-00c862f126a1"><span class="GINGER_SOFTWARE_mark" id="71df38cd-ca4a-4522-8ad9-c0ccf1b930a9"><span class="GINGER_SOFTWARE_mark" id="00ad2734-25e2-4eff-ba0c-04db2a59d82c"><span class="GINGER_SOFTWARE_mark" id="10b8ce73-8c13-4cd0-a43e-23058e66da6b"><span class="GINGER_SOFTWARE_mark" id="fa71a727-ec17-4582-af2d-bbdaf9d13677"><span class="GINGER_SOFTWARE_mark" id="09117681-6576-4277-a207-a0f6d32c0043">(</span></span></span></span></span></span></span></span><span style="color:magenta;">CASE </span><span style="color:blue;">WHEN </span><span style="color:black;">model_type </span><span style="color:blue;">= </span><span style="color:red;">'Laptop' </span><span style="color:blue;">THEN </span><span style="color:black;">1 </span><span style="color:blue;">END</span><span style="color:gray;">) </span><span style="color:blue;">= </span><span style="color:black;">0</span><span style="color:gray;">;<br />
</span></code></p>
<p style="text-align:justify;">At this, the plan becomes simple at all:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/MySQL-Profiler-04.png" width="641" height="122" /></p>
<p style="text-align:justify;">However, the root of performance problems should not always be searched for in queries – it is very important to correctly configure database server settings. For this, the Server Variables tab can be used.</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/MySQL-Profiler-05.png" width="598" height="373" /></p>
<p style="text-align:justify;">In this case, all the settings, for convenience, can be grouped according to their target facilities:</p>
<p style="text-align:justify;"><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/MySQL-Profiler-06.png" width="513" height="610" /></p>
<p style="text-align:justify;">There is no perfect advice how to optimize a query.  However, using the <span class="GINGER_SOFTWARE_mark" id="de80b435-354e-445e-9a2f-9b6369ae3244"><span class="GINGER_SOFTWARE_mark" id="66d2f294-6dca-4222-9ee0-8c21e606ccba"><span class="GINGER_SOFTWARE_mark" id="ca0e40f6-4e79-4e46-ba29-05bc5161c022"><span class="GINGER_SOFTWARE_mark" id="a62ad7ce-eb89-466f-9144-f98c7eb6bd05"><span class="GINGER_SOFTWARE_mark" id="b9fd9ae2-4f23-4588-96b4-97b842622104"><span class="GINGER_SOFTWARE_mark" id="b8c0abc8-8066-4e37-ba27-2b2a028e1bca"><span class="GINGER_SOFTWARE_mark" id="f2aa0bab-d952-41c6-9cc7-966f74135c15"><span class="GINGER_SOFTWARE_mark" id="7b21ca33-8add-407f-88ee-3249b694c89e"><span class="GINGER_SOFTWARE_mark" id="3d9dd9c1-b40b-4ec6-a71a-46f613a457db">profiler</span></span></span></span></span></span></span></span></span> embedded into <strong><a href="http://bit.ly/mysql-gui" target="_blank">dbForge Studio for MySQL</a>,</strong> there is a probability to detect all the performance bottlenecks.</p>
<p style="text-align:justify;">Optimal settings for MySQL server can also vary depending on the specificity of <span class="GINGER_SOFTWARE_mark" id="38140fa1-a11d-41d1-b0c0-27ed347983f0"><span class="GINGER_SOFTWARE_mark" id="718eb635-3261-4979-99f6-284481db76ff"><span class="GINGER_SOFTWARE_mark" id="608ab05a-83da-4eac-8f93-ac334afdf350"><span class="GINGER_SOFTWARE_mark" id="8cae342e-2078-4b3a-b514-b4dc77b89e85"><span class="GINGER_SOFTWARE_mark" id="389fe9e3-223a-45c3-a0fe-f7d37de79f50"><span class="GINGER_SOFTWARE_mark" id="caab22a3-4811-4cf8-ad33-c7491d7cb594"><span class="GINGER_SOFTWARE_mark" id="d84058fe-abcb-41cf-98c7-2692fd7fdf7c"><span class="GINGER_SOFTWARE_mark" id="b9dc702f-895a-439d-b9ff-720508322449">performed</span></span></span></span></span></span></span></span> tasks. <span class="GINGER_SOFTWARE_mark" id="07206fd0-ace4-4caf-820a-181d83a27e6d"><span class="GINGER_SOFTWARE_mark" id="16e35ebb-0f9b-4ca3-91f8-76989dfd39d7"><span class="GINGER_SOFTWARE_mark" id="66a3c39f-3c32-4ed9-abaf-f6cf397d0707"><span class="GINGER_SOFTWARE_mark" id="f83a0678-12f1-4439-982c-7882c4001735"><span class="GINGER_SOFTWARE_mark" id="d2f04143-3bdf-4862-8928-cae0d50c7445">Therefore, detailed</span></span></span></span></span> consideration of the server configuration process will be revealed in a separate article.</p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank" rel="nofollow">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/mysql-technology/'>MySQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/sql-utility/'>SQL Utility</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a> Tagged: <a href='http://blog.sqlauthority.com/tag/devart/'>Devart</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26849/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26849/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26849/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26849/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26849/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26849/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26849/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26849/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26849&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/02/25/mysql-profiler-a-simple-and-convenient-tool-for-profiling-sql-queries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/MySQL-Profiler-01.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/MySQL-Profiler-02.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/MySQL-Profiler-03.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/MySQL-Profiler-04.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/MySQL-Profiler-05.png" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/MySQL-Profiler-06.png" medium="image" />
	</item>
		<item>
		<title>SQL SERVER &#8211; Contest Post &#8211; Notes from the Field &#8211; Learning Performance Tuning and Database Health</title>
		<link>http://blog.sqlauthority.com/2014/02/24/sql-server-contest-post-notes-from-the-field-learning-performance-tuning-and-database-health/</link>
		<comments>http://blog.sqlauthority.com/2014/02/24/sql-server-contest-post-notes-from-the-field-learning-performance-tuning-and-database-health/#comments</comments>
		<pubDate>Mon, 24 Feb 2014 01:30:44 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[Notes from the Field]]></category>
		<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26841</guid>
		<description><![CDATA[One of the most appreciated and loved the series on SQLAuthority.com is Notes from the Field. I often received how did I come up with the idea behind it. Here is the story for the same. Inceptions of Notes from the Field There are two aspects of any technology 1) Theoretical Knowledge and 2) Practical [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26841&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">One of the most appreciated and loved the series on SQLAuthority.com is Notes from the Field. I often received how did I come up with the idea behind it. Here is the story <span class="GINGER_SOFTWARE_mark" id="9fca9a4f-c06f-4fed-b9d4-b719ad66989a"><span class="GINGER_SOFTWARE_mark" id="25cf48ee-6be8-4408-a643-5d0c81ced3d8"><span class="GINGER_SOFTWARE_mark" id="6172d167-6abb-437a-9fe3-7a1e085aef0c"><span class="GINGER_SOFTWARE_mark" id="0969adab-0cc6-41a9-b506-2023a6843f47"><span class="GINGER_SOFTWARE_mark" id="696c73dc-0786-4e75-9d88-0e7cf19546ee">for</span></span></span></span></span> the same.</p>
<h3 style="text-align:justify;">Inceptions of Notes from the Field</h3>
<p><img class="alignnone" alt="" src="http://www.pinaldave.com/bimg/notesfromfield.jpg" width="940" height="128" /></p>
<p style="text-align:justify;">There are two aspects of any technology 1) Theoretical Knowledge and 2) Practical Knowledge. I have been blogging over 7 years over here and over the years, I have shared my theoretical and practical knowledge over here on this blog. However, I am primarily contributor to my blog and hence there was a monotonous tone <span class="GINGER_SOFTWARE_mark" id="acff575a-2b38-4efa-9ad5-3b39ac923b05"><span class="GINGER_SOFTWARE_mark" id="7b9d1367-549d-428a-8a46-62c6486f87ff"><span class="GINGER_SOFTWARE_mark" id="5ba4c0e7-9c43-4d82-b85e-f6d1248a04c2"><span class="GINGER_SOFTWARE_mark" id="123b9488-7428-4995-814e-4e4b8c0439f0"><span class="GINGER_SOFTWARE_mark" id="935efafb-6538-4700-9bcf-4cd721524f47">to</span></span></span></span></span> this blog. I always wanted to bring the perspective of other Database Experts to the blog readers. In the real world, we have thousands of the servers deployed, and each server has its own stories to tell. When I have worked on performance tuning projects, I have realized that it is not possible to figure out everything by a single expert. When we have more than one opinion for any server, it helps us to figure out what is the best possible solution for that server. Following the same logic, I have decided to reach out to <span class="GINGER_SOFTWARE_mark" id="c11cd49a-6303-48fc-9921-10673cd5ec5f"><span class="GINGER_SOFTWARE_mark" id="d80e81f5-9b71-48e5-abe8-f00b840e9edd"><span class="GINGER_SOFTWARE_mark" id="abdacbdd-073b-430b-8fa1-8aea8302a1f7"><span class="GINGER_SOFTWARE_mark" id="4cbf29ed-046c-4754-8a8c-fb2d1faebbaf"><span class="GINGER_SOFTWARE_mark" id="33601ef3-e44c-4f89-9875-f105fd205097">few</span></span></span></span></span> of my fellow industry experts to help me write a series <span class="GINGER_SOFTWARE_mark" id="3b973327-6313-46da-a864-41951b3ad04d"><span class="GINGER_SOFTWARE_mark" id="6945f434-f7e6-4f34-af50-7e9fd8bd30b9"><span class="GINGER_SOFTWARE_mark" id="fa156b6d-2fa9-4440-8678-1f662571d559"><span class="GINGER_SOFTWARE_mark" id="67d473e2-1a3e-45f9-b981-16dc4fb2bb1c"><span class="GINGER_SOFTWARE_mark" id="4121f21e-99e9-4a63-92ea-bf86cdcc2100">Notes</span></span></span></span></span> from the Field.</p>
<h3 style="text-align:justify;">Contest</h3>
<p style="text-align:justify;">Here are details of quick contest. We have so far published 16 different episodes of Notes from the Field. We believe each of them are extremely valuable and have lots of interesting information from the real world. We personally cannot decide which one is better than another, as they all are exceptional posts. With said that when we check the statistics of each of the blog post, we see different interest level for each of them. We decided to have a quick contest for all of you, which will help us to come up with better notes from the field.</p>
<p style="text-align:justify;">Answer following question in the comments &#8211; <em><strong>What would you like to learn next in the Notes from the Field series? </strong></em></p>
<p style="text-align:justify;">One lucky winner will get <span style="color:#ff0000;"><strong>USD 50 Amazon gift card</strong></span>. We will select lucky winner based on the random algorithm.</p>
<h3 style="text-align:justify;"><img class="alignleft" style="font-size:14px;line-height:1.5em;" alt="" src="http://www.pinaldave.com/bimg/doctor-cartoon.gif" width="300" /></h3>
<h3 style="text-align:justify;">Roundup from Notes from the Field</h3>
<p style="text-align:justify;">My friends at <strong><a href="http://www.linchpinpeople.com/" target="_blank" rel="nofollow">Linchpin People</a></strong> are expert at Anything and Everything about SQL. You can reach out to them when you need an urgent care specialist for your database. If you believe your servers are healthy, that is a great thing, but it does not hurt to read the advice of the experts in their own words.</p>
<p style="text-align:justify;">Here is the roundup from Notes from the Field. Each of the <span class="GINGER_SOFTWARE_mark" id="259c4a8c-e725-4f91-87de-da0d62f13e98"><span class="GINGER_SOFTWARE_mark" id="0f3fce31-fd20-4043-abf6-3c8b54595f00"><span class="GINGER_SOFTWARE_mark" id="71eab9aa-eb22-4c46-8918-27ece9546b97"><span class="GINGER_SOFTWARE_mark" id="0219202f-9c57-4f02-a83d-1dbc0f0347d0">note</span></span></span></span> is shared by experts at Linchpin People.</p>
<ul>
<li><strong><a href="http://blog.sqlauthority.com/2013/11/07/sql-server-transaction-log-full-transaction-log-larger-than-data-file-notes-from-fields-001/">Transaction Log Full – Transaction Log Larger than Data File – Notes from the Field #001</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/11/14/sql-server-root-cause-to-performance-problems-notes-from-the-field-002/">Root Cause to Performance Problems – Notes from the Field #002</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/11/21/sql-server-vcpus-how-many-are-too-many-cpu-for-sql-server-virtualization-notes-from-the-field-003/"><span class="GINGER_SOFTWARE_mark" id="1e796464-9240-4f4b-b5dd-9bb55accf7ef"><span class="GINGER_SOFTWARE_mark" id="1c8880eb-862c-4a7d-9a08-b0d767093967"><span class="GINGER_SOFTWARE_mark" id="d16761cd-c255-4d8b-81ea-05daf0505d71"><span class="GINGER_SOFTWARE_mark" id="4c668f85-7e39-4e65-ba56-59c8dd90682c">vCPUs</span></span></span></span> – How Many Are Too Many CPU for SQL Server Virtualization<span class="GINGER_SOFTWARE_mark" id="e6bc0480-d63e-4261-8eb4-fb182f046726"><span class="GINGER_SOFTWARE_mark" id="9df75b86-5c87-4e7e-9b6c-2756181622f6"><span class="GINGER_SOFTWARE_mark" id="19a50fd0-79af-4a81-9f87-3294041b014f"><span class="GINGER_SOFTWARE_mark" id="c598a6e8-746e-4f40-80f5-a8f7743b0b32"> ?</span></span></span></span> – Notes from the Field #003</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/11/26/sql-server-sql-server-configuration-checking-a-must-do-for-every-dba-notes-from-the-field-004/">SQL Server Configuration Checking – A Must Do for Every DBA – Notes from the Field #004</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/12/05/sql-server-finding-frequently-running-query-and-elapsed-time-notes-from-the-field-005/">Finding Frequently Running Query and Elapsed Time – Notes from the Field #005</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/12/12/sql-server-optimal-memory-settings-for-sql-server-notes-from-the-field-006/">Optimal Memory Settings for SQL Server – Notes from the Field #006</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/12/19/sql-server-sql-server-alerts-and-how-to-use-them-notes-from-the-field-007/">SQL Server Alerts and How to Use Them – Notes from the Field #007</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2013/12/25/sql-server-overall-sql-server-performance-not-just-query-performance-notes-from-the-field-008/" rel="bookmark"><span class="GINGER_SOFTWARE_mark" id="bb16b1eb-1edf-4f77-b796-fdc991176528"><span class="GINGER_SOFTWARE_mark" id="37e8b4b1-4225-4cce-b747-00fbe1f60f9f"><span class="GINGER_SOFTWARE_mark" id="1d97aa8d-1785-4010-836a-7ae3ba28c5f8"><span class="GINGER_SOFTWARE_mark" id="4d4b5ce1-042a-4287-bf82-a253dac5b08c">Overall SQL</span></span></span></span> Server Performance – Not Just Query Performance – Notes from the Field #008</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/01/02/sql-server-tools-for-proactive-dbas-central-management-server-notes-from-the-field-009/">Tools for Proactive DBAs – Central Management Server – Notes from the Field #009</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/01/09/sql-server-auditors-passwords-and-exceptions-notes-from-the-field-010/">Auditors, Passwords and Exceptions – Notes from the Field #010</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/01/16/sql-server-check-for-database-integrity-notes-from-the-field-011/">Check for Database Integrity – Notes from the Field #011</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/01/23/sql-server-tools-for-proactive-dbas-policy-based-management-notes-from-the-field-012/">Tools for Proactive DBAs – Policy Based Management – Notes from the Field #012</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/01/30/sql-server-virtualized-sql-server-performance-and-storage-system-notes-from-the-field-013/">Virtualized SQL Server Performance and Storage System – Notes from the Field #013</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/02/06/sql-server-learning-ssis-where-do-i-start-notes-from-the-field-014/">Learning SSIS – Where Do I Start? – Notes from the Field #014</a></strong></li>
<li><strong><a href="http://blog.sqlauthority.com/2014/02/13/sql-server-expanding-your-skills-notes-from-the-field-015/">Expanding Your Skills – Notes from the Field #015</a></strong></li>
<li>
<p style="display:inline !important;"><strong><a href="http://blog.sqlauthority.com/2014/02/20/sql-server-finding-the-last-backup-for-all-databases-notes-from-the-field-016-2/" target="_blank">Finding the Last Backup for All Databases – Notes from the Field #016</a></strong></p>
</li>
</ul>
<p style="text-align:justify;">If you are busy with Christmas, I suggest you bookmark this post and read it later on in <span class="GINGER_SOFTWARE_mark" id="82ec7693-e28e-4fa7-aebf-64290a85c150">the new year</span>.</p>
<p>Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank" rel="nofollow">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/notes-from-the-field/'>Notes from the Field</a>, <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26841/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26841/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26841/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26841/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26841/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26841/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26841/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26841/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26841&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/02/24/sql-server-contest-post-notes-from-the-field-learning-performance-tuning-and-database-health/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>

		<media:content url="http://www.pinaldave.com/bimg/notesfromfield.jpg" medium="image" />

		<media:content url="http://www.pinaldave.com/bimg/doctor-cartoon.gif" medium="image" />
	</item>
		<item>
		<title>SQLAuthority News &#8211; Two Whitepapers from AzureCAT Team on SQL Database</title>
		<link>http://blog.sqlauthority.com/2014/02/23/sqlauthority-news-two-whitepapers-from-azurecat-team-on-sql-database/</link>
		<comments>http://blog.sqlauthority.com/2014/02/23/sqlauthority-news-two-whitepapers-from-azurecat-team-on-sql-database/#comments</comments>
		<pubDate>Sun, 23 Feb 2014 01:30:17 +0000</pubDate>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
				<category><![CDATA[PostADay]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Authority]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[T SQL]]></category>

		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=26804</guid>
		<description><![CDATA[Recently I was reading about SQL Database on Azure. There are lots of confusion around SQL Database around SQL Azure and I have been looking for a good authentic documentation which I can refer as well as I can use that in my day job. After a quick research I ended up on two excellent [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26804&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">Recently I was reading about SQL Database on Azure. There are lots of confusion around SQL Database around SQL Azure and I have been looking for a good authentic documentation which I can refer as well as I can use that in my day job. After a quick research I ended up on two excellent white papers on Microsoft&#8217;s site. If you are into learning SQL Database deployed on Azure, these two are essential white paper for learning.</p>
<p style="text-align:justify;"><strong>Windows <span class="GINGER_SOFTWARE_mark" id="d1d49d80-f7e7-4c0e-bd42-7b7bb94dd586"><span class="GINGER_SOFTWARE_mark" id="3bd5b321-e8ce-422a-b8a3-b2243d2dd88b"><span class="GINGER_SOFTWARE_mark" id="a98e075c-84ec-4fee-bd5c-aa948b291d50">Azure SQL</span></span></span> Database and SQL Server &#8211; Performance and Scalability Compared and Contrasted </strong><br />
This white paper is recently updated and one of the most important <span class="GINGER_SOFTWARE_mark" id="a598924c-af06-4593-9dc3-2eb6f5cbb147"><span class="GINGER_SOFTWARE_mark" id="0a3a07d7-dffb-4ec0-9561-d445c5aaf387"><span class="GINGER_SOFTWARE_mark" id="2ea1b6b1-2d37-4649-8a15-fc024fa8c53f">article</span></span></span> to know the difference between SQL Server and Windows Azure SQL Database (SQL Database). There are lots of similarities and differences between SQL Database and SQL Server and they are often confused among each other. This article takes on the vary subject and explains the differences between them very clearly and with the help of examples. Here are few important sections of this white paper.</p>
<ul style="text-align:justify;">
<li>Standard Application Scenarios</li>
<li>Several Common Expections</li>
<li>Classic Patterns</li>
<li>General Performance Evaluation</li>
<li>Evalute Performance of SQL Database</li>
</ul>
<p style="text-align:justify;"><strong><a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj553018.aspx" target="_blank">Click here to read Windows <span class="GINGER_SOFTWARE_mark" id="7dce0266-a7fa-4ce9-839e-6720db949b61"><span class="GINGER_SOFTWARE_mark" id="b935224b-a383-4758-bf38-abc89641a237">Azure SQL</span></span> Database and SQL Server &#8211; Performance and Scalability Compared and Contrasted </a></strong></p>
<p style="text-align:justify;">Reference: <strong>Pinal Dave (<a href="http://blog.sqlauthority.com/" target="_blank">http://blog.sqlauthority.com</a>)</strong></p><br />Filed under: <a href='http://blog.sqlauthority.com/category/technology/postaday/'>PostADay</a>, <a href='http://blog.sqlauthority.com/category/technology/sql/'>SQL</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-authority/'>SQL Authority</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-query/'>SQL Query</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-server/'>SQL Server</a>, <a href='http://blog.sqlauthority.com/category/technology/sql-tips-and-tricks/'>SQL Tips and Tricks</a>, <a href='http://blog.sqlauthority.com/category/technology/t-sql/'>T SQL</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlauthority.wordpress.com/26804/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlauthority.wordpress.com/26804/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/sqlauthority.wordpress.com/26804/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/sqlauthority.wordpress.com/26804/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlauthority.wordpress.com/26804/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlauthority.wordpress.com/26804/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlauthority.wordpress.com/26804/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlauthority.wordpress.com/26804/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.sqlauthority.com&#038;blog=668536&#038;post=26804&#038;subd=sqlauthority&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.sqlauthority.com/2014/02/23/sqlauthority-news-two-whitepapers-from-azurecat-team-on-sql-database/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/48aa5a2264e8a27d802bb22ab6ccf688?s=96&#38;d=identicon" medium="image">
			<media:title type="html">pinaldave</media:title>
		</media:content>
	</item>
	</channel>
</rss>
