?
Solved

table with very high identity numbers, decreased performance?

Posted on 2011-09-22
7
Medium Priority
?
352 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 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1200 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 84

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1200 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 800 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

862 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