Archive for September, 2007

Moon cakes of 2007

Like Prince Roy, I don’t like Chinese moon cakes during Mid-Autumn festival. This year, we got the following instead:

Our moon cakes: cappuccino mousse, chocolate cheese cake, and tiramisu

They are cappuccino mousse, chocolate cheese cake, and tiramisu for me, our son and my better half respectively. Notice they are all round and tasty.

Speaking of tasty stuff, would you like to try some of this? We got the following picture around the famed Yu Garden in Shanghai.

Ovary and Digestive glands of a crad

Hmmm, dumpling stuffed with the ovary and digestive glands of a crad, absolutely delicious. Let’s just say that is my vegetarian better half’s most favorite dish. (No offense. We just think this is hilarious.)

Happy belated Mid-Autumn festival, everybody. I am working on entries for our family vacation in China. I think I will write in Chinese, with English annotations for pictures.

Comments

Dream language

I was in Denver this week, attending the PASS conference. I always have a good time at PASS: connecting with old friends and making new ones. Plus, it never hurts to crash a few parties, drink some beer (Rock Bottom, just so so, in my opinion), and talk with people from different parts of the country and the world.

On Thursday night we had a volunteer party at the ESPN zone in downtown Denver. Kevin Kline, the current president of PASS, and I had an interesting conversation. We talked a little about learning foreign languages. Kevin mentioned that one foreign friend of his told him that he knew he was good with English when he speaks English in his dreams. Kevin asked if that happened to me.

That was really an interesting question to me, for the following reasons. 1. I never heard of it before; 2. I don’t dream that much, or maybe I do but I couldn’t remember most of them. 3. When I dream, there usually is not much conversation going on. I usually find myself in certain unpleasant predicament, a lot has something to do with taking exams: I didn’t study for the exam or didn’t have enough time for the exams, etc. By the way, both situations actually happened a lot during my school years. In fact, those exam dreams have happened so many times, that I have tried in vain to send a message to the brain part that controls my dreaming to tell my other self in the ether world that “it is just a dream, don’t take it seriously”.

By the way, exams gone wrong seem to be a popular theme of dreamers from all over the world, at least in the US and China. A few other people at the conference told me about it.

My university roommate Du Chaoyun asked me a similar question when he visited Chicago: do I think in English? I actually don’t know the answer to this question. I guess sometimes I do, sometimes I don’t. What I do know is that I will always count in Chinese. I may say the numbers in English out loud, for the benefits of people around me, but there is always translations going on back and forth internally, and I will always count much faster in Chinese.

I have asked the same question to my Swedish better half. She told me she probably thinks in English most of the time nowadays. Sometimes she has trouble remembering a Swedish word when she needs it. I found that to be true in my case also. And she counts in her native language internally too.

I have read it from more than one Chinese web site that English teachers encourage his/her students to think in English. My middle school and high school English teachers may have said the same thing. I don’t know how to achieve it, what it means exactly, or even if achieving that goal is such a good thing.

Comments (1)

Rebuild master database

Recently, the default instance of Sql Server 2005 on my laptop refused to start. Here is the message in the Windows event log:

The SQL Server (MSSQLSERVER) service terminated with service-specific error 3417 (0xD59).

Here is the message in the Sql Server error log:

The log scan number (253:272:1) passed to log scan in database ‘master’ is not valid. This error may indicate data
corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.

Time to rebuild the master database, I told myself. I put in the Sql Server installation media, and ran the following in DOS:

setup.exe /qb INSTANCENAME=mssqlserver REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=ReplaceThisWithMySuperStrongPassword

This underscores the importance of backing up your system databases, especially master and msdb. I actually don’t have them backed up, since this is my test box. But master database is the gut of your Sql Server system, it holds logins, meta data about other databases, among other important information, so it is very important you back it up.

To restore master from a backup after a rebuild, you need to add the -m switch as the startup parameter, so server starts in single user mode. Add it through Sql Server Configuration Manager: double click on Sql Server service, go to Advanced tab, then go to Startup Parameters. At the very end of Startup Parameters, add a semicolon, a dash, and the letter m. Restart and you are ready to restore your master from a backup. When you finish restoring master, remember to take away the -m switch.

If you have backups for your msdb database, which contains important system information such as jobs, SSIS packages, Sql mail, etc, you need to restore it also. You will need to stop Sql Server Agent in order to restore msdb

I am still baffled as to why master was failed / corrupted on my laptop.

Comments

Looking for unused indexes and checking index fragmentation in Sql Server 2005

Here is a script to check unused indexes in your Sql Server 2005 databases. Once one particular index has been used, the dm_db_index_usage_stats will be updated. All this information will be lost every time Sql Server instance is cycled. Therefore, you should run it after Sql Server has been running for a while, as it may take some time for your users or processes to use the indexes. Remember to replace MyDb with your database name

use MyDb
SELECT OBJECT_NAME(object_id) as TableName, object_name(index_id) as IndexName
FROM sys.dm_db_index_usage_stats
WHERE user_seeks = 0
AND user_scans = 0
AND user_lookups = 0
AND system_seeks = 0
AND system_scans = 0
AND system_lookups = 0
and database_id = db_id(’MyDb’)

I have tried to use sp_spaceused to get out how much storage those unused indexes take, but was not successful so far.

The script below can show you index fragmentation in your database, sorted in descending order. Once again, remember to replace MyDb with your database name.
use MyDb
SELECT object_name(b.object_id) as TableName, b.name as IndexName, a.avg_fragmentation_in_percent FROM
sys.dm_db_index_physical_stats(db_id(’MyDb’), NULL, NULL, NULL, NULL) a
inner join
sys.indexes b on a.object_id = b.object_id and a.index_id = b.index_id order by 3 desc;

This is an example script that generates index reorg script.

SELECT ‘alter index [’ + b.name + ‘] on [’ + object_name(b.object_id) + ‘] reorganize’ FROM
sys.dm_db_index_physical_stats(db_id(’MyDb’), NULL, NULL, NULL, NULL) a
inner join
sys.indexes b on a.object_id = b.object_id and a.index_id = b.index_id and b.name is not null where a.avg_fragmentation_in_percent > 50 order by a.index_id, a.avg_fragmentation_in_percent;

Comments

More book giveaway

The first book I co-wrote, on Sql Server Integration Service, has been translated to Chinese. I have about 10 copies to give away.

The second book I co-wrote, on Sql Server 2005 administration, has been translated to Italian. I have 2 copies to give away.

Last time I gave my books away, I took care of everything. And I sent it all over the world. One copy I sent to India was eventually returned. I remember sending one copy to a reader, whose address was something like “The green building about 200 meters away from the central train station”. I couldn’t remember if it was that copy that got returned. Needless to say, it cost me some money to buy the big padded envelopes and stamps, and some time and effort to carry them to the post office and mail them out.

This time, the book is free, provided you pay me back the postage (envelope, stamp). Or, if you live close by in the Chicago area, we can arrange to meet, and I will deliver my book during the meeting. Only readers who know Chinese/Italian need to apply. Email me your info or leave a comment here, with your contact info and which book you are interested in.

The third book I co-wrote, on Sql Server performance tuning, is forthcoming. Not sure how many copies I will get when it publishes.

By the way, do you know that I am a proud owner of a thriving database consulting/training practice? I specialize in Sql Server (admin, automation, performance tuning, high availability/clustering/mirroring). I am also pretty well-versed in MySQL and Oracle. I’d love to help you out with your database needs, either on-site, remotely, or both.

Comments

Sql Server 2005 AWE on Windows 2003 32-bit

Here are steps to enable AWE so that Sql Server 2005 can use additional memory, if your physical memory is more than 4 GB on 32-bit Windows 2003 box.

1. Add /pae at the end of last line inside c:\boot.ini
2. Run gpedit.msc. On the left hand pane, expand Computer Configuration, expand Windows Settings, expand Security Settings, expand Local Policies, select User Rights Assignment
3. On the right hand pane, find Lock pages in memory and double click, then add your Sql Server startup account into Local Security Policy Setting tab;
4. In Sql Server Management Studio, run:
sp_configure ’show advanced’, 1
reconfigure
sp_configure ‘awe enabled’, 1
reconfigure
Ignore the error message below, if you have it.
Msg 5845, Level 16, State 1, Line 1
Address Windowing Extensions (AWE) requires the ‘lock pages in memory’ privilege which is not currently present in the access token of the process.
5. Reboot.

Comments (8)

Back in the U.S.A.

We came back from our family vacation the day before yesterday, currently recovering from jet lag. It was an interesting trip, with a lot of things for me to reflect on. I will probably write more about it, time permitting.

Here are a few pictures. (Flickr is currently blocked by the idiotic and insane GFW. Get a proxy to get around it, very easy to do)

At the Ji Village tablet stone:
Ancestor worship

Game of UNO at my parents’ house:
A round of UNO

A park in my hometown:
Park in front of city government

Meal with high school buddies:
Meal with some high school classmates

The world famous 万亩石榴园:
万亩石榴园

And meal at the Ji Village:
Food

You can see more here, if interested. I will upload and annotate more.

Comments (6)