<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Alexander Kuznetsov</title><subtitle type="html" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/atom.aspx</id><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/default.aspx" /><link rel="self" type="application/atom+xml" href="http://sqlblog.com/blogs/alexander_kuznetsov/atom.aspx" /><generator uri="http://communityserver.org" version="2.1.61129.1">Community Server</generator><updated>2011-05-12T10:35:00Z</updated><entry><title>Avoiding nested transactions might not improve performance.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/08/avoiding-nested-transactions-might-not-improve-performance.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/08/avoiding-nested-transactions-might-not-improve-performance.aspx</id><published>2012-02-08T18:09:00Z</published><updated>2012-02-08T18:09:00Z</updated><content type="html">Beginning a transaction only when @@TRANCOUNT=0 might not improve performance at all. At least, I did not notice any difference whatsoever. No matter if I use this pattern: BEGIN TRAN ; -- (snip) COMMIT ; or a more complex one: DECLARE @trancount INT ; SET @trancount = @@TRANCOUNT ; IF @trancount = 0 BEGIN ; BEGIN TRAN ; END ; --(snip) IF @trancount = 0 BEGIN ; COMMIT ; END ; the performance stays the same: I was not able to notice any difference. Here are my benchmarks. Prerequisites All we need...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/08/avoiding-nested-transactions-might-not-improve-performance.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=41577" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /><category term="Transactions" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transactions/default.aspx" /></entry><entry><title>Using XACT_ABORT ON may be faster than using TRY...CATCH</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/01/using-xact-abort-on-may-be-faster-than-using-try-catch.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/01/using-xact-abort-on-may-be-faster-than-using-try-catch.aspx</id><published>2012-02-01T22:25:00Z</published><updated>2012-02-01T22:25:00Z</updated><content type="html">To ensure atomicity of transactions, we can use XACT_ABORT ON or wrap the transaction in TRY block and rollback in CATCH block. In some cases, the XACT_ABORT ON approach uses noticeably less CPU. I am posting repro scripts. Please run them, tweak them, and post your findings. Environment I've run my scripts on 2008 R2 Dev Edition. Snapshot isolation is enabled, READ_COMMITTED_SNAPSHOT is not enabled. Test data We are using the same test data as in my previous post: CREATE TABLE dbo.Toggle1 ( id INT...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/01/using-xact-abort-on-may-be-faster-than-using-try-catch.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=41497" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Concurrency" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Concurrency/default.aspx" /><category term="Data Integrity" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Data+Integrity/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /><category term="Transactions" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transactions/default.aspx" /></entry><entry><title>Wrapping related changes in a transaction may use less CPU.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/01/wrapping-related-changes-in-a-transaction-may-use-less-cpu.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/01/wrapping-related-changes-in-a-transaction-may-use-less-cpu.aspx</id><published>2012-02-01T22:02:00Z</published><updated>2012-02-01T22:02:00Z</updated><content type="html">Wrapping related changes in a transaction is a good way to ensure data integrity. Besides, in some cases it just runs noticeably faster, using less CPU. As usual, I am posting repro scripts, which you can run, tweak, and see for yourself. Environment I've run my scripts on 2008 R2 Dev Edition. Snapshot isolation is enabled, READ_COMMITTED_SNAPSHOT is not enabled. Test data After applying Occum's razor, all we need is two tables with one row in each: CREATE TABLE dbo.Toggle1 ( id INT NOT NULL PRIMARY...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/02/01/wrapping-related-changes-in-a-transaction-may-use-less-cpu.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=41495" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Concurrency" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Concurrency/default.aspx" /><category term="Data Integrity" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Data+Integrity/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /></entry><entry><title>Yet another gotcha: variables' scopes do not end where they should.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/25/yet-another-gotcha-variables-scopes-do-not-end-where-they-should.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/25/yet-another-gotcha-variables-scopes-do-not-end-where-they-should.aspx</id><published>2012-01-25T22:09:00Z</published><updated>2012-01-25T22:09:00Z</updated><content type="html">Be careful: unlike most other languages, T-SQL does not limit variables' scope to the block where the variable has been defined. For example, the following snippet compiles and runs: -- @to is not in scope yet -- the line below would not compile --SET @to = @to + 3 ; IF DATEPART ( weekday , GETDATE ()) = 3 BEGIN ; -- the scope of this DECLARE does not end when the block ends DECLARE @from INT , @to INT ; SELECT @from = 5 , @to = 7 ; SELECT Number FROM data.Numbers WHERE Number BETWEEN @from AND @to...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/25/yet-another-gotcha-variables-scopes-do-not-end-where-they-should.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=41315" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="consistency" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/consistency/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /></entry><entry><title>Running OLTPish system without deadlocks, and loving it.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/04/running-oltpish-system-wihtout-deadlocks-and-loving-it.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/04/running-oltpish-system-wihtout-deadlocks-and-loving-it.aspx</id><published>2012-01-04T22:31:00Z</published><updated>2012-01-04T22:31:00Z</updated><content type="html">Our OLTPish mixed load system has not had a single deadlock since last April, and we just love it. I would not make any blanket statements, but I think in our case being deadlock-free just makes a lot of practical sense. Of course, in other cases in might not be worth it. To accomplish deadlock-free state, we have taken the following steps: Snapshot isolation for all readers If concurrent updates are not frequent, we just acquire some exclusive lock before updating. As long as collisions are not...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/04/running-oltpish-system-wihtout-deadlocks-and-loving-it.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=40808" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Concurrency" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Concurrency/default.aspx" /><category term="Deadlocks" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Deadlocks/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /></entry><entry><title>Refactoring large live OLTP tables without downtime</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/03/refactoring-large-live-oltp-tables-without-downtime.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/03/refactoring-large-live-oltp-tables-without-downtime.aspx</id><published>2012-01-03T18:11:00Z</published><updated>2012-01-03T18:11:00Z</updated><content type="html">Refactoring tables does not have to be such a big deal. We do not have to shut modifications down, migrate all data into new structure, deploy modified modules, and do it all at once, while the system is down. Doing all migration at once may be risky, and if we make a mistake, there is no easy rollback to the old version. This is why whenever we need to refactor a large table, we are using an alternative, low-risk, no-downtime, incremental approach. The method I am going to describe has been used...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2012/01/03/refactoring-large-live-oltp-tables-without-downtime.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=40746" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Agile Development" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Agile+Development/default.aspx" /><category term="Refactoring" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Refactoring/default.aspx" /><category term="T-SQL Programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/T-SQL+Programming/default.aspx" /></entry><entry><title>"Trusted" Foreign Keys Allow Orphans, Reject Valid Child Rows</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/10/17/trusted-foreign-keys-allow-orphans-reject-valid-child-rows.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/10/17/trusted-foreign-keys-allow-orphans-reject-valid-child-rows.aspx</id><published>2011-10-17T17:15:00Z</published><updated>2011-10-17T17:15:00Z</updated><content type="html">In SQL 2008 R2, MERGE does not implement foreign keys properly. I will show both false negatives (valid rows are rejected) and false positives - orphan rows that are allowed to save. False Negatives The following tables implement a very common type/subtype pattern: CREATE TABLE dbo.Vehicles ( ID INT NOT NULL, [Type] VARCHAR ( 5 ) NOT NULL, CONSTRAINT Vehicles_PK PRIMARY KEY ( ID ), CONSTRAINT Vehicles_UNQ_ID_Type UNIQUE ( ID , [Type] ), CONSTRAINT Vehicles_CHK_ValidTypes CHECK ( [Type] IN ( 'Car'...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/10/17/trusted-foreign-keys-allow-orphans-reject-valid-child-rows.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=39107" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Data Integrity" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Data+Integrity/default.aspx" /><category term="Defensive programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Defensive+programming/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /></entry><entry><title>Preventing Bob from sales from selecting other people's messages</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/08/18/preventing-bob-from-sales-from-selecting-other-people-s-messages.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/08/18/preventing-bob-from-sales-from-selecting-other-people-s-messages.aspx</id><published>2011-08-18T19:22:00Z</published><updated>2011-08-18T19:22:00Z</updated><content type="html">Suppose that Bob can retrieve all messages, as follows, and we are not happy with it: EXEC Exchange.ShowAllMessages ; Suppose that we don't want him to read anything related to messages, so our knee-jerk reaction is this: REVOKE EXECUTE ON Exchange.ShowAllMessages FROM Bob ; This does not work - Bob still can execute Exchange.ShowAllMessages , just as he could before. The reason is simple: everyone were granted the privilege to execute that procedure: GRANT EXECUTE ON Exchange.ShowAllMessages TO...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/08/18/preventing-bob-from-sales-from-selecting-other-people-s-messages.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37913" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="SQL Server security" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/SQL+Server+security/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /></entry><entry><title>Reads involving UDFs under READ_COMMITTED_SNAPSHOT may seem inconsistent.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/08/02/reads-involving-udfs-under-read-committed-snapshot-may-seem-inconsistent.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/08/02/reads-involving-udfs-under-read-committed-snapshot-may-seem-inconsistent.aspx</id><published>2011-08-03T01:33:00Z</published><updated>2011-08-03T01:33:00Z</updated><content type="html">When a select uses scalar or multi-statement UDFs under READ_COMMITTED_SNAPSHOT, we might not get consistent results as of the time our select began - I will provide simple repro scripts. At the time of this writing MSDN clearly states the following: "Read committed isolation using row versioning provides statement-level read consistency". However, if our select invokes scalar or multi-statement UDFs, this consistency is ensured per a statement in the body of the UDF, not per the whole statement...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/08/02/reads-involving-udfs-under-read-committed-snapshot-may-seem-inconsistent.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37448" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Database Programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Database+Programming/default.aspx" /><category term="Defensive programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Defensive+programming/default.aspx" /><category term="Transact SQL" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Transact+SQL/default.aspx" /></entry><entry><title>Entering TRY blocks is not free, but still several times cheaper than catching exceptions.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/26/entering-try-blocks-is-not-free-but-still-eight-times-cheaper-than-catching-exceptions.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/26/entering-try-blocks-is-not-free-but-still-eight-times-cheaper-than-catching-exceptions.aspx</id><published>2011-07-26T15:15:00Z</published><updated>2011-07-26T15:15:00Z</updated><content type="html">The overhead of entering a TRY block is relatively small, but the overhead of catching an exception is more substantial. If we manage to use CASE or IF to prevent an exception, we can noticeably improve performance. We shall run benchmarks and see for ourselves - i n our example, catching an exception will be approximately nine times more expensive than exiting the TRY block without it. Entering TRY blocks is not free In this section we shall wrap the body of a stored procedure in a TRY CATCH block,...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/26/entering-try-blocks-is-not-free-but-still-eight-times-cheaper-than-catching-exceptions.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37264" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Refactoring" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Refactoring/default.aspx" /><category term="T-SQL Performance" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/T-SQL+Performance/default.aspx" /><category term="T-SQL Programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/T-SQL+Programming/default.aspx" /></entry><entry><title>Comparing the cost of INSERT ... EXEC and its alternatives</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/25/comparing-the-cost-of-insert-exec-and-its-alternatives.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/25/comparing-the-cost-of-insert-exec-and-its-alternatives.aspx</id><published>2011-07-26T00:15:00Z</published><updated>2011-07-26T00:15:00Z</updated><content type="html">It is well known that INSERT ... EXEC is not free, but how expensive is it as compared to its alternatives? We shall run benchmarks and see that: Invoking a multi-statement UDF is approximately two times faster than capturing the output of a stored procedure in a table variable via INSERT ... EXEC; INSERT ... EXEC into a table variable is approximately two times faster than INSERT ... EXEC into a temporary table; Inline UDFs are much cheaper than multi-statement UDFs; The cost of invoking a multi-statement...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/25/comparing-the-cost-of-insert-exec-and-its-alternatives.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37257" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author></entry><entry><title>A free book entitled "Version Control by Example" by Eric Sink is available for download</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/24/a-free-book-about-third-generation-version-control-systems-is-available-for-download.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/24/a-free-book-about-third-generation-version-control-systems-is-available-for-download.aspx</id><published>2011-07-25T01:30:00Z</published><updated>2011-07-25T01:30:00Z</updated><content type="html">I have just downloaded and started reading a free PDF book about version control systems (VCS), entitled Version Control by Example , written by Eric Sink. So far I have read a really informative chapter about the advantages of third generation VCS, such as Git, over the second generation ones, such as Subversion and TFS. So far it is a very nice read. I hope you will like it too....(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/24/a-free-book-about-third-generation-version-control-systems-is-available-for-download.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37279" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Source Control" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Source+Control/default.aspx" /><category term="VCS" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/VCS/default.aspx" /><category term="version control" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/version+control/default.aspx" /></entry><entry><title>More specific queries may run faster, but we should not overdo it.</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/20/more-specific-queries-may-run-faster-but-we-should-not-overdo-it.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/20/more-specific-queries-may-run-faster-but-we-should-not-overdo-it.aspx</id><published>2011-07-21T03:01:00Z</published><updated>2011-07-21T03:01:00Z</updated><content type="html">It is well known that replacing a generic, one-size-fits-all query with several more specific ones may boost performance. However, in some cases these more specific queries do not perform any faster than the generic one. We shall consider several examples which demonstrate both scenarios. Prerequisites The following script creates a table and populates it with 4M rows, not much but enough for our test cases. CREATE TABLE dbo.Packages ( ID INT NOT NULL IDENTITY , [length] INT NOT NULL , width INT...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/20/more-specific-queries-may-run-faster-but-we-should-not-overdo-it.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37182" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Refactoring" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Refactoring/default.aspx" /><category term="T-SQL Programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/T-SQL+Programming/default.aspx" /></entry><entry><title>Will wrapping up code in a reusable stored procedure hurt performance?</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/20/will-wrapping-up-code-in-a-reusable-stored-procedure-hurt-performance.aspx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/20/will-wrapping-up-code-in-a-reusable-stored-procedure-hurt-performance.aspx</id><published>2011-07-20T18:03:00Z</published><updated>2011-07-20T18:03:00Z</updated><content type="html">In T-SQL programming, stored procedure calls are not free, and nested stored procedure calls cost even more. First, we shall prove it by running benchmarks. Next, we shall determine if the cost of calling stored procedures is high as compared to the rest of workload. Proving that stored procedure calls are not free Let us begin with a very simple benchmark, using a trivial stored procedure that increments a variable: CREATE PROCEDURE dbo.IncreaseByOne @i INT OUT AS BEGIN ; SET @i = @i + 1 ; END ;...(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/07/20/will-wrapping-up-code-in-a-reusable-stored-procedure-hurt-performance.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=37162" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author><category term="Refactoring" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/Refactoring/default.aspx" /><category term="T-SQL Programming" scheme="http://sqlblog.com/blogs/alexander_kuznetsov/archive/tags/T-SQL+Programming/default.aspx" /></entry><entry><title>Demos for my today's presentation at SQL Rally</title><link rel="alternate" type="text/html" href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/05/12/demos-for-my-today-s-presentation-at-sql-rally.aspx" /><link rel="enclosure" type="application/octet-stream" length="6776" href="http://sqlblog.com/blogs/alexander_kuznetsov/attachment/35583.ashx" /><id>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/05/12/demos-for-my-today-s-presentation-at-sql-rally.aspx</id><published>2011-05-12T14:35:00Z</published><updated>2011-05-12T14:35:00Z</updated><content type="html">Are attached to this short blog post. Also I have promised to post the following link: This is a benchmark that determines whether SET or SELECT is faster....(&lt;a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2011/05/12/demos-for-my-today-s-presentation-at-sql-rally.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=35583" width="1" height="1"&gt;</content><author><name>Alexander Kuznetsov</name><uri>http://sqlblog.com/members/Alexander+Kuznetsov.aspx</uri></author></entry></feed>
