My Wonderful Life

Browse through the life of Girish Prabhu

Common mistakes we do in SQL Server Queries.

with one comment

For the last several years I was working with several enterprise applications, obviously that makes me work on MS SQL Server more than any other application or technology. When I speak about Enterprise applications, we have lot of data – millions. So applications built on that size of data need to be very cautious about the queries and performance results of those queries.

I learned so many things and as I was noticing the patterns in SQL Server ‘human-errors’ looked same for several programmers. Smaller steps that you keep in mind can really help you write high performing application. I would like to comment on few points that I noticed to improve the performance of queries.

  1. Make sure you have Indices created for all Join operations – When the huge tables are created and joined with queries, there are possibility that the table gets ‘scanned’ several times for validating all join conditions. So if you create Index for that join field, system will use hashing and will be much faster.
  2. Avoid using cursors – Cursors are real curses. Avoid cursors and use temporary tables if joins are complex. In case you have recursive cursors, you can use Common Table Expressions. These both will give much quicker results than a cursor. 
  3. Avoid views or complicated joins for large tables – When you have a big table containing tens-of-thousands of data and several other tables, the join causes to read through main table several times for each join (even thought is having index). In this case, you can make snapshot of large table in to a small table and then do all the joins with that temp table. For example if you need to prepare reports for year 2009, then get all the data related to 2009 from the large table to the temp table and then join other tables with this temp table.
  4. Avoid update statements even for temp tables – Consider for reports you need to calculate the extended price for the materials sold. I see several people declaring a temp table and then insert the material details and cost in to the temp table. After that they do an update for calculating the extended price = unitprice * qty. Instead you can directly use this as a calculated column in the select statement itself. 
  5. Avoid Delete – Very important. Any delete (physical delete) should be done when there are no much use of the system. So I would suggest to do a batch delete in off-peak hours. When we delete the system internally does so many calculations to verify the foreign keys, validations, recalculation of indexes etc. For a large table a delete can cause deadlock situation if some one else is trying to read from this table during a delete (if delete happens to take time).
  6. Get only what you want – It is a common practice to use Select (*) even though we need just 2 or 3 columns from that table. Even if you take all columns better make it a practice to specify the columns for the select. This way in later stages, you can avoid unwanted fetches even if we add additional columns may be years later. 
  7. Do not copy what is working for another procedure – It is again another common practice that we copy an existing SQL statement or procedure to make a variant of the same (may be for some additional filtering or joins). It is always a wrong practice, I strongly recommend to build the query from scratch, that allows you to revalidate your requirements and take only what you need. 
  8. Do not read table twice – I see several programmers write queries to get the record before we do an update. In a large table this would cost you almost twice the duration.
  9. Have a primary key for all tables – If you donot keep it, better do not program SQL Server :)

There are obviously lot of other performance improvements we can implement. I welcome you if you have any more points to add to this list.

Written by girishsprabhu

April 7, 2010 at 8:19 pm

Being good.

leave a comment »

In Hinduism, there are Devas and Thrimurthis (Super Gods). Devas are considered to be in charge of a function like air, fire, rain, water and other elements and forms. They have much focused ‘job’ and responsibilities for taking this universe ahead. Indra the king of Devas is blessed with lot of wealth, kamadhenu for enough milk, ‘akshaya patra’ for enough food etc. He gets anything he wishes for. But still he always fears and fights ‘Asuras’. He always looks out for ‘Rishi’ that could harm his position. He really worries too much to keep his position as ‘Devendra’. He is the controller of gods of pancha-boothas at the same time; he fears that others may take over the crown.

That is the situation of all businesses today. They always compete each other and fear about their position. The management will do anything to keep their competitive position and profits. Same is the case of humans. There is no value for relation, humanity or anything. All just want is money.

In Shrimath Bhagavatham, Lord Krishna says ‘The one who knows ME, never fear about anything….. Everything happening is for Good.’. He means that he is the supreme God of the universe. All other devas and deities are a form of him. So if we believe in Lord with out any doubts and we should understand that every thing is happening for the ultimate Good; GOD will never let you down for any reason.

For any incident, be it good or bad, you are giving your version that you like to it. God is always with you – in you. When you listen to God the ‘God’ in you reflects to others since you do not commit damages for others; when you don’t you become cruel and a daemon.

You worship Lord Vishnu and if you are near to Lord, then naturally Lakshmi follows God Vishnu. There is another story that if you worship Lord Vishnu and if you win his attention, Lakshmi will give you lot of wealth to make you leave the Lord – her husband. But if you just worship Lakshmi, she would not stay back at your house since she needs to get back to her husband.

The story always has a meaning – Never worship just money. You need to be content. Be it an organization or human being. You do what you are supposed to be doing and be more ‘value-centric’ than ‘profit-centric’. If you are good human being or a business having the values – profit or wealth will follow you..

Written by girishsprabhu

April 6, 2010 at 4:37 pm

Posted in tough time, Trends

Tagged with

See what Hands can do!

leave a comment »

Written by girishsprabhu

September 6, 2007 at 9:39 am

Posted in Fun

Microsoft brings its Web services to Nokia phones

leave a comment »

Nokia is ready to bring Microsoft Corp.’s Windows Live suite of Web services, like e-mail and instant messaging, to many of its cell phones.

Written by girishsprabhu

September 4, 2007 at 6:54 am

Oberoi Udaivilas voted world’s best hotel – survey

leave a comment »

An Indian hotel has won the award for the world’s best hotel for the first time in a survey by an international travel magazine .

Travel + Leisure Magazine released its 12th annual list of the world’s best awards after a poll of almost 19,000 conducted by researcher Harris Interactive.

The Oberoi Udaivilas in Udaipur, a grand setting combined with palatial architecture in heart of Rajasthan was voted the top hotel worldwide.

Prices for a room per night start at about $600 with an exclusive suite with private pool priced from $3,300, according to the hotel’s Web site.

Read more about the story in Reuters site.

Written by girishsprabhu

August 23, 2007 at 9:15 am

Posted in Indian Companies, News

Mail from a frustrated victim of chain mails

leave a comment »

This one is actually another forward sent from one of my contacts; but I liked the mail very much since the following could be anyone among us.

I wanted to thank all my friends and family who have forwarded chain letters to me in 2003 & 2004 & 2005 & 2006

Because of your kindness:

* I stopped drinking Coca Cola after I found out that it’s good for Removing toilet stains.

* I stopped going to the movies for fear of sitting on a needle infected With AIDS.

* I smell like a wet dog since I stopped using deodorants because they cause cancer.

* I don’t leave my car in the parking lot or any other place and sometimes. I even have to walk about 7 blocks for fear that someone will  drug me with a perfume sample and try to rob me.

* I also stopped answering the phone for fear that they may ask me to dial a stupid number and then I get a phone bill from with calls to Uganda, Singapore and Tokyo .

* I also stopped drinking anything out of a can for fear that I will get sick from the rat feces and urine.

* When I go to parties, I don’t look at any girl, no matter how hot she is, for fear that she will take me to a hotel, drug me then take my kidneys and leave me taking a nap in a bathtub full of ice.

* I also donated all my savings to the charitable trust. A sick girl that was about to die in the hospital about 7,000 times. (Poor girl! she’s been 7 since 1993…)!

* I went bankrupt from bounced checks that I made expecting the $15,000 that Microsoft and AOL were supposed to send me when I participated in their special e-mail program would arrive soon.

* My free Nokia phone never arrived and neither did the free passes for a paid vacation to Disneyland .

* Still open to help some from Bulgaria or Nigeria who wants to use my account to transfer his uncle property of some hundred millions $.

* Made some Hundred wishes before forwarding those Ganesh Vandana, Tirupathi Balaji pics etc… now most of those ‘Wishes’ are already married (to someone else) IMPORTANT NOTE: If you do not send this e-mail to at least 11,246 people in the next 10 mins, a bird will SH** on your head today at 6:30pm.

Written by girishsprabhu

August 23, 2007 at 8:59 am

Posted in comedy, Fun

Brijj – One more player in the Social Networking arena

leave a comment »

Info Edge India Ltd, the company which owns job site Naukri.com, has finally launched a professional networking site – Brijj.com (The name is a variation of “Bridge” – as in connecting between two people). Naukri’s new launch comes at a time when professional networking sites like LinkedIn have started gaining a good number of users in India, and it has also been used to generate jobs and business leads. Business Networking is taking huge leap in India recently and it is obivious that leading job portals do not want to loose their customers.

The fear is that classic job site like Naukri may become redundant over time since potential candidates will get the job leads through a networking site or other platforms. So Naukri had to move into the networking space at least to plug that gap.  A big challenge for Naukri will be to build the user base. Will it take the capital intensive, high octane advertising campaign to garner subscribers, or will it free float it and expect to get users on its own? Probably a few free ipods and iphones can get the initial traction. But will that be a valuable user base? Finally, all depends on what features the site provides (I am yet to take a test drive) and the branding. It’s also not clear what will be the target user base.

LinkedIn currently enjoys a mixed userbase of junior-middle-senior tech and finance pros. Unlikely they will shift to a new networking site. A good idea may be to get new users who haven’t tried LinkedIn yet. Brijj as of now, looks just an add on to the existing platform of Naukri, where they brought up the concept of Recommendation and invitation.

Also, techTribe, a networking site for tech professionals which recently got funded by Canaan Partners, has converted itself into a career networking website. Let us see further, how many people will come up with their own Social Networking portals.

Written by girishsprabhu

August 13, 2007 at 11:04 am

Acquisition by Indian companies overseas continue.

leave a comment »

Raman Roy’s (who was heading Spectramind of Wipro earlier) Quatrro BPO Solutions has announced the acquisition of mortgage loan processing operations and the technology platform of US-based Preferred Financial Group, Inc. The financial terms are undisclosed.

The deal is considered unique since Quatrro would become the first BPO from India to offer an onsite-offsite model. This path has already been taken by software services firms. According to Raman Roy, this acquisition will help the company to acquire the technology platform, the people and the origination business of the US partner and that would also enable to provide end-to-end fulfillment services to mortgage lenders across the US.

Apparently this model will hep Quatrro give services at 30 per cent to 50 per cent cheaper than the US costs.  The acquisition will be done by Quatrro Mortgage Solutions, a subsidiary of Quatrro. PFG is a privately-held financial services corporation that originates, underwrites and funds mortgage products.

In April 2007, Quatrro had bought a majority stake in Chennai-based KPO firm Scope eKnowledge for an undisclosed amount. It bought out Mauritius-based fund eIndia’s stake in the 500 people firm.

Written by girishsprabhu

August 8, 2007 at 4:49 am

Wipro acquires Infocrossing, one of the largest IT deal in India

with 2 comments

As rumoured earlier, Wipro Technologies, the global IT services business of Wipro Ltd, has acquired Infocrossing, Inc., a Nasdaq-listed IT infrastructure management company for $600 million in an all cash deal. Wipro will pay $18.70 a share, which is about 13 per cent premium over the six month average of Infocrossing’s share price.
The deal, the largest by Wipro and the largest overseas acquisition by an Indian IT company yet (see the table, bottom), is expected to close by the fourth quarter of 2007.

It also needs regulatory approvals. The deal is also significant since it’s the first acquisition by Wipro of a listed company abroad, which shows that Indian companies are getting better at wading through the complex regulatory hurdles and disclosure norms. Infocrossing had revenues of $232.4 million and net income of $9.3 million for the year ending March 31, 2007.

The company provides integrated managed infrastructure services to global clients. The acquisition will give Wipro Technologies a strong presence in the remote infrastructure management space, by adding five data center locations and about 900 employees in the US, according to Sudip Banerjee, President, Enterprise Solutions of Wipro Technologies. Infocrossing also brings in expertise in health plan and payer management segments. The company has processed over 175 million claims annually and also provides contracted services to over 90 managed care organisations.
The operating margins of Infocrossing is only in the range of 10-14 per cent as against Wipro’s 25 per cent. Apparently, the margin differences will be mitigated in the next 2-3 years, according to company officials. The current global IT infrastructure market is estimated to be around $150 billion, of which the remote infrastructure management services (that can be offshored) will be worth $70 billion, according to NASSCOM.

Written by girishsprabhu

August 7, 2007 at 12:41 pm

Posted in Investments, News

See why I love Hummer!

with 5 comments

Only Hummers can do this !

[Click on Images to view in full size]

hummer1.jpg

hummer2.jpg

Written by girishsprabhu

July 27, 2007 at 6:51 am

Posted in Hummer, Passion

Follow

Get every new post delivered to your Inbox.