Mahesh
Mahesh

Reputation: 1689

Tell me a situation in which SQL Server indexing is not required

Could you please tell me cases where indexing on an SQL Server table is not required?

Upvotes: 0

Views: 211

Answers (9)

Raj More
Raj More

Reputation: 48016

My old DBA told me that as a rule of thumb in our environment, narrow tables with less than 50K rows do not need indexing for data retrieval purposes from that one table because the cost of the index lookup offsets the cost of the table scan.

Upvotes: 0

davek
davek

Reputation: 22915

I've worked on ETL solutions (Integration Serices writing to SQL Server 2005) where I had to chuck away a lot of indexes as the inserts (and there were only inserts) were taking hours (although as the data was later imported into an Analysis Services cube, where other relations were defined, you could argue that the indexes weren't really ditched). For some tables the compromise was to drop the indexes before the writing process and then recreate them afterwards; the recreation took a long time, but was still quicker than inserting against the momentum of simultaneous index building.

Upvotes: 0

gbn
gbn

Reputation: 432271

For non-staging table, when the table has zero (or maybe just one) rows and has no foreign keys. However, how would you prevent someone adding the same value again?

Otherwise, there may be a benefit for staging tables that are emptied then bulk processed in one call

Simply put, there is almost no case wher you'd not use an index somewhere...

Upvotes: 0

Jaya Wijaya
Jaya Wijaya

Reputation: 179

I think it would be a table in which you need to dump data quickly and possibly in high frequency (like in data acquisition applications, where you would dump raw data from sensors) to be processed later. This is because indexing tends to slow down the data insertion a bit due to overhead in rearranging the index.

Upvotes: 2

Justin
Justin

Reputation: 86729

I can think of a few examples where an index might not be required, but I cant honestly think of any example where you wouldn't want to index your table anyway.

At the very least you should have your primary key indexed - there is just no reason not to.

Upvotes: 0

Paul Sasik
Paul Sasik

Reputation: 81479

One place it might not be required is for something like a logging table where you save some events but would never refer to a primary key within the table. IF you ever access the table it might be for text searches which usually require a table scan anyway. Although one could easily argue that a log table is nothing without a date/time column and that should be indexed.

Upvotes: 1

NeilD
NeilD

Reputation: 2298

If a table is below a certain number of rows, then it is quicker to do a table scan than to look up an index.

I'm not sure of the exact number at which one becomes quicker than the other.

Upvotes: 1

user26901
user26901

Reputation:

Can't think of a really GREAT example. Maybe if you had a table that only held one value for whatever reason. There would be no need to index that table.

Upvotes: 1

kemiller2002
kemiller2002

Reputation: 115488

Technically it's never "required", but it's always a good idea. If you don't have a clustered index (and non-clustered indexes need a clustered index to work), then every time you access data from that table, you have to do a table scan to retrieve the information. If you have an extremely small number of rows in a table, then the index would technically be of little benefit.

Upvotes: 1

Related Questions