<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>The Ji Village News &#187; Windows</title> <atom:link href="http://www.haidongji.com/category/technology/windows/feed/" rel="self" type="application/rss+xml" /><link>http://www.haidongji.com</link> <description>季庄新闻--Haidong Ji's Blog</description> <lastBuildDate>Mon, 30 Jan 2012 02:41:37 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.2</generator> <item><title>Generating dimension data for dates</title><link>http://www.haidongji.com/2011/07/30/generating-dimension-data-for-dates/</link> <comments>http://www.haidongji.com/2011/07/30/generating-dimension-data-for-dates/#comments</comments> <pubDate>Sun, 31 Jul 2011 04:12:06 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[Oracle]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1238</guid> <description><![CDATA[Most analytical and BI databases have date dimension table(s). One frequently needs to generate and populate such data. I present a solution below for such data generation, written in Python. Please use different database drivers/modules to connect to your specific database server (MySQL, SQL Server, Oracle, etc.) for data population. Notes: 1. It takes 2 [...]]]></description> <content:encoded><![CDATA[<p>Most analytical and BI databases have date dimension table(s). One frequently needs to generate and populate such data. I present a solution below for such data generation, written in Python. Please use different database drivers/modules to connect to your specific database server (MySQL, SQL Server, Oracle, etc.) for data population.</p><p>Notes:</p><p>1. It takes 2 parameters, start date and end date, in YYYYMMDD format, inclusive. Extensive error checking is built in, but let me know if you have comments/suggestions;</p><p>2. The script produce a Python dictionary (associated array) and print out its content;</p><p>3. The output includes dayNumber: a day&#8217;s position in a year. For example, 2011-02-01 is the 32ed day in 2011, therefore its dayNumber is 32;</p><p>4. The output includes weekNumber: a week&#8217;s position in a year. The week number in year is based on ISO standard. From documentation: the ISO year consists of 52 or 53 full weeks, where a week starts on a Monday and ends on a Sunday. The first week of an ISO year is the first (Gregorian) calendar week of a year containing a Thursday. This is called week number 1, and the ISO year of that Thursday is the same as its Gregorian year.</p><p>So, 2011-01-01 has the weekNumber 52, because it falls on a Saturday and belongs to the last week of 2010.</p><p>5. The output includes weekday information as well. 4 different variations are included:<br
/> Sunday 0, Monday 1, and so on<br
/> Sunday 1, Monday 2, and so on<br
/> Monday 0, Tuesday 1, and so on<br
/> Monday 1, Tuesday 2, and so on</p><p>6. The script requires the argparse module. It comes with Python 2.7. Python version prior to 2.7 does not have it by default, therefore you need to install it.</p><pre class="brush: python">
import argparse, sys, time
from datetime import date, timedelta
parser = argparse.ArgumentParser(description=&quot;Generating date dimension data&quot;)
parser.add_argument(&#039;-s&#039;, &#039;--startDate&#039;, help=&#039;Start date in YYYYMMDD format&#039;, required=True, dest=&#039;startDate&#039;)
parser.add_argument(&#039;-e&#039;, &#039;--endDate&#039;, help=&#039;end date in YYYYMMDD format&#039;, required=True, dest=&#039;endDate&#039;)
argList = parser.parse_args()
if (((not argList.startDate.isdigit()) or (not (len(argList.startDate) == 8))) or ((not argList.endDate.isdigit()) or (not (len(argList.endDate) == 8))) or (argList.startDate &gt; argList.endDate)):
	print &quot;Input(s) must be numeric in YYYYMMDD format and end date must not be earlier than start date&quot;
	sys.exit (1)
try:
	startDate = date(int(argList.startDate[0:4]), int(argList.startDate[4:6]), int(argList.startDate[6:8]))
	endDate = date(int(argList.endDate[0:4]), int(argList.endDate[4:6]), int(argList.endDate[6:8]))
except ValueError:
	print &quot;Input(s) must be valid date value in YYYYMMDD format&quot;
	sys.exit (1)
start = time.time()
while startDate &lt;= endDate:
	dateInfo = {&#039;dateYYYYMMDD&#039;: startDate.strftime(&#039;%Y%m%d&#039;), &#039;calDate&#039;: startDate.strftime(&#039;%Y-%m-%d&#039;), &#039;calDay&#039;: startDate.day, &#039;calMonth&#039;: startDate.month, &#039;calYear&#039;: startDate.year}
	dateInfo[&#039;dayOfWeekSunday0Monday1&#039;] = startDate.isoweekday() % 7
	dateInfo[&#039;dayOfWeekSunday1Monday2&#039;] = startDate.isoweekday() % 7 + 1
	dateInfo[&#039;dayOfWeekSunday6Monday0&#039;] = startDate.weekday()
	dateInfo[&#039;dayOfWeekSunday7Monday1&#039;] = startDate.isoweekday()
	dateInfo[&#039;dayNumber&#039;] = startDate.toordinal() - date(startDate.year - 1, 12, 31).toordinal()
	dateInfo[&#039;weekNumber&#039;] = startDate.isocalendar()[1]
	print dateInfo
	startDate = startDate + timedelta(1)
</pre>]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/07/30/generating-dimension-data-for-dates/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Sysinternals and PAL</title><link>http://www.haidongji.com/2011/07/10/sysinternals-and-pal/</link> <comments>http://www.haidongji.com/2011/07/10/sysinternals-and-pal/#comments</comments> <pubDate>Sun, 10 Jul 2011 17:19:09 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1229</guid> <description><![CDATA[Sysinternals and PAL (Performance Analysis of Logs) are two fantastic tools for general server information gathering and troubleshooting on Windows. Sysinternals suite is a set of tools that can be downloaded freely from Microsoft. One thing that is particularly attractive about them is that they can be run directly after downloading without special installation and [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://technet.microsoft.com/en-us/sysinternals/bb842062">Sysinternals</a> and <a
href="http://pal.codeplex.com/">PAL (Performance Analysis of Logs)</a> are two fantastic tools for general server information gathering and troubleshooting on Windows.</p><p>Sysinternals suite is a set of tools that can be downloaded freely from Microsoft. One thing that is particularly attractive about them is that they can be run directly after downloading without special installation and all the footprints a typical installation leaves on the host machine (new directories under C:\Program Files\, registry entries, data files and what have you). I found them very valuable and handy.</p><p>In particular, psInfo provides good summary information of the server. For example, psinfo -s -h -d provides basic information about the system, software installed, Windows hot fixes installed, and disk volume information.</p><p>PAL: install PAL on your test/analysis/general purpose machine. Install the mschart control as it is a prerequisite of PAL. Here is how I used it:</p><p>1. Produce Perfmon data gathering template files using PAL. I exported 3 template files: overview, quick overview, and SQL Server 2005/2008;</p><p>Perfmon is the general-purpose data instrumentation tool on Windows. Through Perfmon you can gather system wide counters for things like CPU, memory, network, and disk IO. In addition, a lot of applications such as SQL Server, Exchange, and others, expose application level Instrumentation data such that you can collect them via Perfmon as well.</p><p>It is best to have a few handy data collection template, hence this step.</p><p>2. On the Windows server that I am interested in monitoring, import Perfmon counter template file produced above by opening a DOS prompt under Administrator and executing:</p><p>logman import -n templateNameIdefine -xml pathAndName2TemplateXmlFile</p><p>3. Open Perfmon, find the one you imported, and start collecting</p><p>4. After collection is done, copy the log file and use PAL for analysis. It will generate a very nice and intuitive report. Please don&#8217;t run PAL on the system you are diagnosing. Run it somewhere else. Be patient, as it will take a while for PAL to churn through the data (it took 2 hours on a Rackspace cloud server with 2 CPUs and 1 gig of RAM for a file about 30 meg)</p> ]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/07/10/sysinternals-and-pal/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Installing Perl DBI and DBD-mysql on Windows 64 bit</title><link>http://www.haidongji.com/2011/06/20/installing-perl-dbi-and-dbd-mysql-on-windows-64-bit/</link> <comments>http://www.haidongji.com/2011/06/20/installing-perl-dbi-and-dbd-mysql-on-windows-64-bit/#comments</comments> <pubDate>Mon, 20 Jun 2011 21:28:33 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[Perl]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1214</guid> <description><![CDATA[I had trouble getting Perl DBI and DBD-mysql on Windows in the past. In addition, on Windows 64-bit, you sometimes see recommendations of using 32-bit Perl. Today I got to test the latest 64-bit ActiveState Perl distro for Windows, version 5.12.3.1204. I tested it on Windows 2008 R2 64-bit. I am happy to report that [...]]]></description> <content:encoded><![CDATA[<p>I had trouble getting <a
href="http://www.haidongji.com/2009/05/13/activestate-perl-510-windows-xp-and-dbd-mysql/">Perl DBI and DBD-mysql on Windows in the past</a>. In addition, on Windows 64-bit, you sometimes see recommendations of using 32-bit Perl.</p><p>Today I got to test the latest 64-bit ActiveState Perl distro for Windows, version 5.12.3.1204. I tested it on Windows 2008 R2 64-bit. I am happy to report that it works. I am not categorically recommend FOR the installation of 64-bit Perl on Windows, though.</p><p>Here are the steps:<br
/> 1. Get the ActiveState Perl 64-bit package for Windows and install it, following all the default options;<br
/> 2. On command prompt, do:<br
/> cd c:\perl64\bin<br
/> ppm install DBI<br
/> ppm install DBD-mysql</p><p>I then tested against both Oracle&#8217;s MySQL 5.5 Community Server and MariaDb&#8217;s 5.2.7 on Windows with MaatKit&#8217;s mk-table-checksum to confirm. And it worked fine:</p><p>C:\Users\Administrator\Downloads\maatkit-7540\maatkit-7540\bin>c:\Perl64\bin\perl.exe mk-table-checksum &#8211;databases mysql h=localhost,u=root,p=password</p> ]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/06/20/installing-perl-dbi-and-dbd-mysql-on-windows-64-bit/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Install MySQLdb module for Python</title><link>http://www.haidongji.com/2011/04/04/install-mysqldb-module-for-python/</link> <comments>http://www.haidongji.com/2011/04/04/install-mysqldb-module-for-python/#comments</comments> <pubDate>Tue, 05 Apr 2011 03:06:22 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1130</guid> <description><![CDATA[Update: Commenter MarkR made a great point: if possible, use some packaging tools, to try to maintain proper dependencies, to the extent that is possible. Install from the source should be Plan B. So, try yum install MySQL-python first. This is mostly for my own future reference. It&#8217;ll be icing on the cake if it [...]]]></description> <content:encoded><![CDATA[<p>Update:</p><p>Commenter MarkR made a great point: if possible, use some packaging tools, to try to maintain proper dependencies, to the extent that is possible. Install from the source should be Plan B. So, try yum install MySQL-python first.</p><p>This is mostly for my own future reference. It&#8217;ll be icing on the cake if it helps you!</p><p>This is geared for CentOS or Red Hat. Use apt-get or other packaging tools for different flavours of Linux.</p><p>1. Get Python module setuptools called <a
href="http://pypi.python.org/pypi/setuptools">easy_install</a>. I love easy_install, by the way, sort of like CPAN for Perl modules;<br
/> 2. To install MySQLdb package, you would think easy_install MySQLdb would do. But that is not the case. I hope the developer would fix that. Instead, you need:</p><p>easy_install MySQL-python</p><p>3. If you have build errors, you may need:<br
/> yum install python-devel or yum install gcc or both.</p><p>Update: one more tip. If you encounter:</p><p>gcc: error trying to exec &#8216;cc1plus&#8217;: execvp: No such file or directory, you probably need:</p><p>yum install gcc-c++</p> ]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/04/04/install-mysqldb-module-for-python/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Windows disk throughput benchmark steps with sqlio</title><link>http://www.haidongji.com/2011/02/16/windows-disk-throughput-benchmark-steps-with-sqlio/</link> <comments>http://www.haidongji.com/2011/02/16/windows-disk-throughput-benchmark-steps-with-sqlio/#comments</comments> <pubDate>Thu, 17 Feb 2011 04:27:55 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1073</guid> <description><![CDATA[Credits to Linchi Shea, SQLServerPedia/Brent Ozar, and Jonathan Kehayias for their discussions on sqlio. Update: The test below, against one drive, can run for more than 1 hour. That is a long time. I&#8217;ve tested running 2 sqlio batch scripts against 2 locally attached drives, similar to the ones listed below, and found the results [...]]]></description> <content:encoded><![CDATA[<p>Credits to <a
href="http://sqlblog.com/blogs/linchi_shea/archive/2007/02/21/parse-the-sqlio-exe-output.aspx">Linchi Shea</a>, <a
href="http://sqlserverpedia.com/wiki/SAN_Performance_Tuning_with_SQLIO">SQLServerPedia/Brent Ozar</a>, and <a
href="http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/05/25/parsing-sqlio-output-to-excel-charts-using-regex-in-powershell.aspx">Jonathan Kehayias</a> for their discussions on sqlio.</p><p>Update: The test below, against one drive, can run for more than 1 hour. That is a long time. I&#8217;ve tested running 2 sqlio batch scripts against 2 locally attached drives, similar to the ones listed below, and found the results to be consistent with running those 2 concurrently.</p><p>1. Download and install sqlio;<br
/> 2. Modify param.txt in the same directory where sqlio is. Create a testing file that is 24 gig, or sufficiently large to beat hardware cache along the way. For example, to benchmark drive m, the entry should look like this:</p><pre class="brush: text">
m:\testfile.dat 2 0x0 20480
</pre><p>If you use mount point, it should look like this:</p><pre class="brush: text">
m:\mountPointDirectoryName\testfile.dat 2 0x0 20480
</pre><p>3. Make sure file in step 2 is saved. In DOS command line, under the sqlio installation directory, run the command below. It will create a file for use later:</p><pre class="brush: text">
sqlio -kW -s10 -fsequential -o8 -b8 -LS -Fparam.txt timeout /T 10
</pre><p>4. Create a batch file with the following line as content, let&#8217;s call it mDrive.bat. SQLServerPedia article lets each test run 120 seconds, 2 minutes. In my testing against local disks, I made it 30 seconds. Actually I ran both 120 and 30 and didn&#8217;t see much of a difference. So I will use 30 seconds.</p><p>Note: to test against Windows mount point, the lines below should be like this:</p><pre class="brush: text">
sqlio -kW -t2 -s30 -dM -o1 -frandom -b64 -BH -LS \mountPointDirectoryName\Testfile.dat
</pre><pre class="brush: text">
sqlio -kW -t2 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o4 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o8 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o16 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o32 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o64 -frandom -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o128 -frandom -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t2 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t4 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t8 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t16 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t32 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kW -t64 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t2 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t4 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t8 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t16 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t32 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o1 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o2 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o4 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o8 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o16 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o32 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o64 -fsequential -b64 -BH -LS Testfile.dat
sqlio -kR -t64 -s30 -dM -o128 -fsequential -b64 -BH -LS Testfile.dat
</pre><p>5. In DOS command line, under the sqlio installation directory, run the command below. It takes more than 1 hour, but less than 2 hours to finish:</p><pre class="brush: text">
mDrive.bat &gt; mDriveSqlioResults.txt
</pre><p>6. Run <a
href="http://www.haidongji.com/2011/02/15/parse-sqlio-log-file-with-python-pyparsing/">this Python script</a> to parse mDriveSqlioResults.txt into a CSV file;</p><p>7. Open the CSV file with Excel, create a new sheet, insert a column chart. Drag the chart to make it decent size. Right click on &#8220;Select Data&#8230;&#8221; or something like that, then go back to the first sheet to pick 2 columns of data for this chart. I found charts with MBPS, IOPS, avgLatencyInMS, and maxLatencyInMS are helpful.</p> ]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/02/16/windows-disk-throughput-benchmark-steps-with-sqlio/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Parse sqlio log file with Python pyparsing</title><link>http://www.haidongji.com/2011/02/15/parse-sqlio-log-file-with-python-pyparsing/</link> <comments>http://www.haidongji.com/2011/02/15/parse-sqlio-log-file-with-python-pyparsing/#comments</comments> <pubDate>Wed, 16 Feb 2011 04:44:44 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1066</guid> <description><![CDATA[A few weeks ago I posted some questions on 3 Python text processing modules: pyparsing, SimpleParse, and NLTK. Today I need to analyze a log file generated by sqlio. I decided to use pyparsing. I am pretty pleased with it. I am aware that there are at least 2 utility scripts for this: one is [...]]]></description> <content:encoded><![CDATA[<p>A few weeks ago I posted some <a
href="http://www.haidongji.com/2010/12/31/questions-on-text-processing-with-python/">questions on 3 Python text processing modules: pyparsing, SimpleParse, and NLTK</a>. Today I need to analyze a log file generated by sqlio. I decided to use pyparsing. I am pretty pleased with it.</p><p>I am aware that there are at least 2 utility scripts for this: one is in Perl and then other is in Windows PowerShell. But I wanted to write in Python.</p><p>Noteworthy points:</p><p>1. In analyzing and building up the grammar/structure of the text for Python, I opted for line by line analysis and coding. I think this brings clarity and is easier to read. It felt a bit tedious in building it up, but once it is done, it is pretty rewarding to see the end results;<br
/> 2. After parsing, the script writes the results to a csv file. You can then open that in a spreadsheet program to create some charts. Seeing the results in a column diagram chart brings clarity and focus to the result. It worked pretty well for me.</p><p>All in all, a good and productive day. Below are the details. The top part is the sample log content to be parsed, followed by the program.</p><pre class="brush: python">
&quot;&quot;&quot;
c:\Program Files (x86)\SQLIO&gt;sqlio -kW -t2 -s30 -dH -o1 -frandom -b64 -BH -LS Testfile.dat
sqlio v1.5.SG
using system counter for latency timings, 2208037 counts per second
2 threads writing for 30 secs to file H:Testfile.dat
	using 64KB random IOs
	enabling multiple I/Os per thread with 1 outstanding
	buffering set to use hardware disk cache (but not file cache)
using current size: 24576 MB for file: H:Testfile.dat
initialization done
CUMULATIVE DATA:
throughput metrics:
IOs/sec:  6106.50
MBs/sec:   381.65
latency metrics:
Min_Latency(ms): 0
Avg_Latency(ms): 0
Max_Latency(ms): 5
histogram:
ms: 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24+
%: 99  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
c:\Program Files (x86)\SQLIO&gt;sqlio -kW -t2 -s30 -dH -o2 -frandom -b64 -BH -LS Testfile.dat
sqlio v1.5.SG
using system counter for latency timings, 2208037 counts per second
2 threads writing for 30 secs to file H:Testfile.dat
	using 64KB random IOs
	enabling multiple I/Os per thread with 2 outstanding
	buffering set to use hardware disk cache (but not file cache)
using current size: 24576 MB for file: H:Testfile.dat
initialization done
CUMULATIVE DATA:
throughput metrics:
IOs/sec:  6951.19
MBs/sec:   434.44
latency metrics:
Min_Latency(ms): 0
Avg_Latency(ms): 0
Max_Latency(ms): 6
histogram:
ms: 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24+
%: 87 12  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
&quot;&quot;&quot;
from pyparsing import *
output = open(&quot;sample.csv&quot;, &quot;w&quot;)
input = open(&quot;hDriveSqlioResults.txt&quot;, &quot;r&quot;)
data = input.read()
#------------------------------------------------------------------------
# Define Grammars
#------------------------------------------------------------------------
integer = Word(nums)
singleLetter = Word(alphas, max=1)
realNumber = Combine(Word(nums) + &#039;.&#039; + Word(nums))
reading = Literal(&quot;reading&quot;)
writing = Literal(&quot;writing&quot;)
readingOrWriting = reading | writing
random = Literal(&quot;random&quot;)
sequential = Literal(&quot;sequential&quot;)
randomOrSequential = random | sequential
#Line 1 is useful. We want to suck out the juicy parts.
sectionBeginning = CaselessLiteral(&quot;c:\\program files (x86)\\sqlio&gt;sqlio &quot;)
ioKind = &quot;-k&quot; + singleLetter(&quot;k&quot;)
numThreads = &quot;-t&quot; + integer(&quot;t&quot;)
numSeconds = &quot;-s&quot; + integer(&quot;s&quot;)
driveOrMountPath = &quot;-d&quot; + singleLetter(&quot;d&quot;)
outstandingRequests = &quot;-o&quot; + integer(&quot;o&quot;)
accessType = &quot;-f&quot; + Word(alphas)(&quot;f&quot;)
ioBlockSizeInKB = &quot;-b&quot; + integer(&quot;b&quot;)
#Line 2 can be safely ignored
line2 = &quot;sqlio v&quot; + restOfLine
#Line 3 can be safely ignored
line3 = &quot;using system counter for latency timings&quot; + restOfLine
#Line 4 can be safely ignored
line4 = integer + &quot;threads&quot; + readingOrWriting + restOfLine
#Line 5 can be safely ignored
line5 = &quot;using&quot; + integer + &quot;KB&quot; + randomOrSequential + &quot;IOs&quot; + restOfLine
#Line 6 can be safely ignored
line6 = &quot;enabling multiple &quot; + restOfLine
#Line 7 can be safely ignored
line7 = &quot;buffering set to use&quot; + restOfLine
#Line 8 we should get the file size out
line8 = &quot;using current size: &quot; + integer(&quot;fileSize&quot;) + Word(alphas)(&quot;fileSizeUnit&quot;) + restOfLine
#Line 9 can be safely ignored
line9 = &quot;initialization done&quot; + restOfLine
#Line 10 can be safely ignored
line10 = &quot;CUMULATIVE&quot; + restOfLine
#Line 11 can be safely ignored
line11 = &quot;throughput&quot; + restOfLine
#Line 12 we want IOPS
line12 = &quot;IOs/sec:&quot; + realNumber(&quot;IOPS&quot;) + restOfLine
#Line 13 we want MBPS
line13 = &quot;MBs/sec:&quot; + realNumber(&quot;MBPS&quot;) + restOfLine
#Line 14 can be safely ignored
line14 = &quot;latency&quot; + restOfLine
#Line 15 we need to get minLatency out
line15 = &quot;Min_Latency(ms):&quot; + integer(&quot;minLatency&quot;) + restOfLine
#Line 16 we need to get avgLatency out
line16 = &quot;Avg_Latency(ms):&quot; + integer(&quot;avgLatency&quot;) + restOfLine
#Line 17 we need to get maxLatency out
line17 = &quot;Max_Latency(ms):&quot; + integer(&quot;maxLatency&quot;) + restOfLine
#Line 18 can be safely ignored
line18 = &quot;histogram&quot; + restOfLine
#Line 19 can be safely ignored
line19 = &quot;ms:&quot; + restOfLine
#Line 20 can be safely ignored
line20 = &quot;\%:&quot; + restOfLine
extraStuff = ZeroOrMore(line14 | line15 | line16 | line17 | line18 | line19 | line20)
logEntry = sectionBeginning + ioKind + numThreads + numSeconds + driveOrMountPath + outstandingRequests + accessType + ioBlockSizeInKB + restOfLine + line2 + line3 + line4 + line5 + line6 + line7 + line8 + line9 + line10 + line11 + line12 + line13 + extraStuff
output.write(&quot;IO property, IOPS, MBPS, minLatencyInMS, avgLatencyInMS, maxLatencyInMS\n&quot;)
for tokens in logEntry.searchString(data):
	output.write(&quot;%(k)s%(t)s threads %(o)s queue %(f)s in %(b)s KB chunks,%(IOPS)s,%(MBPS)s,%(minLatency)s,%(avgLatency)s,%(maxLatency)s\n&quot; % tokens)
</pre>]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/02/15/parse-sqlio-log-file-with-python-pyparsing/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Search objects in SQL Server databases with pyodbc</title><link>http://www.haidongji.com/2011/01/05/search-objects-in-sql-server-databases-with-pyodbc/</link> <comments>http://www.haidongji.com/2011/01/05/search-objects-in-sql-server-databases-with-pyodbc/#comments</comments> <pubDate>Thu, 06 Jan 2011 00:08:59 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1032</guid> <description><![CDATA[Command line utility to search for objects based on names. Search results will be displayed in well formatted tabular format, left-justified. 1. pyodbc installed; 2. Use trusted authentication by default. Find the relevant code to adjust to login/password as needed; 3. -w for wild card search. Default is exact name match, case insensitive in almost [...]]]></description> <content:encoded><![CDATA[<p>Command line utility to search for objects based on names. Search results will be displayed in well formatted tabular format, left-justified.</p><p>1. pyodbc installed;<br
/> 2. Use trusted authentication by default. Find the relevant code to adjust to login/password as needed;<br
/> 3. -w for wild card search. Default is exact name match, case insensitive in almost all cases, depending on your SQL Server configuration;<br
/> 4. If -d is not specified, all databases in instance will be searched, minus the ones that one not accessible at the moment. To specify database(s) you want to search into, use -d followed by database names. Separate them with comma if more than one;<br
/> 5. Use -S to specify instance;<br
/> 6. Good sample code for command line parameters processing and pyodbc usage;<br
/> 7. Won&#8217;t work with SQL Server 2000 or lower.</p><p>Example 1: python objectSearch.py myobject -S instance1<br
/> Result: Database objects that are named myobject in instance1 will be displayed</p><p>Example 2: python objectSearch.py -S server1 -w -d db1,db2 myobject<br
/> Result: Database objects that has &#8220;myobject&#8221; in db1 and db2 in server1 will be displayed</p><pre class="brush: python">
import pyodbc, argparse
def pp(cursor, data=None, check_row_lengths=True):
    if not data:
        data = cursor.fetchall( )
    names = [  ]
    lengths = [  ]
    rules = [  ]
    for col, field_description in enumerate(cursor.description):
        field_name = field_description[0]
        names.append(field_name)
        field_length = field_description[2] or 12
        field_length = max(field_length, len(field_name))
        if check_row_lengths:
            # double-check field length, if it&#039;s unreliable
            data_length = max([ len(str(row[col])) for row in data ])
            field_length = max(field_length, data_length)
        lengths.append(field_length)
        rules.append(&#039;-&#039; * field_length)
    format = &quot; &quot;.join([&quot;%%-%ss&quot; % l for l in lengths])
    result = [ format % tuple(names), format % tuple(rules) ]
    for row in data:
        result.append(format % tuple(row))
    return &quot;\n&quot;.join(result)
def objectMatch(wildcardSearch, objectNamePattern, dbName, cn):
	if wildcardSearch:
		sql = &quot;select &#039;%s&#039; as dbName, s.name schema_name, o.name, o.type from %s.sys.objects o inner join %s.sys.schemas s on o.schema_id = s.schema_id where o.name like &#039;%%%s%%\&#039; order by dbname, schema_name, o.name&quot; % (dbName, dbName, dbName, objectNamePattern)
		cursor = cn.cursor()
		cursor.execute(sql)
		rows = cursor.fetchall()
		if len(rows) &gt; 0:
			print pp(cursor, rows, 1)
	else:
		sql = &quot;select &#039;%s&#039; as dbName, s.name schema_name, o.name, o.type from %s.sys.objects o inner join %s.sys.schemas s on o.schema_id = s.schema_id where o.name = &#039;%s&#039; order by dbname, schema_name, o.name&quot; % (dbName, dbName, dbName, objectNamePattern)
		cursor = cn.cursor()
		cursor.execute(sql)
		rows = cursor.fetchall()
		if len(rows) &gt; 0:
			print pp(cursor, rows, 1)
parser = argparse.ArgumentParser(description=&#039;SQL Server object search. Case insensitive&#039;)
parser.add_argument(&#039;-S&#039;, &#039;--server&#039;, help=&#039;Instance you wish to connect to. myInstance is the default if not specified&#039;, dest=&#039;instance&#039;, default=&#039;myInstance&#039;)
parser.add_argument(&#039;-w&#039;, help=&#039;Wildcard search indicator. If specified, LIKE clause will be used for pattern matching. Otherwise it will look for an exact match. Exact match is default&#039;, action=&quot;store_true&quot;, dest=&#039;wild&#039;, default=False)
parser.add_argument(&#039;-d&#039;, &#039;--database&#039;, help=&#039;Database(s) you want to search in. If more than one, separate them by comma only. It will search all databases by default&#039;, action=&quot;store&quot;, dest=&quot;dbs&quot;)
parser.add_argument(&#039;objectNamePattern&#039;, help=&#039;Object name pattern you want to search for&#039;, action=&quot;store&quot;)
argList = parser.parse_args()
try:
	cn = pyodbc.connect(&quot;DRIVER={SQL Server};SERVER=%s;DATABASE=master;Trusted_Connection=yes&quot; % argList.instance)
except:
	print &quot;Couldn&#039;t connect to %s. It is down or you might have had a typo.&quot; % argList.instance
if argList.dbs is None:
	cursor = cn.cursor()
	cursor.execute(&quot;select name from sys.databases where state = 0&quot;)
	rows = cursor.fetchall()
	for row in rows:
		objectMatch(argList.wild, argList.objectNamePattern, row.name, cn)
else:
	dbs = argList.dbs.split(&#039;,&#039;)
	for db in dbs:
		objectMatch(argList.wild, argList.objectNamePattern, db, cn)
</pre>]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2011/01/05/search-objects-in-sql-server-databases-with-pyodbc/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Getting rid of &#8220;Welcome to Internet Explorer 8&#8243; screen</title><link>http://www.haidongji.com/2010/12/09/getting-rid-of-welcome-to-internet-explorer-8-screen/</link> <comments>http://www.haidongji.com/2010/12/09/getting-rid-of-welcome-to-internet-explorer-8-screen/#comments</comments> <pubDate>Thu, 09 Dec 2010 16:37:30 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[Technology]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=1000</guid> <description><![CDATA[The lack of Vimperator function in Chrome, which exists in Firefox, prevents me from totally switching to it. Because I work in different environments in terms of different clients and operating systems, I have to use Internet Explorer sometimes. And I found the &#8220;Welcome to Internet Explorer 8&#8243; screen upon IE starting, if you have [...]]]></description> <content:encoded><![CDATA[<p>The lack of Vimperator function in Chrome, which exists in Firefox, prevents me from totally switching to it. Because I work in different environments in terms of different clients and operating systems, I have to use Internet Explorer sometimes.</p><p>And I found the &#8220;Welcome to Internet Explorer 8&#8243; screen upon IE starting, if you have not followed Microsoft command to configure IE the first time you started, terribly irratitating. It has message like this in the window: &#8220;Internet Explorer 8 helps you use the Internet even faster than before. New features like search suggestions retrieve blah blah&#8230;&#8221;. Would you please respect the end user&#8217;s intelligence, get out of the way and leave him/her alone in peace, quite, and solitude? Sure, one can follow the wizard and set things up, but it feels like being violated. The ability to customize things is good, but not under your dictation.</p><p>Behold, there is a way! Come and follow my way, dear reader, for it leads to enlightenment and eternal happiness:</p><p>1. Start -> Run<br
/> 2. gpedit.msc<br
/> 3. Navigate to User Configuration -> Administrative Template -> Windows Components -> Internet Explorer -> Prevent performance of First Run Customize settings<br
/> 4. Double click, then set it as Disabled.</p> ]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2010/12/09/getting-rid-of-welcome-to-internet-explorer-8-screen/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Unattended install of SQL Server 2008 R2</title><link>http://www.haidongji.com/2010/09/23/unattended-install-of-sql-server-2008-r2/</link> <comments>http://www.haidongji.com/2010/09/23/unattended-install-of-sql-server-2008-r2/#comments</comments> <pubDate>Thu, 23 Sep 2010 18:05:14 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=929</guid> <description><![CDATA[I&#8217;ve written unattended / silent install before for SQL Server 2005. Unattended install is cool because you can automate things: it saves time and improves consistency. Here is something to get you started. I used the command below to: 1. Install SQL Server 2008 R2 default instance, including Replication and FullText search; 2. Install client [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve written unattended / silent install before for SQL Server 2005. Unattended install is cool because you can automate things: it saves time and improves consistency.</p><p>Here is something to get you started. I used the command below to:</p><p>1. Install SQL Server 2008 R2 default instance, including Replication and FullText search;<br
/> 2. Install client tools such as: SQL Server Management Studio, Business Intelligence Development Studio, sqlcmd, Configuration Manager, and such;<br
/> 3. Install Books Online so help is available locally.</p><p>In other words, it sets things up quickly for a typical OLTP DBA so s/he can start getting dirty and productive with minimal delay and distraction.</p><p>Things to keep in mind:</p><p>1. I didn&#8217;t care much about startup account (SQLSVCACCOUNT and AGTSVCACCOUNT) stuff for my testing here. Modify that as necessary. You can also change the startup account after the install is done. So don&#8217;t hang up on that if you don&#8217;t know what the domain\userAccount should be. Let the learning process continue;<br
/> 2. Features is a list of features seperated by comma only, no space in between;<br
/> 3. /qs is nice if you want visual dialog windows popping up telling you where you are at. It is neat to have that visual confirmation during the first few runs. Once you are comfortable, a simple /q will do;<br
/> 4. Don&#8217;t forget /SQLSYSADMINACCOUNTS. Remember to put that piece in so you can connect after the installation is complete. Kinda important, ya know.</p><pre class="brush: text">
E:\Installers\SQL&gt;Setup.exe /qs /ACTION=Install /FEATURES=SQL,Tools /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT=&quot;NT AUTHORITY\SYSTEM&quot;
/SQLSYSADMINACCOUNTS=&quot;.\Administrator&quot; /AGTSVCACCOUNT=&quot;NT AUTHORITY\Network Service&quot; /IACCEPTSQLSERVERLICENSETERMS
</pre>]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2010/09/23/unattended-install-of-sql-server-2008-r2/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Testing Windows IO with SQLIO and SysBench</title><link>http://www.haidongji.com/2010/09/19/testing-windows-io-with-sqlio-and-sysbench/</link> <comments>http://www.haidongji.com/2010/09/19/testing-windows-io-with-sqlio-and-sysbench/#comments</comments> <pubDate>Mon, 20 Sep 2010 04:28:38 +0000</pubDate> <dc:creator>Haidong Ji</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[SQLServer]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Windows]]></category> <guid
isPermaLink="false">http://www.haidongji.com/?p=915</guid> <description><![CDATA[To benchmark IO on Linux and MySQL transaction processing, SysBench is a popular choice that can do both. After poking around at the source code, it seems PostgreSQL and Oracle are also included for transaction processing testing if you have the proper header files, but I didn&#8217;t test those. To benchmark IO on Windows and [...]]]></description> <content:encoded><![CDATA[<p>To benchmark IO on Linux and MySQL transaction processing, SysBench is a popular choice that can do both. After poking around at the source code, it seems PostgreSQL and Oracle are also included for transaction processing testing if you have the proper header files, but I didn&#8217;t test those.</p><p>To benchmark IO on Windows and SQL Server transaction processing, Microsoft provides two tools, SQLIO and SQLIOSim. SQLIO is a misnomer in that it really doesn&#8217;t have much to do with SQL Server. It is a general purpose disk IO benchmark tool.</p><p>So today I was playing with SysBench and noticed that I can compile and build it on Windows as well. I decided I should run IO benchmark on a single machine with both tools (SQLIO and SysBench), and see if I could reconcile the results.</p><p>To make things simple, I thought I would just benchmark random read of 3G (orders of magnitude bigger than disk controller cache) files for 5 minutes (300 seconds) with a single thread using 16Kb block size, without adding any additional queue. I tested this on both my laptop and an Amazon EC2 instance. The commands for both tools are listed below, and they should perform the same thing, as far as I can tell. Let me know if you have any comments/pointers or if I missed anything.</p><p>SysBench commands:</p><pre class="brush: text">
sysbench --test=fileio --file-total-size=3G prepare
sysbench.exe --test=fileio --file-total-size=3G --file-test-mode=rndrd --max-time=300 run
</pre><p>Fro SQLIO, here is the line in param.txt and command used:</p><pre class="brush: text">
c:\testfile.dat 1 0x0 3072
sqlio -kR -s300 -dc -b16 -frandom -Fparam.txt
</pre><p>As this is a quick test, I ran the same test twice and took the average value for comparison purposes. The detailed output is pasted at the end of this post.</p><p>On my Windows XP Pro Service Pack 2 laptop with Intel X-25 SSD:</p><table
border="1"><tr><th></th><th>IO/Second</th><th>Throughput/Second</th></tr><tr><td>SQLIO</td><td>3833.5</td><td>59.90Mb</td></tr><tr><td>SysBench</td><td>3390.77</td><td>52.98Mb</td></tr></table><p>So on my laptop, SQLIO&#8217;s results are 13% higher than that of SysBench.</p><p>On Amazon EC2 ami-c3e40daa with EBS device running Windows Server 2008 Datacenter Edition Service Pack 2, whose results varied widely between my two runs:</p><table
border="1"><tr><th></th><th>IO/Second</th><th>Throughput/Second</th></tr><tr><td>SQLIO</td><td>678.91</td><td>10.61Mb</td></tr><tr><td>SysBench</td><td>408.96</td><td>6.39Mb</td></tr></table><p>On this machine, SQLIO results are 66% higher than that of SysBench.</p><p>Below is the gory details.</p><p>Here are the detailed output on my laptop:<br
/> SQLIO<br
/> C:\Program Files\SQLIO>sqlio -kR -s300 -dc -b16 -frandom -Fparam.txt<br
/> sqlio v1.5.SG<br
/> parameter file used: param.txt<br
/> file c:\testfile.dat with 1 thread (0) using mask 0&#215;0 (0)<br
/> 1 thread reading for 300 secs from file c:\testfile.dat<br
/> using 16KB random IOs<br
/> using specified size: 3072 MB for file: c:\testfile.dat<br
/> initialization done<br
/> CUMULATIVE DATA:<br
/> throughput metrics:<br
/> IOs/sec:  3835.39<br
/> MBs/sec:    59.92</p><p>C:\Program Files\SQLIO>sqlio -kR -s300 -dc -b16 -frandom -Fparam.txt<br
/> sqlio v1.5.SG<br
/> parameter file used: param.txt<br
/> file c:\testfile.dat with 1 thread (0) using mask 0&#215;0 (0)<br
/> 1 thread reading for 300 secs from file c:\testfile.dat<br
/> using 16KB random IOs<br
/> using specified size: 3072 MB for file: c:\testfile.dat<br
/> initialization done<br
/> CUMULATIVE DATA:<br
/> throughput metrics:<br
/> IOs/sec:  3832.00<br
/> MBs/sec:    59.87</p><p>SysBench<br
/> C:\MessAround\sysbench-0.4.12\sysbench-0.4.12\sysbench\RelWithDebInfo>sysbench.e<br
/> xe &#8211;test=fileio &#8211;file-total-size=3G &#8211;file-test-mode=rndrd &#8211;max-time=300 run<br
/> sysbench 0.4:  multi-threaded system evaluation benchmark</p><p>Running the test with following options:<br
/> Number of threads: 1</p><p>Extra file open flags: 0<br
/> 128 files, 24Mb each<br
/> 3Gb total file size<br
/> Block size 16Kb<br
/> Number of random requests for random IO: 10000<br
/> Read/Write ratio for combined random IO test: 1.50<br
/> Periodic FSYNC enabled, calling fsync() each 100 requests.<br
/> Calling fsync() at the end of test, Enabled.<br
/> Using synchronous I/O mode<br
/> Doing random read test<br
/> Threads started!<br
/> WARNING: Operation time (18446744073709226000.000000) is greater than maximal co<br
/> unted value, counting as 10000000000000.000000<br
/> WARNING: Percentile statistics will be inaccurate<br
/> Done.</p><p>Operations performed:  10000 Read, 0 Write, 0 Other = 10000 Total<br
/> Read 156.25Mb  Written 0b  Total transferred 156.25Mb  (52.143Mb/sec)<br
/> 3337.16 Requests/sec executed</p><p>Test execution summary:<br
/> total time:                          2.9966s<br
/> total number of events:              10000<br
/> total time taken by event execution: 2.9343<br
/> per-request statistics:<br
/> min:                                  0.01ms<br
/> avg:                                  0.29ms<br
/> max:                            18446744073709.47ms<br
/> approx.  95 percentile:               0.48ms</p><p>Threads fairness:<br
/> events (avg/stddev):           10000.0000/0.00<br
/> execution time (avg/stddev):   2.9343/0.00</p><p>C:\MessAround\sysbench-0.4.12\sysbench-0.4.12\sysbench\RelWithDebInfo>sysbench.e<br
/> xe &#8211;test=fileio &#8211;file-total-size=3G &#8211;file-test-mode=rndrd &#8211;max-time=300 run<br
/> sysbench 0.4:  multi-threaded system evaluation benchmark</p><p>Running the test with following options:<br
/> Number of threads: 1</p><p>Extra file open flags: 0<br
/> 128 files, 24Mb each<br
/> 3Gb total file size<br
/> Block size 16Kb<br
/> Number of random requests for random IO: 10000<br
/> Read/Write ratio for combined random IO test: 1.50<br
/> Periodic FSYNC enabled, calling fsync() each 100 requests.<br
/> Calling fsync() at the end of test, Enabled.<br
/> Using synchronous I/O mode<br
/> Doing random read test<br
/> Threads started!<br
/> WARNING: Operation time (18446744073694841000.000000) is greater than maximal co<br
/> unted value, counting as 10000000000000.000000<br
/> WARNING: Percentile statistics will be inaccurate<br
/> Done.</p><p>Operations performed:  10000 Read, 0 Write, 0 Other = 10000 Total<br
/> Read 156.25Mb  Written 0b  Total transferred 156.25Mb  (53.818Mb/sec)<br
/> 3444.38 Requests/sec executed</p><p>Test execution summary:<br
/> total time:                          2.9033s<br
/> total number of events:              10000<br
/> total time taken by event execution: 2.8777<br
/> per-request statistics:<br
/> min:                                  0.01ms<br
/> avg:                                  0.29ms<br
/> max:                            18446744073696.34ms<br
/> approx.  95 percentile:              15.39ms</p><p>Threads fairness:<br
/> events (avg/stddev):           10000.0000/0.00<br
/> execution time (avg/stddev):   2.8777/0.00</p><p>Here are the detailed output from Amazon EC2 ami-c3e40daa with EBS device:<br
/> SQLIO<br
/> c:\Program Files\SQLIO>sqlio -kR -t1 -s300 -dC -frandom -b16 -Fparam.txt -BH -LS</p><p>sqlio v1.5.SG<br
/> using system counter for latency timings, 3579545 counts per second<br
/> parameter file used: param.txt<br
/> file c:\testfile.dat with 1 thread (0) using mask 0&#215;0 (0)<br
/> 1 thread reading for 300 secs from file c:\testfile.dat<br
/> using 16KB random IOs<br
/> buffering set to use hardware disk cache (but not file cache)<br
/> size of file c:\testfile.dat needs to be: 3221225472 bytes<br
/> current file size:      0 bytes<br
/> need to expand by:      3221225472 bytes<br
/> expanding c:\testfile.dat &#8230; done.<br
/> using specified size: 3072 MB for file: c:\testfile.dat<br
/> initialization done<br
/> CUMULATIVE DATA:<br
/> throughput metrics:<br
/> IOs/sec:  1230.94<br
/> MBs/sec:    19.23<br
/> latency metrics:<br
/> Min_Latency(ms): 0<br
/> Avg_Latency(ms): 0<br
/> Max_Latency(ms): 204<br
/> histogram:<br
/> ms: 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24+<br
/> %: 98  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0</p><p>c:\Program Files\SQLIO>sqlio -kR -t1 -s300 -dC -frandom -b16 -Fparam.txt -BH -LS</p><p>sqlio v1.5.SG<br
/> using system counter for latency timings, 3579545 counts per second<br
/> parameter file used: param.txt<br
/> file c:\testfile.dat with 1 thread (0) using mask 0&#215;0 (0)<br
/> 1 thread reading for 300 secs from file c:\testfile.dat<br
/> using 16KB random IOs<br
/> buffering set to use hardware disk cache (but not file cache)<br
/> using specified size: 3072 MB for file: c:\testfile.dat<br
/> initialization done<br
/> CUMULATIVE DATA:<br
/> throughput metrics:<br
/> IOs/sec:   126.88<br
/> MBs/sec:     1.98<br
/> latency metrics:<br
/> Min_Latency(ms): 0<br
/> Avg_Latency(ms): 7<br
/> Max_Latency(ms): 497<br
/> histogram:<br
/> ms: 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24+<br
/> %: 13  9  0  3  7  8  8  8  8  8  8  8  2  1  1  1  1  1  1  1  1  0  0  0  2</p><p>C:\Users\Administrator\Documents\sysbench-0.4.12\sysbench\RelWithDebInfo>sysbenc<br
/> h.exe &#8211;test=fileio &#8211;file-total-size=3G &#8211;file-test-mode=rndrd &#8211;max-time=300 r<br
/> un<br
/> sysbench 0.4:  multi-threaded system evaluation benchmark</p><p>Running the test with following options:<br
/> Number of threads: 1</p><p>Extra file open flags: 0<br
/> 128 files, 24Mb each<br
/> 3Gb total file size<br
/> Block size 16Kb<br
/> Number of random requests for random IO: 10000<br
/> Read/Write ratio for combined random IO test: 1.50<br
/> Periodic FSYNC enabled, calling fsync() each 100 requests.<br
/> Calling fsync() at the end of test, Enabled.<br
/> Using synchronous I/O mode<br
/> Doing random read test<br
/> Threads started!<br
/> Done.</p><p>Operations performed:  10000 Read, 0 Write, 0 Other = 10000 Total<br
/> Read 156.25Mb  Written 0b  Total transferred 156.25Mb  (10.64Mb/sec)<br
/> 680.95 Requests/sec executed</p><p>Test execution summary:<br
/> total time:                          14.6854s<br
/> total number of events:              10000<br
/> total time taken by event execution: 14.6048<br
/> per-request statistics:<br
/> min:                                  0.01ms<br
/> avg:                                  1.46ms<br
/> max:                                150.29ms<br
/> approx.  95 percentile:               4.77ms</p><p>Threads fairness:<br
/> events (avg/stddev):           10000.0000/0.00<br
/> execution time (avg/stddev):   14.6048/0.00</p><p>C:\Users\Administrator\Documents\sysbench-0.4.12\sysbench\RelWithDebInfo>sysbenc<br
/> h.exe &#8211;test=fileio &#8211;file-total-size=3G &#8211;file-test-mode=rndrd &#8211;max-time=300 r<br
/> un<br
/> sysbench 0.4:  multi-threaded system evaluation benchmark</p><p>Running the test with following options:<br
/> Number of threads: 1</p><p>Extra file open flags: 0<br
/> 128 files, 24Mb each<br
/> 3Gb total file size<br
/> Block size 16Kb<br
/> Number of random requests for random IO: 10000<br
/> Read/Write ratio for combined random IO test: 1.50<br
/> Periodic FSYNC enabled, calling fsync() each 100 requests.<br
/> Calling fsync() at the end of test, Enabled.<br
/> Using synchronous I/O mode<br
/> Doing random read test<br
/> Threads started!<br
/> Done.</p><p>Operations performed:  10000 Read, 0 Write, 0 Other = 10000 Total<br
/> Read 156.25Mb  Written 0b  Total transferred 156.25Mb  (2.1371Mb/sec)<br
/> 136.77 Requests/sec executed</p><p>Test execution summary:<br
/> total time:                          73.1139s<br
/> total number of events:              10000<br
/> total time taken by event execution: 73.0284<br
/> per-request statistics:<br
/> min:                                  0.02ms<br
/> avg:                                  7.30ms<br
/> max:                                728.84ms<br
/> approx.  95 percentile:              23.08ms</p><p>Threads fairness:<br
/> events (avg/stddev):           10000.0000/0.00<br
/> execution time (avg/stddev):   73.0284/0.00</p> ]]></content:encoded> <wfw:commentRss>http://www.haidongji.com/2010/09/19/testing-windows-io-with-sqlio-and-sysbench/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
