Solved

table with very high identity numbers, decreased performance?

Posted on 2011-09-22
7
334 Views
Last Modified: 2012-05-12
I have a table with current identity values of 4118223 and higher, its INT column with auto-increment. The table only has about 300,000 records in it, but performance on the table seems slow, even when just doing something such as deleting a single record. I'm wondering if the high INT values have something to do with it? I don't know if there is any way to reset the numbers or something. I believe SQL will never repeat an identity column value, is that correct?

Would appreciate any advice on this. Thank you!
0
Comment
Question by:bbdesign
7 Comments
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 300 total points
ID: 36583235
>>I'm wondering if the high INT values have something to do with it?

Not a blessed thing.
0
 
LVL 13

Expert Comment

by:Wizilling
ID: 36583247
yes it would never repeat an identity column.
You need to put clustered indexes on your identity column. If the identity column is already a primary key then you already have a index on it . So in this case - you need to rebuild your indexes.

alter index all on tablename rebuild
go


0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36583269
It's going to be a 32-bit INT no matter what the actual number is, whether it is 1 or 2,000,000,001.  It is always fetching the same amount of data so like @matthewspatrick said, "Not a blessed thing."
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:bbdesign
ID: 36583281
What does "you need to put clustered indexes on your identity column" mean, or how do I do that?

Excuse my lack of understanding of terminology, but I don't know that I have it set as a Primary Key. I put:

Is Identity: Yes
Identity Increment: 1
Identity Seed: 1

So that query you just gave me, that will reset the column back to 1 again? Thanks!
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 300 total points
ID: 36583316
bbdesign,

Don't confuse identity settings with index settings.

A clustered index means that the physical order of how the rows are stored matches the order of the index.  It speeds up the selects and deletes, but unless you are careful about how you pad the index it can start to slow down inserts once the padding starts to get consumed.

Patrick
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 36583331
having identity is just a technique to get the value sequentially and automatically filled.
by this, the field is not indexed, nor actually guaranteed to be unique.

a index (aka a primary key) on the field will make sure that it is unique, and that delete by using that field in the where clause will be efficient.

btw, the index does not need to be clustered (though with the SQL management studio gui, it will be clustered by default if it's the first index),
but you should know that for "living tables" (tables where there is quite some delete / insert activity), a clustered index is a "must have" ... however, the primary key field is usually not the first choice for being the clustered index.
0
 

Author Comment

by:bbdesign
ID: 36583368
OK, thanks guys.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now