# Why post\_number?

**URL:** https://meta.discourse.org/t/why-post-number/52634
**Category:** Development
**Created:** [November 7, 2016, 7:33pm UTC](https://meta.discourse.org/t/why-post-number/52634 "2016-11-07T19:33:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Kevin\_Wildenradt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_wildenradt/32/62507_2.png) [@Kevin\_Wildenradt](https://meta.discourse.org/u/Kevin_Wildenradt)
#### Post date: [November 7, 2016, 7:33pm UTC](https://meta.discourse.org/t/why-post-number/52634/1 "2016-11-07T19:33:26Z")

</div>

I’ve noticed that all posts bear both a post\_id and a post\_number. I understand that post\_id is the unique identifier of the post in the entire forum, while post\_number is the number of the post in its topic. Posts identify themselves as replies to other posts by referencing the post\_number of another post in the reply\_to\_post\_number field. Whenever any topic (or section of posts from a topic) is retrieved from the server, it contains a sorted array of the post\_id’s of every post in the topic. The front end provides access to specific post\_numbers via the URL, but when such a URL is actually accessed the request made to the back end is in terms of post\_ids (presumably accessed from the above mentioned array).

This is all well and good, but it seems like everything post\_number is used for could be accomplished with post\_id instead: post\_id’s are always increasing, so they can be used to determine the relative ordering of posts in a topic. Since they are globally unique they are certainly unique within each topic, and so could be used in a reply\_to\_post\_id that serves the same purpose as reply\_to\_post\_number.

TLDR; What purpose does post\_number serve that could not be easily accomplished with post\_id? If there is none then removing it would streamline the data model, which would seem to be a good thing.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 7, 2016, 8:33pm UTC](https://meta.discourse.org/t/why-post-number/52634/2 "2016-11-07T20:33:05Z")

</div>

> [@Kevin\_Wildenradt](#):
>
> TLDR; What purpose does post\_number serve that could not be easily accomplished with post\_id?

This allows [Why post\_number? - #3 by Kevin\_Wildenradt](https://meta.discourse.org/t/why-post-number/52634/3) to continue to work efficiently even if [Why post\_number? - #2 by sam](https://meta.discourse.org/t/why-post-number/52634/2) is deleted.

And [Why post\_number? - #3 by Kevin\_Wildenradt](https://meta.discourse.org/t/why-post-number/52634/3) is arguably much prettier than [Why post\_number? - #9 by sam](https://meta.discourse.org/t/why-post-number/52634/373873) or [Bootstrap failed with exit code 128](https://meta.discourse.org/t/why-post-number/373873) which does not hint properly on the topic.

---

<div class="post-metadata">

### Author: ![Kevin\_Wildenradt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_wildenradt/32/62507_2.png) [@Kevin\_Wildenradt](https://meta.discourse.org/u/Kevin_Wildenradt)
#### Post date: [November 8, 2016, 1:54am UTC](https://meta.discourse.org/t/why-post-number/52634/3 "2016-11-08T01:54:25Z")

</div>

Thanks for getting back to me so quickly Sam 😄

> [@sam](#):
>
> This allows [Why post\_number? - #3 by Kevin\_Wildenradt](https://meta.discourse.org/t/why-post-number/52634/3) to continue to work efficiently even if [Why post\_number? - #2 by sam](https://meta.discourse.org/t/why-post-number/52634/2) is deleted.

How would post\_id not work for this scenario? It would seem that if 2 is deleted, the third post would become the second post, but its post\_number does not change accordingly and is now wrong. Post\_id would behave the same way in this scenario, except that it would not wrongfully identify what is now the second post in the thread as the third.

> [@sam](#):
>
> [Why post\_number? - #3 by Kevin\_Wildenradt](https://meta.discourse.org/t/why-post-number/52634/3) is arguably much prettier than [Why post\_number? - #9 by sam](https://meta.discourse.org/t/why-post-number/52634/373873)

Agreed that it is a prettier URL.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [November 8, 2016, 1:56am UTC](https://meta.discourse.org/t/why-post-number/52634/4 "2016-11-08T01:56:33Z")

</div>

And if post 2 is later undeleted after post 3 takes its place, does it then become post 1 1/2 ?

---

<div class="post-metadata">

### Author: ![Kevin\_Wildenradt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_wildenradt/32/62507_2.png) [@Kevin\_Wildenradt](https://meta.discourse.org/u/Kevin_Wildenradt)
#### Post date: [November 8, 2016, 2:08am UTC](https://meta.discourse.org/t/why-post-number/52634/6 "2016-11-08T02:08:40Z")

</div>

@Mittineague I do not believe that post\_number is ever updated, even in the event of post deletions. If it were updated then deleting a post would result in every link to every post after that post being broken.

I have just deleted the post immediately before this, post\_number 5. This was post\_number 6 before the deletion, and it still is if you look at the JSON representation of this topic [Why post\_number?](https://meta.discourse.org/t/why-post-number/52634.json)

I have a running discourse instance without the 24 hour deletion delay, and in my testing there the post\_number remains the same after deleting preceding posts.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 8, 2016, 3:09am UTC](https://meta.discourse.org/t/why-post-number/52634/7 "2016-11-08T03:09:34Z")

</div>

> [@Kevin\_Wildenradt](#):
>
> How would post\_id not work for this scenario? It would seem that if 2 is deleted, the third post would become the second post, but its post\_number does not change accordingly and is now wrong.

The post number is correct now, cause external links continue to work. If we ever renumbered links would break which would be terrible.

(post number, topic\_id) is an alias for (post\_id) which is used to keep urls looking just right.

---

<div class="post-metadata">

### Author: ![Kevin\_Wildenradt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kevin_wildenradt/32/62507_2.png) [@Kevin\_Wildenradt](https://meta.discourse.org/u/Kevin_Wildenradt)
#### Post date: [November 11, 2016, 10:08pm UTC](https://meta.discourse.org/t/why-post-number/52634/8 "2016-11-11T22:08:13Z")

</div>

That makes sense, but why is reply\_to\_post\_number used to identify which post a post is a reply to? If post\_number only exists to make URL’s look prettier, why is it the identifier that replies depend on? Wouldn’t it be more consistent to make replies depend on post\_id, a much more fundamental identifier? You would have to check that a post with that post\_id existed in the thread the reply was being posted in, but you already have to do that with post\_number.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 11, 2016, 10:59pm UTC](https://meta.discourse.org/t/why-post-number/52634/9 "2016-11-11T22:59:58Z")

</div>

> [@Kevin\_Wildenradt](#):
>
> why is it the identifier that replies depend on? Wouldn’t it be more consistent to make replies depend on post\_id, a much more fundamental identifier?

Yeah, this is a historic artefact we may get to cleaning it up at some point.
