lunatechian (lunatech-ian)

one relating to, belonging to, or resembling lunatech

Happy Holi at Stanford, California, USA!

Holi is one of my favourite and I really love all aspects of it - colours, the burning of the bonfire the day before Holi (Holika Dahan), Bhang and the food! I had not had a good Holi celebration after I moved to Bangalore (2005).

However, I had a GREAT Holi yesterday when I joined thousands of others from Bay Area in the Asha Stanford's Holi celebration. I had tons of fun coloring my wife, friends and random folks, having yummy food and enjoying a beautiful day in the sun.

We had planned to take the train to one of our friend's (N) place and then accompany him and his wife to the Holi celebrations. The day started at 8 AM and we had a hiccup when we missed our train to get to our friend's place. We had to wait another hour to catch the next train. However, things started looking better after this incident. We ran into another acquintance Of ours on the train station and they got on the same train as us. We passed them a few tips about which places to visit in San Francisco (they were on their way to SF for some tourism).

We got down at our station and N. came down to pick us up. We went to his house, chit-chatted for a while and then started off for the venue to Stanford.

I was expecting a jolly good time and that is what I got :-) . The holi was in full swing when we got there. One of the playgrounds had been cordoned off for the holi festivities. We took our tickets and jumped into the festivities. There were lots of colors and lots of people. After we had colored each other, we started putting colors on random people. After 30 minutes with colors, it was difficult to recognize each other. There were some dance performances by some Stanford groups. And then the dancing started. And then we put color on more random people. The festivities ended around 3 PM. We had some food and then we came back home. Back home, we had to scrub ourself for around 15 minutes to clean out the colors, but it was a minor hassle.

Overall, I had a very good time and I hope to go back to the Holi celebrations again next year.

Defined tags for this entry: , ,

optmizing ORDER BY in MySQL

A few days back we were trying to optimize a sql query that was using an ORDER BY clause. When we ran an EXPLAIN on the query, we saw that the query was Using filesort and Using temporary. Since this query was run quite frequently, there was a benefit in optimizing this.

I had been under the impression that if your query uses filesort and then has to use temp tables for sorting, you cannot do much to save the query. However, that is not the case. If you have an index on the column being used to do the order by , mysql will use that index for sorting. Of course, there are caveats to this, the most important one being

The key used to fetch the rows is not the same as the one used in the ORDER BY: SELECT * FROM t1 WHERE key2=constant ORDER BY key1;

Hence, if you have a query which requires to be sorted, and it is being run quite frequently, it makes sense to add an index on the column on which you are doing the sort.

Defined tags for this entry: ,