Wednesday, August 22, 2007

So what are the reasons of an ASP.NET restarts?

Under what conditions the ASP.NET application WILL restarts?
So what are the reasons of an ASP.NET restarts?

  • Adding, modifying, or deleting assemblies from the application's Bin folder.
  • Adding, modifying, or deleting localization resources from the App_GlobalResources or App_LocalResources folders.
  • Adding, modifying, or deleting the application's Global.asax file.
  • Adding, modifying, or deleting source code files in the App_Code directory.
  • Adding, modifying, or deleting Profile configuration.
  • Adding, modifying, or deleting Web service references in the App_WebReferences directory.
  • Adding, modifying, or deleting the application's Web.config file.

Tuesday, August 21, 2007

What is the difference between clustered and nonclustered indexes?

There are two types of indexes: clustered and nonclustered indexes.

Clustered index:

A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

A clustered index determines the physical order of data in a table. A clustered index is analogous to a telephone directory, which arranges data by last name. Because the clustered index dictates the physical storage order of the data in the table, a table can contain only one clustered index. However, the index can comprise multiple columns (a composite index), like the way a telephone directory is organized by last name and first name.

A clustered index is particularly efficient on columns that are often searched for ranges of values. After the row with the first value is found using the clustered index, rows with subsequent indexed values are guaranteed to be physically adjacent. For example, if an application frequently executes a query to retrieve records between a range of dates, a clustered index can quickly locate the row containing the beginning date, and then retrieve all adjacent rows in the table until the last date is reached.

Note PRIMARY KEY constraints create clustered indexes automatically if no clustered index already exists on the table and a nonclustered index is not specified when you create the PRIMARY KEY constraint.

Before creating clustered indexes, understand how your data will be accessed. Consider using a clustered index for:

  • Columns that contain a large number of distinct values.
  • Queries that return a range of values using operators such as BETWEEN, >, >=, <, and <=.
  • Columns that are accessed sequentially.
  • Queries that return large result sets.
Clustered indexes are not a good choice for:
  • Columns that undergo frequent changes This results in the entire row moving (because SQL Server must keep the data values of a row in physical order). This is an important consideration in high-volume transaction processing systems where data tends to be volatile

Nonclustered index:

A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

A nonclustered index is analogous to an index in a textbook. The data is stored in one place, the index in another, with pointers to the storage location of the data. The items in the index are stored in the order of the index key values, but the information in the table is stored in a different order (which can be dictated by a clustered index). If no clustered index is created on the table, the rows are not guaranteed to be in any particular order.