Solved

table with very high identity numbers, decreased performance?

Posted on 2011-09-22
7
328 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
Comment Utility
>>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
Comment Utility
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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:bbdesign
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
OK, thanks guys.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

772 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

10 Experts available now in Live!

Get 1:1 Help Now