Thursday, January 10, 2013

INDEXS in SQL SERVER

A SQL table explanation is not good enough for getting the desired data very quickly or sorting the data in a specific order.

What we actually need for doing this is some sort of cross reference facilities where for certain columns of information within a table, it should be possible to get whole records of information quickly. But if we consider a huge amount of data in a table, we need some sort of cross reference to get to the data very quickly. This is where an index within SQL Server comes in.

So an index can be defined as:
  • “An index is an on-disk structure associated with a table or views that speed retrieval of rows from the table or view. An index contains keys built from one or more columns in the table or view”. These keys are stored in a structure (B-tree) that enables SQL Server to find the row or rows associated with the key values quickly and efficiently.”

Index Structures

For example, if you create an index on the primary key and then search for a row of data based on one of the primary key values, SQL Server first finds that value in the index, and then uses the index to quickly locate the entire row of data. Without the index, a table scan would have to be performed in order to locate the row, which can have a significant effect on performance.

An index is made up of a set of pages (index nodes) that are organized in a B-tree structure. This structure is hierarchical in nature, with the root node at the top of the hierarchy and the leaf nodes at the bottom, as shown in Figure below.
 
Figure : B-tree structure of a SQL Server index

When a query is issued against an indexed column, the query engine starts at the root node and navigates down through the intermediate nodes. The query engine continues down through the index nodes until it reaches the leaf node.

Clustered Indexes

A clustered index stores the actual data rows at the leaf level of the index. Returning to the example above, that would mean that the entire row of data associated with the primary key value of 123 would be stored in that leaf node.

An important characteristic of the clustered index is that the indexed values are sorted in either ascending or descending order.  As a result, there can be only one clustered index on a table or view. In addition, data in a table is sorted only if a clustered index has been defined on a table.

Indexes are first sorted on the first column in the index, then any duplicates of the first column and sorted by the second column, etc.

Nonclustered Indexes

In non-clustered index the leaf nodes of a nonclustered index contain only the values from the indexed columns and row locators that point to the actual data rows, rather than contain the data rows themselves. This means that the query engine must take an additional step in order to locate the actual data.

A row locator’s structure depends on whether it points to a clustered table or to a heap.
1. If referencing a clustered table, the row locator points to the clustered index, using the value from the clustered index to navigate to the correct data row.
2. If referencing a heap, the row locator points to the actual data row. 

(Note: A table that has a clustered index is referred to as a clustered table. A table that has no clustered index is referred to as a heap.)

 --> Nonclustered indexes cannot be sorted like clustered indexes.

Max number of clustered index in table: 1

Max number of non-clustered index in table: 
  1. In sql server 2005- 249 
  2. in sql server 2008- 999
 Composite index:
 An index that contains more than one column. In both SQL Server 2005 and 2008, you can include up to 16 columns in an index.

 Consider the following guidelines when planning your indexing strategy:

1. For tables that are heavily updated, use as few columns as possible in the index, and don’t over-index the tables.



2. If a table contains a lot of data but data modifications are low, use as many indexes as necessary to improve query performance.

3. For clustered indexes, try to keep the length of the indexed columns as short as possible.

4. The uniqueness of values in a column affects index performance. In general, the more duplicate values you have in a column, the more poorly the index performs.

5. In multi-column indexes, list the most selective (nearest to unique) first in the column list. For example, when indexing an employee table for a query on social security number (SSN) and last name (lastName), your index declaration should be:

CREATE NONCLUSTERED INDEX ix_Employee_SSN
ON dbo.Employee (SSN, lastName);

Syntax:

Create Clustered Index index_name on table_name (Columns_name)

CREATE NONCLUSTERED INDEX ix_Employee_SSN
ON dbo.Employee (SSN, lastName);

 Disadvantages:

1. Both clustered indexes, and nonclustered indexes take up additional disk space. The amount of space that they require will depend on the columns in the index, and the number of rows in the table.

2. Indexes will increase the amount of time that your INSERT, UPDATE and DELETE statement take, as the data has to be updated in the table as well as in each index.

3. Columns of the TEXT, NTEXT and IMAGE data types can not be indexed using normal indexes. Columns of these data types can only be indexed with Full Text indexes.

Disadvantage for Clustured Index:

If we update a record and change the value of an indexed column in a clustered index, the database might need to move the entire row into a new position to keep the rows in sorted order. This behavior essentially turns an update query into a DELETE followed by an INSERT, with an obvious decrease in performance. A table's clustered index can often be found on the primary key or a foreign key column, because key values generally do not change once a record is inserted into the database.

Disadvantage for NonClustured Index :

The disadvantage of a non-clustered index is that it is slightly slower than a clustered index and they can take up quite a bit of space on the disk.

Another disadvantage is using too many indexes can actually slow your database down. Thinking of a book again, imagine if every "the", "and" or "at" was included in the index. That would stop the index being useful - the index becomes as big as the text! On top of that, each time a page or database row is updated or removed, the reference or index also has to be updated.

The DROP INDEX Command:

An index can be dropped using SQL DROP command. Care should be taken when dropping an index because performance may be slowed or improved.
The basic syntax is as follows:
DROP INDEX index_name;

Monday, June 25, 2012

Hidden Treasure: Cricket team at IDS Infotech Limited.

Team Members :
  1. Akhilendu Shukla (Team Owner)  -Allrounder
  2. Deepali Kakkar (Vice-Captian)- Allrounder
  3. Nitin Kumar  - Wicket-Keeper/ Batsman
  4. Arun Sharma*- All-rounder
  5. Rajiv Kumar  - Allrounder
  6. Rohit Gandhi -  Allrounder
  7. Rishab Sharma - Allrounder
  8. Vivek Kumar - Allrounder
  9. Ravi Mittal - Allrounder
  10. Rajesh Bhatia - Allrounder
  11. Navneet Singh -  Allrounder
  12. Parvesh Kumar (Strategic Partner) 
Hidden Treasure

IDS Infotech Cricket team: Hidden Treasure
  
Play in progress at IDS infotech SSB Cricket League

Team Hidden Treasure

Wicket Keeper of hidden treasure



Wednesday, June 20, 2012

Aeron chairs with innovative mechanisms

Aeron chairs have taken the world by storm and are a choice of millions and millions of people around the world. They are especially the favorite of office goers as comfort is their top priority in midst of so much work load and the challenges that are posed to the body because of the pressure put on them. The ordinary chairs do not care or pay attention to the discomfort that is caused to their body and this is when aeron chairs prove to be a boon to them. There are so many advantages and functions of aeron chairs. To start with, they are super comfy and so light that you would not even feel that there is a chair beneath you. They facilitate the movement of your body in a way that no other ordinary chair does and help you stay active throughout the day. The wheels provided beneath them help you to move to and fro without getting up from the chair too much and therefore are so comfortable that you wouldn’t want to leave them. The head rest too keeps your neck straight and saves it from any pain or pressure and therefore takes care of your entire body. The materials used for this chair are also no ordinary materials. They help to absorb the body heat and therefore help you feel cool and fresh throughout the day. Aren’t aeron chairs a complete package with so many advantages and functions to offer. Ditch the ordinary uncomfortable chairs and get yourself an aeron chair right away Tags: aeron chair

Monday, April 16, 2012

Relish your food with kosher restaurants

The best way to spend quality time with someone would be over a meal. And that meal should be sumptuous enough to leave you with a smile on yohttp://www.blogger.com/img/blank.gifur face. Well, that’s the kind of thing that kosher restaurants menus offer. These restaurants are well reputed all over the world. They offer you a wide variety to choose from but they stick to the kosher lawshttp://www.blogger.com/img/blank.gif. Each food item is given equal attention, http://www.blogger.com/img/blank.gifin case you have specifications like if you are allergic to a particular ingredient, you can address the problem well befhttp://www.blogger.com/img/blank.gifore. And it will be prepared adhering to all your needs.
Kosher restaurants menus cater to the customers desires making it quite popular. There has been seen a huge demand for kosher food from quite some time. Undoubtedly, kosher restaurants menus are pretty impressive that has made it famous over night. You name it and you will get it. They give everything that further touch of style and magic. Not only the delicious food but their wine list is remarkable as well. You get that perfect wine paired with your meal. Kosher restaurants menus are indeed interesting and there has been an increase in total number of kosher restaurants.

Monday, March 26, 2012

Where to find kosher restaurants?

Although kosher food is getting popular it might still be a challenge to find Kosher food and restaurants. In case you happen to live in a kosher restaurants with large Jewish population, then of course you will not face any problem finding a big range of good Kosher restaurants. But in case if you are in a new place where there are no Jews and no one has even heard of Kosher, then youhttp://www.blogger.com/img/blank.gif my have a tough time finding an authentic .
There are certain big metro cities all across the world where the Jewish population stays in large numbers and has already left a big impact on the food and culture around. A very good example is New York, with large Jewish community as well other blend of cultures. While here you will have no problem finding a good Kosher restaurants. But with the rising popularity of Kosher foods, you will find Kosher restaurants springing up even with hardly any Jewish people or community living there.
Even with the above information, one can never be very sure if the food served in many popular Kosher restaurants is really authentic. Therefore you need to consult your own knowledgeable Orthodox Rabbi for precise instructions before purchasing from an unverified establishment. Getting Kosher food while traveling may also offer many challenges.

Saturday, March 10, 2012

Kosher restaurants

Serving food as per Jewish dietary laws, kosher restaurants will serve pizzerias, cafés,
fast food and cafeterias. You will come across kosher bakeries, caterers, butchers and
kosher Chinese as well as kosher sushi food. These establishments work under rabbinical
supervision and observe certain other Jewish laws. And if under Jewish ownership, these
locations must be closed during Jewish holidays and during Shabbat.

You will come across dairy or meat foods at such locations but at some Kosher
restaurants, you will find even delicatessens served. Some of these restaurants may
specialize in a particular kind of food and also offer different popular foods among Jews.
You will find Pizza a common and well liked food served at these kosher restaurants, buthttp://www.blogger.com/img/blank.gif
then there are kosher pizza shops that usually serve Middle Eastern cuisine, like falafel,
bagels with cream cheese and other foods such as fish. Salads may also be served.
New York City has the maximum number of kosher restaurants in US and in Canada,
you will find Toronto having the most restaurants. You will even find Kosher Chinese
restaurants too getting popular. In smaller cities, with lesser Jewish populations, you will
find kosher dining limited to just a single establishment. Jewish people often get ready-
made kosher meals that may be difficult to get otherwise.

Viste : Kosher restaurants