<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>My DasBlog! - Databases</title>
    <link>http://net.bloggix.com/</link>
    <description>newtelligence powered</description>
    <language>en-us</language>
    <copyright>Alexander Meijers</copyright>
    <lastBuildDate>Wed, 18 May 2005 06:30:09 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>a.meijers@smoothocean.com</managingEditor>
    <webMaster>a.meijers@smoothocean.com</webMaster>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=2cfef107-ea0b-4276-8be4-8acf30160811</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2cfef107-ea0b-4276-8be4-8acf30160811</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">
            <a href="http://sqljunkies.com/WebLog/amachanic/">Adam Machanic</a> has
posted a month ago an article about SqlDataReader performance tips. One about using
an indexer with the ordinal position, a second one about avoiding the <font face="Courier New" color="#808080">Get&lt;datatype&gt;</font> methods
and a third about opening and closing the reader.</font>
        </p>
        <p>
          <font color="#000000">Especially the last one is something we all sometimes forget.
Thanks to Adam for these tips! :)</font>
        </p>
        <p>
          <font color="#000000">
            <strong>Tip 1: </strong>
          </font>
          <font color="#000000">
            <strong>Use
an indexer with the ordinal position</strong>: </font>
        </p>
        <p>
          <font color="#000000">Instead of: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">while
(reader.read()) object x = reader.GetValue("ColX");</font>
          </font>
        </pre>
        <p>
          <font color="#000000">or </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font color="#808080">while
(reader.read()) object x = reader["ColX"];</font>
          </font>
        </pre>
        <p>
          <font color="#000000">do: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
ColX = reader.GetOrdinal("ColX"); while (reader.read()) object x = reader[ColX];</font>
          </font>
        </pre>
        <p>
          <font color="#000000">
            <strong>Tip 2: Avoid the Get&lt;datatype&gt; (e.g. GetInt32)
methods at all costs, and use static casts instead of converts: </strong>
          </font>
        </p>
        <p>
          <font color="#000000">Bad: </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
x = reader.GetInt32(ColX);</font>
          </font>
        </pre>
        <p>
          <font color="#000000">Better: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
x = Convert.ToInt32(reader[ColX]);</font>
          </font>
        </pre>
        <p>
          <font color="#000000">Best: </font>
        </p>
        <p>
          <font color="#000000">
          </font>
        </p>
        <pre class="code">
          <font face="Verdana" color="#000000">
            <font face="Courier New" color="#808080">int
x = (int)reader[ColX];</font>
          </font>
        </pre>
        <p>
          <font color="#000000">For maximal performance return the SQL Server equivalent of
whatever datatype you'll be casting to (so that you can avoid the Convert methods.)
And avoid NULLs so that you don't have to check for DBNull on the client.</font>
        </p>
        <p>
          <font color="#000000">
            <strong>Tip 3: "open late and close early"</strong>
          </font>
        </p>
        <p>
          <font color="#000000">Finally, just like in classic ADO, when using a SqlDataReader,
"open late and close early" is the way to go. Open your connection at the last possible
moment and close it as soon as you're done reading the data -- this will maximize
connection pool availability. </font>
        </p>
        <p>
          <font color="#000000">
          </font> 
</p>
        <p>
          <font color="#000000">you can find all the tips also at his blog by following this
link:</font>
        </p>
        <p>
          <a href="http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx">http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx</a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2cfef107-ea0b-4276-8be4-8acf30160811" />
      </body>
      <title>Nice SqlDataReader performance tips by Adam Machanic</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</guid>
      <link>http://net.bloggix.com/2005/05/18/NiceSqlDataReaderPerformanceTipsByAdamMachanic.aspx</link>
      <pubDate>Wed, 18 May 2005 06:30:09 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;&lt;a href="http://sqljunkies.com/WebLog/amachanic/"&gt;Adam Machanic&lt;/a&gt; has
posted a month ago an article about SqlDataReader performance tips. One about using
an indexer with the ordinal position, a second one about avoiding the &lt;font face="Courier New" color=#808080&gt;Get&amp;lt;datatype&amp;gt;&lt;/font&gt; methods
and a third about opening and closing the reader.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Especially the last one is something we all sometimes forget.
Thanks to Adam for these tips! :)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Tip 1: &lt;/strong&gt;&lt;/font&gt;&lt;font color=#000000&gt;&lt;strong&gt;Use
an indexer with the ordinal position&lt;/strong&gt;: &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Instead of: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;while
(reader.read()) object x = reader.GetValue("ColX");&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;or &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font color=#808080&gt;while
(reader.read()) object x = reader["ColX"];&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;do: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
ColX = reader.GetOrdinal("ColX"); while (reader.read()) object x = reader[ColX];&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Tip 2: Avoid the Get&amp;lt;datatype&amp;gt; (e.g. GetInt32) methods
at all costs, and use static casts instead of converts: &lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Bad: &lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
x = reader.GetInt32(ColX);&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Better: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
x = Convert.ToInt32(reader[ColX]);&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Best: &lt;/font&gt; 
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&lt;pre class=code&gt;&lt;font face=Verdana color=#000000&gt;&lt;font face="Courier New" color=#808080&gt;int
x = (int)reader[ColX];&lt;/font&gt; &lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#000000&gt;For maximal performance return the SQL Server equivalent of whatever
datatype you'll be casting to (so that you can avoid the Convert methods.) And avoid
NULLs so that you don't have to check for DBNull on the client.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;strong&gt;Tip 3: "open late and close early"&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Finally, just like in classic ADO, when using a SqlDataReader,
"open late and close early" is the way to go. Open your connection at the last possible
moment and close it as soon as you're done reading the data -- this will maximize
connection pool availability. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;you can find all the tips also at his blog by following this link:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx"&gt;http://sqljunkies.com/WebLog/amachanic/archive/2005/04/06/10462.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=2cfef107-ea0b-4276-8be4-8acf30160811" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,2cfef107-ea0b-4276-8be4-8acf30160811.aspx</comments>
      <category>C#</category>
      <category>Databases</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=bf3b3e89-c260-4c56-b586-17d6c5fbdca0</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,bf3b3e89-c260-4c56-b586-17d6c5fbdca0.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,bf3b3e89-c260-4c56-b586-17d6c5fbdca0.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bf3b3e89-c260-4c56-b586-17d6c5fbdca0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As we know every database is build from two files on disk. The first file contains
all data and the second file contains the log of the database. The log file grows
and grows and grows...
</p>
        <p>
Yesterday i had to backup a database from server A and restore it back onto server
B. When i tried to restore the database i got the message that an enormous amount
of disk space was needed. I discovered that my log file of the database was almost
145 Gb big. During the restoring the system tries to reserve the same amount of space
which was not there.
</p>
        <p>
Thanks to Bob from Logica CMG i found out that you have to do the following
to shrink your database files. Open your properties of the database and go to the
tab called "Options". There you will find a dropdown box for the recovery model which
you have to set to "Simple".
</p>
        <p>
          <img src="http://blogs.tamtam.nl/alexander/content/binary/db_properties.JPG" border="0" />
        </p>
        <p>
Open the Query Analyser and execute the following command:
</p>
        <p>
          <strong>DBCC SHRINKDATABASE(database_name)</strong> where database_name is the name
of the database.
</p>
        <p>
Both files for the database are shrunk to a minimal size. Now i could easily backup
my database from server A and restore it on server B.
</p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=bf3b3e89-c260-4c56-b586-17d6c5fbdca0" />
      </body>
      <title>Shrinking your database log file in SQL Server 2000</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,bf3b3e89-c260-4c56-b586-17d6c5fbdca0.aspx</guid>
      <link>http://net.bloggix.com/2005/04/12/ShrinkingYourDatabaseLogFileInSQLServer2000.aspx</link>
      <pubDate>Tue, 12 Apr 2005 05:58:14 GMT</pubDate>
      <description>&lt;p&gt;
As we know every database is build from two files on disk. The first file contains
all data and the second file contains the log of the database. The log file grows
and grows and grows...
&lt;/p&gt;
&lt;p&gt;
Yesterday i had to backup a database from server A and restore it back onto server
B. When i tried to restore the database i got the message that an enormous amount
of disk space was needed. I discovered that my log file of the database was almost
145 Gb big. During the restoring the system tries to reserve the same amount of space
which was not there.
&lt;/p&gt;
&lt;p&gt;
Thanks to&amp;nbsp;Bob from&amp;nbsp;Logica CMG i found out that you have to do the following
to shrink your database files. Open your properties of the database and go to the
tab called "Options". There you will find a dropdown box for the recovery model which
you have to set to "Simple".
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blogs.tamtam.nl/alexander/content/binary/db_properties.JPG" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Open the Query Analyser and execute the following command:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;DBCC SHRINKDATABASE(database_name)&lt;/strong&gt; where database_name is the name
of the database.
&lt;/p&gt;
&lt;p&gt;
Both files for the database are shrunk to a minimal size. Now i could easily backup
my database from server A and restore it on server B.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=bf3b3e89-c260-4c56-b586-17d6c5fbdca0" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,bf3b3e89-c260-4c56-b586-17d6c5fbdca0.aspx</comments>
      <category>Databases</category>
    </item>
    <item>
      <trackback:ping>http://net.bloggix.com/Trackback.aspx?guid=81ff6b61-3946-4e8d-82cc-4d084d175d93</trackback:ping>
      <pingback:server>http://net.bloggix.com/pingback.aspx</pingback:server>
      <pingback:target>http://net.bloggix.com/PermaLink,guid,81ff6b61-3946-4e8d-82cc-4d084d175d93.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://net.bloggix.com/CommentView,guid,81ff6b61-3946-4e8d-82cc-4d084d175d93.aspx</wfw:comment>
      <wfw:commentRss>http://net.bloggix.com/SyndicationService.asmx/GetEntryCommentsRss?guid=81ff6b61-3946-4e8d-82cc-4d084d175d93</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Thanks to the blog of <a href="http://loudcarrot.com/Blogs/dave/archive/2005/02/13/1499.aspx">Dave
Donaldson</a> i found a link to a website about connection strings for any type
of database. The link to the website is:
</p>
        <p>
          <a href="http://www.connectionstrings.com">www.connectionstrings.com</a>
        </p>
        <img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=81ff6b61-3946-4e8d-82cc-4d084d175d93" />
      </body>
      <title>Connection Strings</title>
      <guid isPermaLink="false">http://net.bloggix.com/PermaLink,guid,81ff6b61-3946-4e8d-82cc-4d084d175d93.aspx</guid>
      <link>http://net.bloggix.com/2005/03/30/ConnectionStrings.aspx</link>
      <pubDate>Wed, 30 Mar 2005 07:34:57 GMT</pubDate>
      <description>&lt;p&gt;
Thanks to the blog of &lt;a href="http://loudcarrot.com/Blogs/dave/archive/2005/02/13/1499.aspx"&gt;Dave
Donaldson&lt;/a&gt; i found a link to a website about&amp;nbsp;connection strings for any type
of database. The link to the website is:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.connectionstrings.com"&gt;www.connectionstrings.com&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://net.bloggix.com/aggbug.ashx?id=81ff6b61-3946-4e8d-82cc-4d084d175d93" /&gt;</description>
      <comments>http://net.bloggix.com/CommentView,guid,81ff6b61-3946-4e8d-82cc-4d084d175d93.aspx</comments>
      <category>Databases</category>
    </item>
  </channel>
</rss>