Vikram Kamath

March 25, 2007

Karaoke evening

Filed under: Fun — Vikram @ 09:56

Yesterday, we had a karaoke and dance evening. It was organised by the GSB community in the UK

I had a go at one of the many bollywood songs. Even Gautham had a go. It was all wonderful. We managed to sing in tune and without missing many beats.

It was an occasion for people from our community to come and meet and have fun.

I have posted some more pictures here.

March 23, 2007

World cup cricket: India out of the world cup

Filed under: Cricket — Vikram @ 21:20

Good riddance to another rubbish from the Indian cricketers until the next world cup.

India are finally out of the world cup after loosing, again pathetically, against the mighty Lankans. Even though Indian bowlers tried to contain them by getting wickets constantly, the batting order were not that lucky. They were set a target of 255 by the Lankans.

Tendulkar, with all his experience, again out on a duck in possibly his last world world cup. Dhoni, what more can be said about him. He was out of the first ball he faced in the match. It was indeed a great ball from Muralitharan. Yuvraj Singh, run out. Sehwag tried his best, but not enough I reckon. Dravid, the captain, tried to glue himself at the crease, was unlucky. Wickets kept falling at the other end. I reckon he lost his calm at one point and started hitting some good strokes taking him to 60 before he was caught my Muralitharan off Jayasurya. After his dismissal, there was no going back. Our tail-enders cannot handle the Lankans by any means. I must commend Harbhajan for his unbeaten 17. Indians were finally bowled out for 185 and were sent packing back home by the mighty Lankans.

The Indians are now on their way back to India. Dravid, needs to answer many questions back home. His captaincy seems to have gone for a toss. He dosen’t have the wao factor that Ganguly had as a captain. Ganguly may not have scored heavily as a captain, but he had the capacity to turn the game around.

Anyways, good riddence to the rubbish cricket from the Indians, at least for this world cup. Who knows whats more to come. India can just hope a miracle to happen. I saw their faces after they lost the match. A sense of shock. They can now just hope against all odds that Bangladesh will loose to Bermuda.

March 21, 2007

Partitioned views: CHECK constraints with NOT FOR REPLICATION clause

Filed under: SQL Server — Vikram @ 17:08

I am posting this entry to remind myself about what happens when you have the NOT FOR REPLICATION clause with a check constraint on a column in a table.

I was going through how data partitioning can be achieved in SQL server 2000/2005. As mentioned in the one the various articles on the internet, the simple way is to create identical tables with the same primary key columns and have a view on top that includes each of the tables with a UNION clause. However that is not the scope of this post.

The scope of this post is the impact on queries on partitioned views by having a check constraint in the underlying partitioned tables and that the check constraints are created with a NOT FOR REPLICATION clause. I have a standalone database without any replication involved. I would do the following for example:

Create two identical tables:

create table [dbo].[Table_1]
(
 [TableID]  INTEGER PRIMARY KEY NONCLUSTERED
                CHECK NOT FOR REPLICATION ([TableID] BETWEEN 1 AND 999),  
 [AnyOtherColumn] int  NOT NULL ,  
) ON [Primary]
GO

create table [dbo].[Table_2]
(
 [TableID]  INTEGER PRIMARY KEY NONCLUSTERED
                CHECK NOT FOR REPLICATION ([TableID] BETWEEN 1000 AND 1999),  
 [AnyOtherColumn] int  NOT NULL ,
) ON [Primary]
GO

Note the NOT FOR REPLICATION clause in the check constraints on the TableID column.

Creating a view on top of that

create view TableView
as
 select * from Table_1
 union all
 select * from Table_2
GO

Now use the following query to see the query execution plan:

select * from TableView where TableID = 10


In SQL server 2000 the query execution would look like this:

In SQL server 2005 the execution plan would look like this:

In both cases you would notice that there is an index scan on both the tables that are part of the view. What would happen if there was no primary key? It would have done a table scan on all the tables. In this example there are only two tables. What would be the performance hit if there are many more tables with huge amount of data in it? The last thing you would want is a table scan on all tables to retrieve just one row.

Now drop the tables and the view and create them again, now without the NOT FOR REPLICATION clause in the check constraint.


create table [dbo].[Table_1]
(
 [TableID]  INTEGER PRIMARY KEY NONCLUSTERED
                CHECK ([TableID] BETWEEN 1 AND 999),  
 [AnyOtherColumn] int  NOT NULL ,  
) ON [Primary]
GO

create table [dbo].[Table_2]
(
 [TableID]  INTEGER PRIMARY KEY NONCLUSTERED
                CHECK ([TableID] BETWEEN 1000 AND 1999),  
 [AnyOtherColumn] int  NOT NULL ,
) ON [Primary]
GO

create view TableView
as
 select * from Table_1
 union all
 select * from Table_2
GO

Now see the execution plan for the same query

select * from TableView where TableID = 10

This is what you see in SQL server 2000:

This is the execution plan on SQL server 2005

The difference this time is that it has done an index seek only on the partition where the data would be present. Since the check constraint on Table_1 allows values for TableID column only in the range of 1 and 999, it picks up data only from that partition table and does not bother looking for it in the other tables in the view.

So, why does the NOT FOR REPLICATION clause on the check constraint reduce the performance of the query so drastically?

Do not use the NOT FOR REPLICATION clause unless you need it.

Now, to add to the fun create the tables again, now with the primary key as clustered and without NOT FOR REPLICATION clause. Run the query execution plan for the same query again.

On SQL server 2000

On SQL server 2005

On both SQL server versions there is a clustered index scan just on the partition that is in the scope of the query.

If any one of you figures out why the NOT FOR REPLICATION on the check constraint makes such a huge query degradation, I would like to know why.

I have opened a thread on the MSDN forum for the same problem. You can find it here.

March 19, 2007

World cup cricket: Comfortable win for India

Filed under: Cricket — Vikram @ 21:31

Virender SehwagIndia played against Bermuda today. The Indian batting line up, after closing a lost chapter against Bangladesh, scored a record breaking total of 413 for the loss of 5 wickets in 50 overs. Sehwag scored the much awaited century. Ganguly added 89, Yuvraj 83 and Tendulkar, an unbeaten 57. Dhoni added a smashing 29 of 25 balls with Dravid finishing the innings with a six. In all a comfortable and a well earned world cup record total. Even if it is against a weaker and inexperienced Bermuda, it is in the history books.

Next was Bermuda with the bat. India had to contain runs and bowl them out for a very low score in order to have a better chance of getting into the super-eights on run rate. Although Bermuda kept loosing wickets constantly, I still felt that the Indians could not contain the runs. They did bowl well, but it did not impress me for their class. Again, a very mediocre performance with the ball. They could not get Hemp out who stuck impressively on the crease scoring an unbeaten 76 runs. He was the only batsman who scored for Bermuda. Bermuda managed to score 156 and dragged until the 44th over.

The Indians did manage a comfortable victory but I feel they could have bowled Bermuda out at a much lower total. India stands second on run rate in its group with three teams (Sri Lanka, Inda and Bangladesh) tied at 2 points each.

March 17, 2007

World cup cricket: Another best of the worst from Indians

Filed under: Cricket — Vikram @ 23:34

Today’s world cup battle against the Bangladeshis turned out to be one of the best of the worst for Indians. They have had a humiliating defeat against the so called “relatively inexperienced” Bangladesh team. I must say, I am not a hardcore cricket enthusiast, but I try and keep myself updated with the latest. I happened to see the match today. I started watching when Indians were playing at 90 for the loss of 4 wickets and Saurav Ganguly and Yuvraj Singh were at the crease. Looking at the Indian scorecard, they seemed to be on the loosing front right from the beginning. Sehwag, Tendulakar, Dravid, all back in the pavilion.

Although, Ganguly and Yuvraj, seemed to stabilize the situation for India at one point of time, all that was washed away when Yuvraj got out at 47, followed by Ganguly, Dhoni, Harbhajan and Agarkar in a span of just 2 runs. Ultimately, the Indians were bowled out at a total of 191 runs, thanks to some good and some lucky strokes by Zahir Khan and Munaf Patel at the end with both adding 15 runs each.

Then came the so called “relatively inexperienced” Bangladeshis with the bats. They, had nothing much to do I reckon, except for playing calmly and not loosing early wickets. The Indian bowling attack was not that great. Very mediocre for their experience in the game. Even, Bhajji didn’t seem do any magic with the “doosra” nor did Tendulkar, compared to the spinning attack by the Bangladeshis. This allowed the Bangladeshis to reach their target calmly with the loss of 5 wickets in the 49th over.

In all the Bangladeshis had a historic win against the Indians today. What happened to the Indians in the field today? They seemed to be showing no contention even whilst fielding. The Indians have been totally outplayed by the Bangladeshis in all respect in the field today.

India still has hopes of making up to this loss.

But the first major upset in this tournment is that Pakistan is out of contention for the world cup 2007. They lost against Ireland today. It was another major upset, worse than India’s loss against Bangladesh. The Pakistanis were surprisingly bowled out for just 132 on board. Ireland, being supposedly made up of amateur cricketers, crawled to victory to reach a revised target of 128 in 47 overs. This match ended with a six by Trent Johnston of Azhar Mahmood. Again, a historic win for the Irish in world cup cricket. They are probably through to the Super-Eights, while the Pakistanis are on their way home.

Sadly, there won’t be the India -Pakistan clash in this world cup. Hope India fairs well. Come on India!!!!!!

March 8, 2007

Cumulative hotfix for SQL Server 2005 SP2 is now available

Filed under: SQL Server — Vikram @ 23:15

Cumulative hotfix package (build 3152) for SQL Server 2005 Service Pack 2 is available.

 For more information about the bug fix list, follow the link.

Not long since SP2 was released.

Create a free website or blog at WordPress.com.