MySQL Data type changes which index to use

I tracked down a performance issue in my code today that was pretty subtle.

I have a table with a varchar column that contains a number, mainly for size reasons. This column has an index all to itself, so queries using the column should be pretty snappy, but they weren’t.

My code went something like this:

I know I shouldn’t have built the conditions that way, but that’s the way the code was. And the performance sucked!

Why is Facebook always broken?

As far as I can tell, Facebook is always broken. Ok, they do seem to struggle on serving users, but a lot of functionality breaks on Facebook every day. I’ve seen no press on this, I guess the vultures are all circling around Twitter.

Here’s some examples over the last 2 months:

Now, when things break, its usually not all the servers, so some apps for some users will be broken, while others will be working just fine. Facebook does tend to fix these things quite quickly, but I’ve seen very little communication about what is broken when its broken.

It’s always exciting in Facebook Land!

Deleting a Facebook app is far too easy

In the Facebook Developer Application, the act of deleting an application does have a confirmation page, but it isn’t very clear on what application is being deleted – there is the name of the application, but not the picture or icon.

And the delete works even if you have thousands of users.

Ask me how I found this out, I dare you!

Is the Internet the biggest revolution in the last 500 years?

Many would say yes, but Tom Standage would beg to differ in his book “The Victorian Internet”

Mr Standage tells the story of the people who created the telegraph system starting at the end of the 18th century, and leading to Samuel Morse and the first electric system in the US.  He goes into the social aspects of suddenly being able to be in touch across the world, the doom and gloom that came from the newspaper industry, and the rise and fall of the operators of the equipment.

I found out about this book from Rick Segal’s blog The Post Money Value

Facebook Notes: Everyone sees something different

One of the interesting things about Facebook is that, of the interesting pages on Facebook, everyone sees a different version of that page.

Search is clearly filtered to show stuff that is more relevant to you first. Your ‘facebook’ page has stuff filtered out depending on what Facebook thinks is interesting to you (with input from the tiny ‘Preferences’ settings that I expect no-one actually changes)

Search is the tricky one. If someone tells you to type something into Google, you’ll see the same results as them. On Facebook, probably not! This could give Facebook great opportunities for advertising, but their search actually sucks! e.g. I searched for an app the other day and couldn’t find it – I was using the singular form of the name when I should have used the plural. Now I have that app installed, it shows up higher in the search, but now it’s too late.

My latest Rails project is live

December 22, 2007 Link to post  Permalink

I’ve been working on a project for a while. The site has been live for a month or so, and seems to be stable. If you visit my site to read the posts, you may have noticed the top section of the left sidebar has been showing a widget from my new site VideoSlush:

VideoSlush: is a trading game for YouTube videos. You find cool videos that you think may get a lot of views in a short amount of time. You ‘buy’ the video and also take a guess at how many views it may get by noon the next day to earn a bonus. Then you see how your video does over time, using the graphs to see when the price peaks and then selling.

Sign-up is free and open, so check it out.

Making Rails fragment caching usable

December 13, 2007 Link to post  Permalink

Caching is a real pain to get right. Actually, the caching part is quite easy with Rails, its the expiry that causes the trouble. All the simple cases are easy! Its when you have a page with various pieces of data, with different expiry conditions that the trouble starts.

I’ve written some code to use versioning in my fragment cache that is working for my most recent project. This technique relies on using Memcache to work correctly. I’ve been thinking about packaging this up as a plugin and releasing it. Luckily, I never got around to it.

Today, I read this post on how to do better caching. This plugin has documentation and tests, and is easier to configure than mine.

Go check it out.

Rails validates_uniqueness_of is completely broken

December 10, 2007 Link to post  Permalink

If you are using the Rails implementation of validates_uniqueness_of in your model to ensure duplicate data doesn’t get into your database, your application is broken. If you don’t use the database to ensure uniqueness with a key, then your app will fail at some point in the future. Probably just when you start getting some decent traffic and would like the app to not fail.

How do I know this? It happened to me this last weekend.

In checking this out, I find that Michael Koziarski of the Rails core team recently wrote

validates_uniqueness_of gives a nice error message, and does an ok job at guaranteeing uniqueness. Validates uniqueness of + a unique index does both.

Postfix stops working suddenly

November 5, 2007 Link to post  Permalink

Today I had a strange problem. Mail suddenly stopped being processed by my Postfix configuration that’s been running for months. The logs looked fine up until 4:06pm, and then nothing!

Restarting Postfix didn’t make it work either. Google failed to come to my rescue too.

I eventually started thinking about the logging aspect. My Syslog stopped at the same time. Was I out of disk space? Nope. What else?

Eventually, I restarted the syslog daemon (sysklogd on Ubuntu) and it started working again.

Google thinks I'm evil

Some of my sites, including this one, are hosted at Dreamhost. At the beginning of June, Dreamhost had a security lapse (that they have still not explained fully) that allowed someone access to many accounts. It looks like an automated process went looking for index.html and index.cgi files and swapped them out for some Bad Code. Luckily, this attack skipped my Rails sites.

Since my blog was working Ok when I checked, I thought I was in good shape, but it turns out that the part of my site had been compromised. A few weeks later, Google noticed this problem and has marked everything on the domain, including sub-domains, as being harmful.

I think I’ve made all the required changes to clean up the broken hosts, but it will probably take and Google some time to process these changes and unlock me from the world of the undead.