Wednesday, March 19, 2014
Sunday, March 9, 2014
Big Data - My Journey
I have just started the journey in Big data. While reading hadoop I have decided to setup hadoop in Ubuntu. After couple of tries,I came across an article in the below url, which works 100 %
http://goo.gl/F9gudz
Thanks Udemy and Nitesh Jain.
http://goo.gl/F9gudz
Thanks Udemy and Nitesh Jain.
Saturday, August 20, 2011
Out of memory exception Why and How ?
We often encounter out of memory exception while working with .net application (or in real life
Asks by wife!). In a 32 bit environment , by default 2 GB virtual memory is available apart from
Physical RAM memory . It should be noted that all 2 GB can not be utilized.
AS there are free, reserved and committed states in virtual memory and if we run out of virtual address space to further reserve or physical space to commit
The following link got more details
Friday, April 1, 2011
April Fool - Gmail Motion this year's hoax
Gmail Motion is this year's April Fool hoax.
But it will be nice if we have this feature in Gmail :)
Enjoy watching
But it will be nice if we have this feature in Gmail :)
Enjoy watching
Funny Side -- What if Kollywood heros handle IT Project
What if Tamil Heros handle IT Project.
First comes 'Captain' Visaya kanth as Project manager.
Project Meeting starts
(Please read numbers in tamil)
Intha project'la mottham 1,19,738 line code irukku,athula naama eluthunathu 45,434 line, athula 30,114 line comments mattum outsource pannathu 74,304 line, athula 52,314 line comment.
Intha project armbichapo iruntha team size 54 paer, naduvula velaya vittu ponavanga 13 paer,
Deadline meet panna velaiku saertha consultants 10 paer, employees 24 paer.Intha project armbichapo athoda cost Rs53,45,645. 36P.Mudikira po athoda cost Rs353,23,617. 28P.
Aga mottham ellaruma saenthu en thalayila molaga arachuttaanga SIR !!!(with emotion).
Enakku intha softwarea venam, naan pakistan poyi thiviravaatheengala shoot panna poraen. GOOD BYEE
(Captain walks out of conference rooom, All Directors bow there head in shame & in a state of shock).
Now, Superstar is Another project manager
Kanna, intha bugnrathaey softwarela irukka koodathu,athu intha badshahvuku pudikathu.
'Oru bug iruntha, athula nooru bug irukkunu artham'.
Kanna, bug iruntha enna kuppidu, summa paranthu bug ellam fix pannirraen
Customer sollraen(bug), Arunachalam fix panran
Superstar explains Project life cycle to new hires
Kanna, project life cyclenrathu Annamalai' cycle illa, athu vera,ithu vera. Ippudu soodu
Ra, Ramiah, 8ttukulla project irukku ramiah,8,8, Projecta pirichukko, ippo intha 8'll irukka therijukko.
Modha 8'll nee seiyadadhu conceptualization alla,Raendam 8'll seiyadadhu MRD(Mktg. Req. Doc) alla. (Ra, Ramiah..chorus)
Moonam 8'll seiyadadhu TLD(Top Level Design) alla.Nee, Naangam 8'll seiyadadhu implementaionum alla. (Ra, Ramiah..chorus)
Aintham 8'll seiyadadhu testingum alla,Aram 8'll seiyadadhu releasum alla,
(Ra, Ramiah..chorus)
Yelaam 8'llseiyadadhu bug fixingum alla,Nee ettam 8'll inrutha nimmadhi alla(Maintenance),
(Ra, Ramiah..chorus)
Ettu Etta Project life pirichiko, ippo intha 8'll irukka therijukko.Ra, Ramiah, 8ttukulla project irukku ramiah
(Ra, Ramiah..chorus)
Now comes, 'Padma Shri' Kamal Haasan
Ennathu customer kitta irunthu buga??
'Haan, Haan', Aiyo kadavulae,...............
(Now starts going in circles in the conference room)
Intha project asingham, asingham,Design asingham, implementation asingham,Abiramiya (Sr. Proj. Mgr) Pakkanum,Angae pentathol maram ellam irukkum, malai mela poganum (Onsite),
Appo thaan intha project vera managerukku pogum.
Abirami, Abirami
(Finally faints)
Next, 'Navarasa Nayagan' Karthik in project discussion
Intha Project irukku paaru, athu intha rose mathiri, alagha, namma rambha(team member) illa,
rambha mathiri irukkum..(slowly walks to her & wisks her away to ooty for
further dicussion)
Vaigai Puyal Vadivelu
(Project is released and full of bugs, Surya, Vijay, Ramesh krishna &
charlie
(Friends) are his project members)
V:Dei inga vaangada..nee poyi irukura ella bug'um fix pannu.
(Surya&;Vijay follow ramesh krishna).
V:DEI!! neenga engada Poringaa ??
S &; Vij:Bug fix panna..
V:Ithu varaikum introduce panna bug pothum, Onnum fix panna venam.
(S,Vijay & RK return)
V:Dei, nee yaenda vanthaey ??
RK:Neenga thana sir, bug fix panna vaenamnu soneenga..
V:Bug fix panna venamnu sonnathu avangala, Unnai Illa.
(RK goes to fix bugs)
RK:High priority bug, low priority bug ethunu eppadi kandu pudikirathu
V:Nee fix panra ellamae, high priority bug thaan.
V:Neenga inga vaangada (Suriya and Vijay follow him)
V:(Vijay)Dei, nee ivan kooda poyi debugging pannu (Vijay Leaves)
V:Nee en kooda vaa (Suriya, follows)
V:Antha buga open pannu
S:(Opens the bug, and starts typing code slowly)
V:Pathu, Keyboarduku valikumla, methuva pathu
V:Vegama type panni tholada
Thursday, March 31, 2011
Alternate for Cursors in SQL Server
T-SQL provides us with a CURSOR statement to work on the data on a row-by-row basis. Cursors are especially handy when you are using OUTPUT stored procedures and need to pass one ID to the stored procedure at a time. However, this kills the whole theory of set-based operations, which are inherently faster than their row based counterparts. The following is one way of converting your CURSOR statement using the WHILE keyword in such a scenario
Suppose you have the following SQL statement:
Suppose you have the following SQL statement:
DECLARE @item_category_id INT
DECLARE @order_id INT
DECLARE @purchase_order_id INT
DECLARE item_cursor CURSOR FAST_FORWARD FOR
SELECT
it.item_category_id
,ord.order_id
FROM dbo.item_categories it
INNER JOIN dbo.orders ord
ON ord.item_category_id = it.item_category_id
WHERE ord.order_date >= '1-sep-05'
and it.isSuspended != 1
OPEN item_cursor
FETCH NEXT FROM item_cursor INTO
@item_category_id
,@order_id
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC dbo.usp_generate_purchase_order @item_category_id, @order_id, @purchase_order_id OUTPUT
/*
Call other code here to process your purchase order for this item
*/
FETCH NEXT FROM item_cursor INTO
@item-category_id
,@order_id
END
Now here is the code, which does not use a CURSOR but achieves the same result using a WHILE loop. The key here is to get all the item categories which fit our WHERE clause into a memory table and use the Primary Key of this table to pick up each successive item category.
--Declare variables
DECLARE @item_category_id INT
DECLARE @order_id INT
DECLARE @purchase_order_id INT
--Declare a memory table
DECLARE @item_table TABLE (primary_key INT IDENTITY(1,1) NOT NULL, --THE IDENTITY STATEMENT IS IMPORTANT!
item_category_id INT,
order_id INT
)
--now populate this table with the required item category values
INSERT INTO @item_table
SELECT -- Same SELECT statement as that for the CURSOR
it.item_category_id
,ord.order_id
FROM dbo.item_categories it
INNER JOIN dbo.orders ord
ON ord.item_category_id = it.item_category_id
WHERE ord.order_date >= '1-sep-05'
and it.isSuspended != 1
DECLARE @item_category_counter INT
DECLARE @loop_counter INT
SET @loop_counter = ISNULL(SELECT COUNT(*) FROM @item_table),0) -- Set the @loop_counter to the total number of rows in the
-- memory table
SET @item_category_counter = 1
WHILE @loop_counter > 0 AND @item_category_counter <= @loop_counter
BEGIN
SELECT @item_category_id = item_category_id
,@order_id = order_id
FROM @item_table
WHERE primary_key = @item_category_counter
--Now pass the item-category_id and order_id to the OUTPUT stored procedure
EXEC dbo.usp_generate_purchase_order @item_category_id, @order_id, @purchase_order_id OUTPUT
/*
Call other code here to process your pruchase order for this item
*/
SET @item_category_counter = @item_category_counter + 1
END
This gives about 75 % performance increase
Wednesday, March 30, 2011
SQL Server 2008 New Features
New features in SQL SERVER 2008
Analysis Scale and Performance
SQL Server 2008 drives broader analysis with enhanced analytical capabilities and with more complex computations and aggregations. New cube design tools help users streamline the development of the analysis infrastructure enabling them to build solutions for optimized performance.
Star Join Query Optimizations
SQL Server 2008 provides improved query performance for common data warehouse scenarios. Star Join Query optimizations reduce query response time by recognizing data warehouse join patterns.
Partitioned Table Parallelism
Partitions enable organizations to manage large growing tables more effectively by transparently breaking them into manageable blocks of data. SQL Server 2008 builds on the advances of partitioning in SQL Server 2005 by improving the performance on large partitioned tables.
Integrated Full Text Search
Integrated Full Text Search makes the transition between Text Search and relational data seamless, while enabling users to use the Text Indexes to perform high-speed text searches on large text columns.
DATE/TIME
SQL Server 2008 introduces new date and time data types:
DATE—A date-only type
TIME—A time-only type
DATETIMEOFFSET—A time-zone-aware datetime type
DATETIME2—A datetime type with larger fractional seconds and year range than the existing DATETIME type
MERGE SQL Statement
With the introduction of the MERGE SQL Statement, developers can more effectively handle common data warehousing scenarios, like checking whether a row exists, and then executing an insert or update.
Enhanced Database Mirroring
SQL Server 2008 builds on SQL Server 2005 by providing a more reliable platform that has enhanced database mirroring, including automatic page repair, improved performance, and enhanced supportability.
Transparent Data Encryption
Enable encryption of an entire database, data files, or log files, without the need for application changes. Benefits of this include: Search encrypted data using both range and fuzzy searches, search secure data from unauthorized users, and data encryption without any required changes in existing applications.
Analysis Scale and Performance
SQL Server 2008 drives broader analysis with enhanced analytical capabilities and with more complex computations and aggregations. New cube design tools help users streamline the development of the analysis infrastructure enabling them to build solutions for optimized performance.
Star Join Query Optimizations
SQL Server 2008 provides improved query performance for common data warehouse scenarios. Star Join Query optimizations reduce query response time by recognizing data warehouse join patterns.
Partitioned Table Parallelism
Partitions enable organizations to manage large growing tables more effectively by transparently breaking them into manageable blocks of data. SQL Server 2008 builds on the advances of partitioning in SQL Server 2005 by improving the performance on large partitioned tables.
Integrated Full Text Search
Integrated Full Text Search makes the transition between Text Search and relational data seamless, while enabling users to use the Text Indexes to perform high-speed text searches on large text columns.
DATE/TIME
SQL Server 2008 introduces new date and time data types:
DATE—A date-only type
TIME—A time-only type
DATETIMEOFFSET—A time-zone-aware datetime type
DATETIME2—A datetime type with larger fractional seconds and year range than the existing DATETIME type
MERGE SQL Statement
With the introduction of the MERGE SQL Statement, developers can more effectively handle common data warehousing scenarios, like checking whether a row exists, and then executing an insert or update.
Enhanced Database Mirroring
SQL Server 2008 builds on SQL Server 2005 by providing a more reliable platform that has enhanced database mirroring, including automatic page repair, improved performance, and enhanced supportability.
Transparent Data Encryption
Enable encryption of an entire database, data files, or log files, without the need for application changes. Benefits of this include: Search encrypted data using both range and fuzzy searches, search secure data from unauthorized users, and data encryption without any required changes in existing applications.
Tuesday, March 29, 2011
Could not record and playback Coded UI test for web part enabled ASP.Net application
Today one of the interesting problem was reported by our test team. They were facing issues while playing back the recorded coded UI automated test scripts. One of the application they were trying to automate was built with webparts.
Because of this test script written by one tester , could not be executed by other so team member.
After examining the source of html, we found that personalization db causing control id to generate different for different users.
Workaround :
After dwelling hours we decided to go with with workaround.
ie To swap user id between recorded tester with the one who is going to execute the script.
using the following update statement.
use aspnetdb
Go
update aspnet_users set username = 'executerid' ,loweredusername='executerid'
where username='recorderid'
Monday, March 28, 2011
What's New on SharePoint 2010
SharePoint is always a flagship MS Product. And 2010 adds more feathers to its crown.
From Integration of Peformance Point Server to use of Powershell in SharePoint administration, Microsoft added so many new features to SharePoint 2010. Visit dedicated MSDN link for more details.
Now I have added SocialVibe in my blog. Just do someactivty so that some money will go to Childrens of War.
Sunday, March 27, 2011
SQL Server transaction isolation level
Application developers who work in an environment where users retrieve data while others save/update data are probably familiar with the challenges of concurrency and isolation levels.
In this article, I'll cover the following:
- What are Isolation Levels in general?
- An overview of the Isolation Levels in SQL Server prior to SQL Server 2005
- The new Snapshot Isolation Level and how it improves on the existing Isolation Levels
1 - What are Isolation Levels?
Isolation levels in SQL Server are the specific mechanisms that allow transactions to run in isolation of each other, with rules for each specific level. Each specific isolation level carries rules: these rules include locking of rows and accepting (nor not accepting) inconsistent data across transactions. Each level takes and holds shared locks on data during SELECT read statements.
2 - Isolation Levels in SQL Server 2000
SQL Server 2000 provides four isolation levels. Each of the four isolation levels implements a progressively stricter set of rules.
- READ UNCOMMITTED (Dirty read)
- READ COMMITTED (SQL Server default)
- REPEATABLE READ
- SERIALIZABLE
READ UNCOMMITTED is the lowest and least restrictive isolation level. When using this level, I can query the value of a row/column that is in the middle of a transaction but not yet completed. For instance, take a look at the following tasks:
User 1 | User 2 |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL READUNCOMMITTED BEGIN TRAN UPDATE Production.Product SET Name = 'Super Blade' WHERE ProductID = 316 -- was previously 'Blade', now 'Super Blade' | |
| USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRAN SELECT Name from Production.Product WHERE ProductID =316 -- WILL RETURN 'Super Blade', even before committing transaction, | |
| COMMIT TRANSACTION |
In both tasks, I set the transaction isolation level to READ UNCOMMITTED. In task 1, I update the value of a row from 'Blade' to 'Super Blade'. But before I commit the transaction, I query the table in another task, and I return the new updated value, even though I have not yet committed the transaction in task 1. This is because the isolation level allows me to read uncommitted data. This is why some refer to this isolation level as a "Dirty Read". You should only use this isolation level (which, in effect, provides no real isolation with other transactions) if you need to get the most immediate feedback possibly from a query, and when accuracy is not absolutely critical.
If I modify the code above to use the READ COMMITTED isolation level (which is the default SQL Server isolation level), the code for user 2 will result in a deadlock on the SELECT statement until the COMMIT TRANSACTION for User 1 executes. This is because the READ COMMITTED isolation level can only read COMMITTED data. Since the Transaction and UPDATE statement for User 1 perform an exclusive LOCK on the row, the SELECT statement for User 2 will be in a "deadlock" condition until the COMMIT occurs for User 1.
User 1 | User 2 |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL READCOMMITTED BEGIN TRAN UPDATE Production.Product SET Name = 'Super Blade' WHERE ProductID = 316 -- was previously 'Blade', now 'Super Blade' | |
| USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL READ COMMITTED BEGIN TRAN SELECT Name from Production.Product WHERE ProductID =316 -- Deadlock until the COMMIT finishes for User 1 | |
| COMMIT TRANSACTION | |
-- Lock is released, and now will finally return 'Super Blade' |
Many developers are satisfied with the behavior of the READ COMMITTED level. However, consider the following scenario: User 2 needs to query the same row twice in a stored procedure. In between the two queries, User 1 updates the specific row. User 2 will receive a different result the second time, because the READ COMMITTED level does not isolate User 2 from the update performed by User 1. This situation is referred to as a non-repeatable read. If you need for User 2 to read the same piece of data both times and return the same result, and not allow User 1's UPDATE to complete until User 2's queries complete, you can use the Isolation level calledREPEATABLE READ.
User 1 | User 2 |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL REPEATABLE READ BEGIN TRAN SELECT Name from Production.Product WHERE ProductID= 316 -- returns 'Blade' | |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL REPEATABLEREAD BEGIN TRAN UPDATE Production.Product SET Name = 'Super Blade' WHERE ProductID = 316 -- Deadlock, because User 2 still has the row | |
SELECT Name fromProduction.Product WHERE ProductID =316 -- Will still return 'Blade' | |
-- Still in deadlock until User 2 commits the transaction | |
COMMIT TRANSACTION | |
-- UPDATE completes we can COMMIT COMMIT TRANSACTION |
As you can probably imagine, the REPEATABLE READ isolation level holds locks on data until the transaction completes. This can affect operations that need to do multiple updates, which many impact performance. So this level should be used carefully.
The REPEATABLE READ level protects User 2 from any outside changes to data. However, suppose User 2 wanted to query on a range of products twice within a stored procedure, while User 1 inserted a new row (that matches the range) in between the two queries. This is a PHANTOM record, which User 2 may not wish to see if it changes the results from the first query to the second. This brings us to the last (and highest) isolation level, theSERIALIZABLE isolation level. A SERIALIZABLE isolation level will lock out any insertions that would match the range, until the other transaction is committed:
User 1 | User 2 |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVELSERIALIZABLE BEGIN TRAN SELECT COUNT(*) FROM Production.Product WHERESafetyStockLevel = 500 -- returns 167 | |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRAN INSERT INTO Production.Product (ProductName,ProductNumber, SafetyStockLevel....) VALUES ('111','TEST111',500....) -- Deadlock, because this would affect the rowcount for User 2 | |
SELECT COUNT(*) FROM Production.Product WHERESafetyStockLevel = 500 -- STILL returns 167 | |
-- Still in deadlock until User 2 commits the transaction | |
COMMIT TRANSACTION | |
-- INSERT completes we can COMMIT COMMIT TRANSACTION | |
SELECT COUNT(*) FROM Production.Product WHERESafetyStockLevel = 500 -- NOW returns 168 |
As you can see from the code above, the SERIALIZABLE isolation level locks out any attempts to insert new data that matches the query of a transaction that would include the new insertion. It does so through the use of key-range locks. Once again, this level should be used carefully, as it also uses locks and resources.
3 - The new SNAPSHOT ISOLATION LEVEL in SQL Server 2005
SQL Server 2005 adds a fifth isolation level, called the SNAPSHOT Isolation Level. Books Online describes this new level as "non-blocking READ COMMITTED". The level prevents queries from reading "dirty data", but also allows you to query data without using shared locks. The level does this by taking a "snapshot" (thus the name of the isolation level) into the tempDB database, This allows a developer to query against a specific version of the data throughout the entire transaction, without needing to wait for any other locks to clear, and without reading from any "dirty data".
Before using this new isolation level, you must first configure the specific database, as follows:
ALTER DATABASE AdventureWorks
SET ALLOW_SNAPSHOT_ISOLATION ON
GO
SET ALLOW_SNAPSHOT_ISOLATION ON
GO
After you configure the database, you can use the SNAPSHOT ISOLATION level as follows:
User 1 | User 2 |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE Production.Product SET Name = 'Super Blade' WHERE ProductID =316 -- was previously 'Blade', now 'Super Blade' | |
USE AdventureWorks GO SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT Name from Production.Product WHERE ProductID =316 -- Still 'Blade' | |
COMMIT TRANSACTION | |
SELECT Name from Production.Product WHERE ProductID =316 -- Still 'Blade' COMMIT TRANSACTION SELECT Name from Production.Product WHERE ProductID =316 -- NOW it's 'Super Blade' | |
In the code above, User 2 retains the original value ('version') of 'Blade', until we commit the transaction BOTH for User 1 and then User 2.
Subscribe to:
Posts (Atom)