Showing posts with label versus. Show all posts
Showing posts with label versus. Show all posts

Wednesday, March 7, 2012

Deferred Updates versus In-Place Updates

The following question was posted on http://support.microsoft.com/kb/195760/en-us:



Q. What are the conditions under which deferred updates occur in SQL Server 7.0?

A. In SQL Server 7.0, all updates are in-place (direct), provided that the column or columns participating in the clustered index key are not changed. If a change is made to a UNIQUE clustered key, the update plan runs in a hybrid mode where the query processor combines direct and deferred updates. If the clustered key is not UNIQUE, all of the updates are run as deferred.

You can use SHOWPLAN to see examples of how this behavior works. Look for the SPLIT and COLLAPSE operators in the plan. If you find a SPLIT below the clustered index update, one of the clustering keys must have been changed. If a COLLAPSE operator is found, the update is running in a hybrid mode; SQL Server collapses delete and insert to the same key values into an in-place update.

NOTE: This behavior holds true for any index.

Has this behavior changed in SQL Server 2005?

Ken, whenever you are modifying the key columns of an index, the operation will be implemented as a delete followed by an insert, as the row needs to move within the B-Tree from the old location to the new. This can be explictly visible in the query plan showed in SHOWPLAN with the SPLIT operator, or be implicitly performed at the Storage Engine level. In SQL 2005, the number of cases where the SPLIT operator is employed is somewhat decreased, but it is still used. See the following trivial example:

use tempdb
go

create table t(p int primary key clustered)
go

update t set p = p + 1
go

Please let me know if you have more questions on this.
Thanks

|||

Okay, that tells me how changes to the primary key columns will be processed. Now what will happen if only the non-key columns are changed?

Ken

|||When only non key columns are updated, changes are performed in place, i.e. without moving the row inside the B-Tree. This is of course a much cheaper operation. You might want to take a look at a new SQL 2005 feature, the ability to include nonkey columns in nonclustered indexes.

Bottom line: an update statement will not maintain the nonclustered indexes whose columns are not being modified, will trigger row movements inside the indexes whose keys are being updated, and perform in place update to indexes whose only non key columns are being modified.

Deferred Updates versus In-Place Updates

The following question was posted on http://support.microsoft.com/kb/195760/en-us:



Q. What are the conditions under which deferred updates occur in SQL Server 7.0?

A. In SQL Server 7.0, all updates are in-place (direct), provided that the column or columns participating in the clustered index key are not changed. If a change is made to a UNIQUE clustered key, the update plan runs in a hybrid mode where the query processor combines direct and deferred updates. If the clustered key is not UNIQUE, all of the updates are run as deferred.

You can use SHOWPLAN to see examples of how this behavior works. Look for the SPLIT and COLLAPSE operators in the plan. If you find a SPLIT below the clustered index update, one of the clustering keys must have been changed. If a COLLAPSE operator is found, the update is running in a hybrid mode; SQL Server collapses delete and insert to the same key values into an in-place update.

NOTE: This behavior holds true for any index.

Has this behavior changed in SQL Server 2005?

Ken, whenever you are modifying the key columns of an index, the operation will be implemented as a delete followed by an insert, as the row needs to move within the B-Tree from the old location to the new. This can be explictly visible in the query plan showed in SHOWPLAN with the SPLIT operator, or be implicitly performed at the Storage Engine level. In SQL 2005, the number of cases where the SPLIT operator is employed is somewhat decreased, but it is still used. See the following trivial example:

use tempdb
go

create table t(p int primary key clustered)
go

update t set p = p + 1
go

Please let me know if you have more questions on this.
Thanks

|||

Okay, that tells me how changes to the primary key columns will be processed. Now what will happen if only the non-key columns are changed?

Ken

|||When only non key columns are updated, changes are performed in place, i.e. without moving the row inside the B-Tree. This is of course a much cheaper operation. You might want to take a look at a new SQL 2005 feature, the ability to include nonkey columns in nonclustered indexes.

Bottom line: an update statement will not maintain the nonclustered indexes whose columns are not being modified, will trigger row movements inside the indexes whose keys are being updated, and perform in place update to indexes whose only non key columns are being modified.

Saturday, February 25, 2012

default versus named instance with custom app

Are there some general recommendations/guidelines/best practices for choosing to run your custom application against a default or named instance of SQL Server?

We have an application, which in it's stand-alone/local configuration, installs an MSDE default instance if it does not already exist, and runs against this instance. In addition, regardless of whether or not it installs the default instance, it expects to run against the default instance.

We are looking into migrating to SQL Server 2005 Express (Compact almost fits our needs, but not quite), and would like to pay more attention to the best solution regarding the use of instances, default versus named.

Thanks

hi,

1TechZ wrote:

Are there some general recommendations/guidelines/best practices for choosing to run your custom application against a default or named instance of SQL Server?

the "general" recomendation is to use a "standard" named instance named SQLExpress idf you do not need particular custom settings..

We have an application, which in it's stand-alone/local configuration, installs an MSDE default instance if it does not already exist, and runs against this instance. In addition, regardless of whether or not it installs the default instance, it expects to run against the default instance.

this is not a "best practice" behaviour.. users should be able to identify the instance the application should run against..

regards

|||

As Andrea indicated, it will be 'best' you your application has its own instance. That way you will have complete control over the security.

If you use the default instance, or the SQLExpress instance, since the user may have administrator priviledges, he/she may be able to access your database, even altering schema and/or code. Not particularly something you want to have to support.

Default Versus Named Instance

Default uses: Servername
Named uses: Servername\Instancename
Clusters are a whole different beast entirely. Are you on a cluster or
stand-alone?
Kevin Hill
3NF Consulting
http://www.3nf-inc.com/NewsGroups.htm
http://kevin3nf.blogspot.com
"Matt Tinney" <matt.tinney@.css-security.com> wrote in message
news:eeAQaxv$GHA.4292@.TK2MSFTNGP02.phx.gbl...
> When makes an application require the use of a default SQL instance versus
> named instances? If named instances are allowed with an application, how
> does one specify the specific instance to use?
>
> Clusters are a whole different beast entirely. Are you on a cluster or
> stand-alone?
We are talking about connecting to a SQL server instance from a client app;
it should not matter whether or not the SQL instance runs in a cluster.
Linchi
"Kevin3NF" wrote:

> Default uses: Servername
> Named uses: Servername\Instancename
> Clusters are a whole different beast entirely. Are you on a cluster or
> stand-alone?
> --
> Kevin Hill
> 3NF Consulting
> http://www.3nf-inc.com/NewsGroups.htm
> http://kevin3nf.blogspot.com
>
> "Matt Tinney" <matt.tinney@.css-security.com> wrote in message
> news:eeAQaxv$GHA.4292@.TK2MSFTNGP02.phx.gbl...
>
>
|||Except for the Virtual Server name being a required part of the connection
parameters
Kevin Hill
3NF Consulting
http://www.3nf-inc.com/NewsGroups.htm
Real-world stuff I run across with SQL Server:
http://kevin3nf.blogspot.com
"Linchi Shea" <LinchiShea@.discussions.microsoft.com> wrote in message
news:F6590417-338D-4794-B22D-768F497B7857@.microsoft.com...[vbcol=seagreen]
> We are talking about connecting to a SQL server instance from a client
> app;
> it should not matter whether or not the SQL instance runs in a cluster.
> Linchi
> "Kevin3NF" wrote:

Default Versus Named Instance

I think I see what you ar asking.
Without a client side alias to make the ServerName\InstanceName format look
like a default instance, older MDAC versions (2.6 and lower, I think) cannot
connect to a named instance. This is client library issue, not an
application issue.
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"Matt Tinney" <matt.tinney@.css-security.com> wrote in message
news:eeAQaxv$GHA.4292@.TK2MSFTNGP02.phx.gbl...
> When makes an application require the use of a default SQL instance versus
> named instances? If named instances are allowed with an application, how
> does one specify the specific instance to use?
>
An alternative would be to have the server use a dedicated port for the name
instanced, as opposed to dynamic ports, and then specify that in the Data
Source parameter:
MyServer,11291
Anthony Thomas

"Geoff N. Hiten" <SQLCraftsman@.gmail.com> wrote in message
news:eo$acrbAHHA.2328@.TK2MSFTNGP02.phx.gbl...
> I think I see what you ar asking.
> Without a client side alias to make the ServerName\InstanceName format
look
> like a default instance, older MDAC versions (2.6 and lower, I think)
cannot[vbcol=seagreen]
> connect to a named instance. This is client library issue, not an
> application issue.
> --
> Geoff N. Hiten
> Senior Database Administrator
> Microsoft SQL Server MVP
>
> "Matt Tinney" <matt.tinney@.css-security.com> wrote in message
> news:eeAQaxv$GHA.4292@.TK2MSFTNGP02.phx.gbl...
versus
>