# 主题ID是如何生成的？

**URL:** <https://meta.discourse.org/t/how-are-topic-ids-generated/86937>\
**Category:** Support\
**Created:** [2018年五月7日 17:38 UTC](https://meta.discourse.org/t/how-are-topic-ids-generated/86937 "2018-05-07T17:38:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrieltonon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabrieltonon/32/88155_2.png) [@gabrieltonon](https://meta.discourse.org/u/gabrieltonon)\
**Post date:** [2018年五月7日 17:38 UTC](https://meta.discourse.org/t/how-are-topic-ids-generated/86937/1 "2018-05-07T17:38:43Z")

</div>

Are they created following a simple arithmetic pattern? Also, are they based for the entirety of an instance, or only personal accounts? I’m using the API and seeing some inconsistencies.

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2018年五月7日 18:08 UTC](https://meta.discourse.org/t/how-are-topic-ids-generated/86937/2 "2018-05-07T18:08:09Z")

</div>

It’s a PostgreSQL sequence. It increases +1 for every new topic.

---

<div class="post-metadata">

**Author:** ![gabrieltonon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gabrieltonon/32/88155_2.png) [@gabrieltonon](https://meta.discourse.org/u/gabrieltonon)\
**Post date:** [2018年五月7日 18:52 UTC](https://meta.discourse.org/t/how-are-topic-ids-generated/86937/3 "2018-05-07T18:52:16Z")

</div>

Thanks for the quick response! Are they unique values across the entire Discourse instance or are they based on each individual user?

---

<div class="post-metadata">

**Author:** ![notriddle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/notriddle/32/133055_2.png) [@notriddle](https://meta.discourse.org/u/notriddle)\
**Post date:** [2018年五月7日 18:56 UTC](https://meta.discourse.org/t/how-are-topic-ids-generated/86937/4 "2018-05-07T18:56:07Z")

</div>

They’re unique across the whole instance.

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [2024年六月8日 12:37 UTC](https://meta.discourse.org/t/how-are-topic-ids-generated/86937/5 "2024-06-08T12:37:34Z")

</div>

此主题已在 2223 天后自动关闭。不再允许回复。
