Solved

table with very high identity numbers, decreased performance?

Posted on 2011-09-22
7
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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 143

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

733 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