Archive for February, 2008

TableDiff in Sql Server 2005

TableDiff is a great tool to compare the content of tables with the same structure. It is part of replication tools, but can be used for other purposes as well.

This is the requirement of the tool, as spelled out in this error message: The replication table difference tool requires the comparison tables/views to have either a primary key, identity, rowguid or unique key column.

Here is a sample statement:

C:\Program Files\Microsoft SQL Server\90\COM>tablediff -sourceserver SourceInstance -sourcedatabase SourceDb -sourceschema dbo -sourcetable t1 -destinationserver DestinationInstance -destinationdatabase Test2 -destinationschema dbo -destinationtable t1 -f c:\tablediff.sql

Comments

Logo programming fun

My son had the idea, and I just implemented it in Logo. It’s been really fun. We learned typing, math, geometry, and all that together without even knowing it. We did it on Ubuntu with KTurtle. By the way, it looks KTurtle’s Logo implementation is not consistent with documentations found in other sites. The next version of KTurtle may fix that.

The idea he came up with was to divide a canvas into 3 equal parts and paint them in different colors: white, black, and red. Below is what I came up with. I drew my implementation on a piece of paper and explained what I was going to do. It’s actually not as easy as we first thought. The things we learned: difference between GO versus FORWARD or BACKWARD, TURN commands and the fact that GO does not change the turtle’s direction (in other words, the direction is maintained unless you change it). In fact, DIRECTION is actually a better keyword for me to use here for this purpose, I should remember to tell him tomorrow morning. I should also introduce variables later, at least to define the canvas size.

We will do a Swedish flag together, then Chinese flag, followed by American flag, probably in the order of difficulty. This site was pretty helpful in figuring out different colors and their corresponding RGB codes.

This is what we got:

KTurtle

# Begin LOGO code

reset
canvassize 300, 300
canvascolor 255, 0, 0
penwidth 100
pencolor 255, 250, 250
go 0, 50
turnright 90
forward 300
go 0, 150
pencolor 0, 0, 0

# turnright 90
forward 300
pencolor 255, 0, 0
go 0, 250

# turnright 90
forward 300
center

# End LOGO code

Comments (1)

Big Security Token cache affects performance of Sql Server 2005

I recently came across a Sql Server performance problem. It was caused by TokenAndPermUserStore taking too much of cache.

Server specifications:

Windows 2003 R2 SP2 Enterprise b4-bit, Sql Server 2005 Enterprise 64-bit SP2, 2 Quad-Core Dell server with 32 gig of memory

Symptoms that I have experienced:

1. Over time, the application got timeout messages. Task Manager on the server itself didn’t show any CPU, Memory, or IO pressure. It would take me forever to connect to the instance, while I am on the box directly, and open a query window. This happened despite the fact that this is a overpowered 64-bit machine with 8 processors, 32 gig of memory that only serves a handful of small databases;

2. If you issue statement below and inspect its value over time, you will see the value keeps increasing:

Select single_pages_kb + multi_pages_kb from sys.dm_os_memory_clerks where type = ‘userstore_tokenperm’

The reason it took so much space, I think, is because there are tons of temp table creation in user stored procedures. You could bypass this issue if you give the app login sysadmin, but we all know what a brilliant idea that is.

My solution: I put in a job that flushes the Security Token cache daily. I didn’t observe any negative effects, and the performance problem went away. This is the statement I used:

dbcc freesystemcache (’TokenAndPermUserStore’)
go

Microsoft claims that there are hot fixes for this, but the above DBCC command fixed my woes, so I didn’t bother requesting it.

Comments (2)

In memory of Ken Henderson

Ken Henderson’s death really shocked me. I didn’t feel like working for a few days after I learned the news.

I met Ken twice. The first time was when I was at PASS (Sql Server conference) in Grapevine, Texas. Then I just admired him from afar. We may have traded pleasantries. I remember attending Microsoft PSS lab, and bumped into him there too. He struck me as a humble, knowledgeable person that is easy to talk to, a terrific human being. I also met Bob Ward and Bart Duncan there. They are all great folks.

The second time, I was at PASS conference in Barcelona. We may have had a longer conversation, the details of which I couldn’t remember now. When we saw each other, I remember he greeted me by gesturing toward me with a pointed index finger, kinda like cool dudes greeting each other on the streets. As an aspiring information technology professional, I sought his counsel on how to go to the next level, and I remember getting plenty of encouragement from him, which meant a lot.

In the ensuing years, we traded emails a few times. I have his The Guru’s Guide to SQL Server Architecture and Internals book, but never really finished it. That seemed to be the norm for me. I have what I call a “guerilla style of learning” when it comes to IT: I find what I need, and then move on. I am thinking of changing that habit, really dig deep through good technical books by reading cover to cover. Ken’s books will be a great starting point. His preface to this book, where he talked briefly about his childhood growing up in rural Oklahoma, touched me greatly.

When browsing through his books at bookstores 4 or 5 years ago, I remembered that I flipped through the pages looking for his snappy, clever quotes at the beginning of each chapter. Two of the which had lasting impressions: one was a translated Chinese saying: “Of the thirty-six alternatives, running away is the best option”. I was slightly amused by its translation. The other quote was from Truman Capote, the content of which I forgot, probably something about his way of writing, but it served as the first introduction for me to Capote’s work. I read a few short stories by Capote last November, and enjoyed it, although I have to say they all feel kind of weired/queer?. No offense, though. Someday I will watch the Capote movie.

Speaking of movies, I vaguely remember that Ken is a movie fan, and may even have a separate blog for it. I remember he took George Will to task in one of his posts, but I couldn’t find that blog address now.

I learned today that Ken is also the author of this fascinating blog: Infidelis Maximus — Atheism, unbelief, and other subjects of interest to religious infidels. I just had time to browse through a little bit, and I have to say I really enjoyed it.

My condolences goes to his immediate family. What a wonderful, humble, eloquent, articulate, caring, and generous human being! He lives on in many people’s memories. Here I quote his essay “The Aging Champion” he wrote for SQL Server 2005 Practical Troubleshooting: The Database Engine, as the end of this post.

There’s a lesson to be learned here, and it has to do with the value of humility. Becoming arrogant and walling yourself off from the “little people” in the world is a fast ticket to stagnation. It’s a good way to stop growing professionally. There are no little people. The world moves too quickly not to learn all you can from whomever you can whenever you can. No matter how long I work in this business, I continue to learn from practically everyone around me—new people and old alike, experienced and inexperienced as well. I have always considered myself lucky to have worked with so many great people over the years.

No matter who you are, you are never above exchanging a warm greeting or lending a helping hand when you can. People frequently write me or contact me for help, sometimes with the most esoteric of questions, and I do the best I can to assist them. I’ve been where they are, and their requests keep me moving—they keep me on my toes. I’m keenly aware that I owe much of what I’ve learned over the years to the many fine people I’ve had the privilege of coming in contact with, and exchanging a cordial greeting with them or helping them in some small way is the least I can do.

And you have to remember that there is always someone out there who’s bigger and better. When you work harder at trying to hold other people back than at helping them realize their potential, you make what should be teamwork into a zero-sum game where only one party can win—everyone else, by definition, must lose. Even if you prevail for a time, this sets you up for what I call the aging champion syndrome. Eventually someone will come along that you can’t stop. He’ll be quicker or smarter or more determined than you in some way, and you’ll soon find yourself lying flat on your back, knocked out of the match, staring up at the ref while he shouts out the 10-count, wondering why no one listens to you anymore.

Comments

风雪无阻,过年平安

昨天给朋友写电邮时提到受天气影响回家过年的人们。在网上看到不少照片,很震撼,但又不能做些什么。

今天读博客,响应Likk同志的号召,给我的博客也加上黄丝带。祝大家旅途安全,过个好年!

这个叫Likk的家伙可不简单:诗人,爸爸是摄影家,女儿是小诗人,带墨镜,开黑车,很像帮派老大。他是我最欣赏的博客之一。以下是几个很好的链接:

关于农民工子女的教育
媒体之无良

Comments