<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4621332910242972635</id><updated>2011-11-29T10:57:24.018+01:00</updated><category term='AMD'/><category term='SQL'/><title type='text'>Silicon remarks</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://silicon-remarks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://silicon-remarks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>rudidlo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4621332910242972635.post-7184263392854935942</id><published>2008-09-19T16:30:00.001+02:00</published><updated>2008-12-23T20:38:56.333+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='AMD'/><title type='text'>AMD Fusion - a response to your dreams?</title><content type='html'>I've found today a very nice video. If you're AMD fan, enjoy this &lt;a href="http://www.amd.com/us/fusion/Pages/index.aspx"&gt;video&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4621332910242972635-7184263392854935942?l=silicon-remarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://silicon-remarks.blogspot.com/feeds/7184263392854935942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4621332910242972635&amp;postID=7184263392854935942' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default/7184263392854935942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default/7184263392854935942'/><link rel='alternate' type='text/html' href='http://silicon-remarks.blogspot.com/2008/09/amd-fusion-response-to-your-dreams.html' title='AMD Fusion - a response to your dreams?'/><author><name>rudidlo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4621332910242972635.post-4384404508576893294</id><published>2008-03-06T21:33:00.012+01:00</published><updated>2008-09-19T13:36:23.034+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>How to manipulate data through time.</title><content type='html'>Plenty of us are using in our databases Bit column as information if record is valid or not. But when you're selecting only valid records, you must filter table with Del=0 or something. So we have plenty of selects, which are using full scan thank to "Del" column low selectivity. Yes, we can delete records and all associated records in child tables if we want, but there two defects can arise.&lt;br /&gt;&lt;br /&gt;First of them is absence of history related to our data collections. Second one is higher CPU and I/O load.&lt;br /&gt;So I decided to choose two columns in my tables to localize records in time. First of them is column with GETDATE() default value (you know it probably :)), "CreateDate" name and nonclustered index on it, in descend order.&lt;br /&gt;A several week  ago I spoked with one software company owner about NULL values in columns. "Here is no reason to use delegated values instead of NULLs", he said. "When database engine comes with new version, here can be plenty of difficulties with those values.Why you have choosed this kind of mechanism?"&lt;br /&gt;I thought, that seeking some values in datetime column would be faster then seeking columns which has NULL instead of value. Scanning NULLs is slower then scanning values as I noticed &lt;a href="http://silicon-remarks.blogspot.com/2008/01/to-be-with-null-or-not-to-be-with-null.html" target="_blank"&gt;in my last article&lt;/a&gt;. I answered him that database engine always use  index scan and never use index seek. "You're wrong", he said. "Server always use   index scan."&lt;br /&gt;I talked about it with my boss and he said: "Compare those two mechanisms".&lt;br /&gt;So, I decided to write testing script. I create table with integer data type primary key with identity incrementation and two columns with date time data type. I insert about 1 million records into it and then I select all records with delegate values, records with null values and then I seek records in some random interval. Interval is random for every iteration for those two tests. With selecting range over NULL enabled column is more slower, because &lt;a href="http://msdn2.microsoft.com/en-us/library/ms172984.aspx" target="_blank"&gt;SARG&lt;/a&gt; went for a walk :).&lt;br /&gt;Programmer, I have written about him in second paragraph was right and I was wrong with my decision. But when you select limited ranges of data, using delegate values will be always slower.&lt;br /&gt;&lt;br /&gt;Note: You can make some steps to history, when you select data like this:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin:auto 5em;border:1px solid gray;padding: 1em;"&gt;SELECT *&lt;br /&gt;FROM dbo.Table&lt;br /&gt;WHERE CreateDate &lt;= @ParameterDate AND DeleteDate &gt;= @ParameterDate&lt;br /&gt;&lt;/div&gt; to select records which were valid on @ParameterDate.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://0xecza.bay.livefilestore.com/y1prL2cktNjTvvyFOjZ7KQrRl_W7Mc7LLyKMyy9VtDeVlExeXWwARpNkJVQhnMUJYRH7voSNtJQphVVT64XQl5DHw/manipulate-data-through-time.sql?download" target="_blank"&gt;Here you can download testing script&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4621332910242972635-4384404508576893294?l=silicon-remarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://silicon-remarks.blogspot.com/feeds/4384404508576893294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4621332910242972635&amp;postID=4384404508576893294' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default/4384404508576893294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default/4384404508576893294'/><link rel='alternate' type='text/html' href='http://silicon-remarks.blogspot.com/2008/03/how-to-manipulate-width-data-trough.html' title='How to manipulate data through time.'/><author><name>rudidlo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4621332910242972635.post-4057912633016493749</id><published>2008-01-21T14:57:00.029+01:00</published><updated>2008-06-16T09:55:13.819+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>To be with NULL or not to be with NULL</title><content type='html'>&lt;h4&gt;with help from ISNULL and COALESCE functions.&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;From time to time you probably catch an idea about making better performance on your SQL Server. So, I mean SQL Server 2005 or "Yukon", as you wish.&lt;br /&gt;&lt;br /&gt;I have read plenty of articles on the internet about performance related questions. Some authors say, that ISNULL is better and other say that COALESCE is speed like CASE vs. IF-THEN, for instance.&lt;br /&gt;&lt;br /&gt;So I created a &lt;a href="http://0xecza.bay.livefilestore.com/y1prL2cktNjTvs_6AoeswZ78ji9TOdMJu2nw2EU5OQDHJ0tA0SvhP3j-iwhiYhWSmWiPpt9YfjHhRGLWuEQKhyEpA/coalesce-vs-isnull.sql?download"&gt;small SQL script&lt;/a&gt; to measure which method can be faster.&lt;br /&gt;&lt;br /&gt;I ran this script on my machine, so results are better for ISNULL function. IMHO it's because COALESCE must hold datatype for each tested value.&lt;br /&gt;&lt;br /&gt;Please also notice differences between selecting values from NULL-enabled and NON-NULL enabled columns with the same data types. I think, that NON-NULL columns will be always faster.&lt;br /&gt;&lt;br /&gt;&lt;div class="tablecontainer"&gt;&lt;br /&gt;&lt;table cellspacing="0" cellpadding="0" class="table-cell-outline"&gt;&lt;br /&gt;&lt;tr&gt;&lt;th&gt;Function&lt;/th&gt;&lt;th&gt;Data type&lt;/th&gt;&lt;th&gt;NullValues Presence&lt;/th&gt;&lt;th&gt;MinCPUTime&lt;/th&gt;&lt;th&gt;MaxCPUTime&lt;/th&gt;&lt;th&gt;AvgCPUTime&lt;/th&gt;&lt;th&gt;Min Timelength [ms]&lt;/th&gt;&lt;th&gt;Max Timelength [ms]&lt;/th&gt;&lt;th&gt;Avg Timelength [ms]&lt;/th&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;AllColumnsNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;13.33&lt;/td&gt;&lt;td class="cell-numeric"&gt;14.66&lt;/td&gt;&lt;td class="cell-numeric"&gt;14.00&lt;/td&gt;&lt;td class="cell-numeric"&gt;388.95&lt;/td&gt;&lt;td class="cell-numeric"&gt;597.64&lt;/td&gt;&lt;td class="cell-numeric"&gt;493.30&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td  class="bold"&gt;AllThreeNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;14.02&lt;/td&gt;&lt;td class="cell-numeric"&gt;15.77&lt;/td&gt;&lt;td class="cell-numeric"&gt;14.90&lt;/td&gt;&lt;td class="cell-numeric"&gt;455.90&lt;/td&gt;&lt;td class="cell-numeric"&gt;534.09&lt;/td&gt;&lt;td class="cell-numeric"&gt;495.00&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;FirstColumnNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;15.06&lt;/td&gt;&lt;td class="cell-numeric"&gt;17.93&lt;/td&gt;&lt;td class="cell-numeric"&gt;16.50&lt;/td&gt;&lt;td class="cell-numeric"&gt;509.25&lt;/td&gt;&lt;td class="cell-numeric"&gt;624.54&lt;/td&gt;&lt;td class="cell-numeric"&gt;566.90&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;LastColumnNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;13.16&lt;/td&gt;&lt;td class="cell-numeric"&gt;15.23&lt;/td&gt;&lt;td class="cell-numeric"&gt;14.20&lt;/td&gt;&lt;td class="cell-numeric"&gt;457.96&lt;/td&gt;&lt;td class="cell-numeric"&gt;568.63&lt;/td&gt;&lt;td class="cell-numeric"&gt;513.30&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;AllColumnsNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;27.82&lt;/td&gt;&lt;td class="cell-numeric"&gt;30.97&lt;/td&gt;&lt;td class="cell-numeric"&gt;29.40&lt;/td&gt;&lt;td class="cell-numeric"&gt;854.74&lt;/td&gt;&lt;td class="cell-numeric"&gt;1287.25&lt;/td&gt;&lt;td class="cell-numeric"&gt;1071.00&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;AllThreeNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;29.65&lt;/td&gt;&lt;td class="cell-numeric"&gt;32.54&lt;/td&gt;&lt;td class="cell-numeric"&gt;31.10&lt;/td&gt;&lt;td class="cell-numeric"&gt;972.10&lt;/td&gt;&lt;td class="cell-numeric"&gt;1301.89&lt;/td&gt;&lt;td class="cell-numeric"&gt;1137.00&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;FirstColumnNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;33.50&lt;/td&gt;&lt;td class="cell-numeric"&gt;39.09&lt;/td&gt;&lt;td class="cell-numeric"&gt;36.30&lt;/td&gt;&lt;td class="cell-numeric"&gt;1075.53&lt;/td&gt;&lt;td class="cell-numeric"&gt;1567.66&lt;/td&gt;&lt;td class="cell-numeric"&gt;1321.60&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;COALESCE&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;LastColumnNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;31.36&lt;/td&gt;&lt;td class="cell-numeric"&gt;34.03&lt;/td&gt;&lt;td class="cell-numeric"&gt;32.70&lt;/td&gt;&lt;td class="cell-numeric"&gt;1029.25&lt;/td&gt;&lt;td class="cell-numeric"&gt;1169.94&lt;/td&gt;&lt;td class="cell-numeric"&gt;1099.60&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;AllColumnsNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;11.16&lt;/td&gt;&lt;td class="cell-numeric"&gt;12.43&lt;/td&gt;&lt;td class="cell-numeric"&gt;11.80&lt;/td&gt;&lt;td class="cell-numeric"&gt;350.55&lt;/td&gt;&lt;td class="cell-numeric"&gt;494.64&lt;/td&gt;&lt;td class="cell-numeric"&gt;422.60&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;AllThreeNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;9.53&lt;/td&gt;&lt;td class="cell-numeric"&gt;10.66&lt;/td&gt;&lt;td class="cell-numeric"&gt;10.10&lt;/td&gt;&lt;td class="cell-numeric"&gt;245.90&lt;/td&gt;&lt;td class="cell-numeric"&gt;526.09&lt;/td&gt;&lt;td class="cell-numeric"&gt;386.00&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;FirstColumnNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;11.16&lt;/td&gt;&lt;td class="cell-numeric"&gt;12.63&lt;/td&gt;&lt;td class="cell-numeric"&gt;11.90&lt;/td&gt;&lt;td class="cell-numeric"&gt;367.54&lt;/td&gt;&lt;td class="cell-numeric"&gt;419.65&lt;/td&gt;&lt;td class="cell-numeric"&gt;393.60&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;int&lt;/td&gt;&lt;td class="bold"&gt;LastColumnNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;11.28&lt;/td&gt;&lt;td class="cell-numeric"&gt;13.11&lt;/td&gt;&lt;td class="cell-numeric"&gt;12.20&lt;/td&gt;&lt;td class="cell-numeric"&gt;367.91&lt;/td&gt;&lt;td class="cell-numeric"&gt;463.48&lt;/td&gt;&lt;td class="cell-numeric"&gt;415.70&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;AllColumnsNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;24.79&lt;/td&gt;&lt;td class="cell-numeric"&gt;26.20&lt;/td&gt;&lt;td class="cell-numeric"&gt;25.50&lt;/td&gt;&lt;td class="cell-numeric"&gt;825.06&lt;/td&gt;&lt;td class="cell-numeric"&gt;1103.33&lt;/td&gt;&lt;td class="cell-numeric"&gt;964.20&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;AllThreeNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;19.64&lt;/td&gt;&lt;td class="cell-numeric"&gt;21.75&lt;/td&gt;&lt;td class="cell-numeric"&gt;20.70&lt;/td&gt;&lt;td class="cell-numeric"&gt;585.75&lt;/td&gt;&lt;td class="cell-numeric"&gt;965.64&lt;/td&gt;&lt;td class="cell-numeric"&gt;775.70&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;FirstColumnNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;25.36&lt;/td&gt;&lt;td class="cell-numeric"&gt;26.83&lt;/td&gt;&lt;td class="cell-numeric"&gt;26.10&lt;/td&gt;&lt;td class="cell-numeric"&gt;808.47&lt;/td&gt;&lt;td class="cell-numeric"&gt;984.52&lt;/td&gt;&lt;td class="cell-numeric"&gt;896.50&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td class="bold"&gt;ISNULL&lt;/td&gt;&lt;td class="italic"&gt;varchar&lt;/td&gt;&lt;td class="bold"&gt;LastColumnNotNull&lt;/td&gt;&lt;td class="cell-numeric"&gt;28.47&lt;/td&gt;&lt;td class="cell-numeric"&gt;30.12&lt;/td&gt;&lt;td class="cell-numeric"&gt;29.30&lt;/td&gt;&lt;td class="cell-numeric"&gt;929.79&lt;/td&gt;&lt;td class="cell-numeric"&gt;1095.00&lt;/td&gt;&lt;td class="cell-numeric"&gt;1012.40&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4621332910242972635-4057912633016493749?l=silicon-remarks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://silicon-remarks.blogspot.com/feeds/4057912633016493749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4621332910242972635&amp;postID=4057912633016493749' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default/4057912633016493749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4621332910242972635/posts/default/4057912633016493749'/><link rel='alternate' type='text/html' href='http://silicon-remarks.blogspot.com/2008/01/to-be-with-null-or-not-to-be-with-null.html' title='To be with NULL or not to be with NULL'/><author><name>rudidlo</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
