fun with stored procedures

I had some fun today optimizing a stored procedure. It was taking about 10 minutes to run, and I got it down to running in two seconds with a pretty minor change.

Without getting into too many gory details, it was basically doing a somewhat complicated PIVOT. It was using a SUM() call to generate a value that it was really just ignoring, just checking to see if it was null or not. I replaced the SUM() with a COUNT(), and checked for zero instead of null, and bam, 10 minutes down to 2 seconds.

This is the kind of stuff I really like doing — figuring out how to make a minor change in a bit of code that doesn’t affect the output, but results in a measurable improvement in performance. The only thing that’s still a little frustrating about this is that I don’t completely understand why the difference is so great. I have a general idea of why this worked, but something weird must be going on internally with the PIVOT option in MS SQL for this to have made such a huge difference.

my dad

Today is the one-year anniversary of my dad’s death. I considered a few things I might do today to remember and honor him. In the end, I decided to stay home and watch the Giants game, since that’s likely what he’d be doing today if he was still around.

I haven’t been down to my parents’ old house in a few weeks, and I really need to get down there are get some more stuff done, but I couldn’t quite talk myself into going down there today.

time for a new Kindle?

My Kindle 1 may be on its last legs. First, the battery doesn’t last long anymore. If it were only that, I’d just buy a new battery. But it’s also been locking up a lot lately. Thinking that this might just have something to do with my internal memory being almost full, I’ve moved nearly everything to the SD card. And today I deleted the system indexes from both the internal memory and SD card, to force the Kindle to recreate them. No clue if that will help. If it doesn’t, then I guess I’m going to be looking at the Kindle 3.

DropBox

I finally decided to switch from Windows Live Sync (aka FolderShare) to DropBox. I’ve got it installed on my desktop, Dell laptop, MacBook, and Acer netbook now, and I’ve moved everything from FolderShare to DropBox.

The main problem with FolderShare is that it doesn’t actually store any of your stuff, it just enables you to sync a folder between shared computers. So, to sync two computers, for instance, you need to have them both turned on and connected to the internet at the same time. For me, this has been leading to occasional problems, where I wind up with two versions of the same file, or I need to turn on my desktop computer to get the latest version of a file down to my laptop, for instance.

DropBox stores your stuff in the cloud, so it shouldn’t be a problem to get a shared file from one computer to another without needing them both on at the same time. We’ll see how it works in practice, but so far, so good.

Sept 11

I fully intended on ignoring the fact that today is Sept 11. I had a few things lined up to do in the morning, then I was planning on watching some college football in the afternoon. I went out for a haircut this morning, though, and walked past the Sept 11 memorial here in Somerville. There were a bunch of people gathered around it, in silence. I think I walked by after all the official speeches were done. There was something about just seeing the people there, no one really talking, or doing anything, just being there.

When I got to the barber, he had the TV on, set to channel 7, where they were showing the reading of the names at the WTC site. I had about an hour wait before my haircut, so I got to listen to quite a few names being read. Very moving. So my plan to ignore Sept 11 has failed, and I am spending a good bit of time thinking about it now.

Two good articles to read: first, this classic Onion piece: God Angrily Clarifies ‘Don’t Kill’ Rule. The Onion did a great job in the days after 9/11 figuring out how a satirical newspaper / web site could possibly approach such a topic.

Second, this John Hodgman piece at McSweeney’s.

Dad and Mike


Dad and Mike
Originally uploaded by andyhuey

I just finished uploading the third set of photos that I had scanned in by ScanCafe. We’re coming up on the first anniversary of Dad’s passing. It’s hard to believe it’s been almost a year now. There weren’t too many pictures of Dad in this bunch (he was usually the one taking these photos), but here’s a nice one of Dad and Mike, at Mike’s confirmation, outside the church.

Satoshi Kon

I read this morning that Satoshi Kon had passed away. He was only 46. He was a brilliant director and writer. Millennium Actress and Tokyo Godfathers are two of my favorite films of all time. I saw him at Big Apple Anime Fest, probably in 2003, for the first American showing of Tokyo Godfathers. (I remember first seeing Millennium Actress at BAAF also, probably in 2001, but I don’t think he was there for that.) I also got a chance to see him in 2008 for a retrospective at Walter Reade. He seemed like a really nice guy, self-deprecating, but very serious about his work. And he was very Japanese, in a way that’s kind of hard to define, though his work was influenced by both Japanese and American culture. The NY Times obit by A. O. Scott is well-written and I agree with pretty much everything said or quoted therein.

Somerville to join county library system

mycentraljersey.com is reporting that Somerville will be joining the Somerset County library system. I don’t know enough about the history on this to know why we weren’t *always* part of the Somerset County system, but it seems like a reasonable enough thing to do.

I only got my library card a few months ago, despite living in Somerville for more than ten years. And I haven’t actually used the card yet. I have a kind of sentimental attachment to libraries, since I used our public library in Roselle Park quite often as a kid, and because my brother Pat was a librarian.

I get most of my books through BookMooch or SwapTree now, or on the Kindle, so I don’t actually have much use for the library, but I’m glad we have one.

less than helpful naming conventions

I had to do a little debugging work today in a system that I’m not too familiar with. I came across this line of code:

bool result = processor.Process();

If your code has reached the level of abstraction where the most meaningful name you can give a class is “Processor”, and the most meaningful name you can give the main routine in your class is “Process()”, then you may have gotten a little too abstract.