# Table id's never get recycled?

**URL:** <https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379>\
**Category:** Rails\
**Created:** [July 25, 2007, 10:23pm UTC](https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379 "2007-07-25T22:23:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 25, 2007, 10:23pm UTC](https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379/1 "2007-07-25T22:23:36Z")

</div>

I’ve noticed that as you create and delete records, id’s that are no  
longer being used don’t seem to get used again.  
Is this supposed to happen?  
Is there a way to choose an id that is not being used for a new  
record? (because the record that had previously used an id has been  
destroyed)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 25, 2007, 10:24pm UTC](https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379/2 "2007-07-25T22:24:45Z")

</div>

This is pretty standard behavior for a database and is not specific to  
Rails.

On 7/25/07, removed\_email\_address@domain.invalid \<

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 25, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379/3 "2007-07-25T22:37:12Z")

</div>

Oh! Didn’t know that. Thanks.  
So that never really ever causes trouble then?  
id’s don’t ever get rearranged by the db?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 25, 2007, 10:44pm UTC](https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379/4 "2007-07-25T22:44:02Z")

</div>

> Oh! Didn’t know that. Thanks.  
> So that never really ever causes trouble then?

It can if the integer wraps around and starts at 1 again. But that’s  
usually a long way off 🙂

> id’s don’t ever get rearranged by the db?

No.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 25, 2007, 11:32pm UTC](https://www.ruby-forum.com/t/table-ids-never-get-recycled/110379/5 "2007-07-25T23:32:29Z")

</div>

All very good to know! I’m not deeply database knowledgeable as you  
can tell.  
Thanks a lot!
