admin管理员组文章数量:1417662
I have one question. Will WordPress always assign new post post ID which is incremental n+?
For example if I delete some posts, will WordPress use ID of deleted post for new post added in future?
I have one question. Will WordPress always assign new post post ID which is incremental n+?
For example if I delete some posts, will WordPress use ID of deleted post for new post added in future?
Share Improve this question asked Oct 3, 2015 at 9:22 Advanced SEOAdvanced SEO 6892 gold badges16 silver badges41 bronze badges 2- 1 I'm not sure how WordPress handles it, but most software for forums, blogs, news sites and other similar sites do not delete content when you delete it. Instead, it's just marked in the database as deleted or disabled, but you can still find it in the database if you know where to look. This also means that the ID CANNOT be reused, because it's technically still in use. – Nzall Commented Oct 3, 2015 at 13:59
- @NateKerkhofs When you first delete a post in WordPress, it is moved to the trash which like you described simply marks it as deleted but does not remove it from the database. When an item is deleted from trash it is purged from the database. – shea Commented Oct 10, 2015 at 7:55
3 Answers
Reset to default 7Post ID is always incremental. There's no way the ID of a previous post is assigned to a new post. If a post is deleted, the ID of that post remains vacant forever.
I think it's important to understand the why here. The post is stored in a database. 99% of databases that attach a numerical Id "automagically" to a new record do so via something called an "Identity" field (or column). This Identity increments at a fixed rate (usually by +1, but it can be other increments) each time a record is inserted into the database. Due to the way it functions internally, even if you delete the newest record, the one inserted after that will be greater than "the newest one that was just deleted". (Note that this is true for a hard delete and not just the kind of "soft delete" that was mentioned in the comments.)
There fore, the post id is unique by definition and will never be reused.
The concept above is sound - but I was wondering is it the fact. So I looked at the ID column definition of the wp_post table in the database and it is marked as "AI" (meaning auto increment). This means the database is the implementation of the ID increment.
I think this means it will always be bigger than the previous value (typically +1) however in databases with linked tables there can be jumps - that was a non-technical meaning of "linked" - I recall an issue on oracle in an enterprise environment related to this but don't recall the details)
本文标签: Is post ID number always incremental n
版权声明:本文标题:Is post ID number always incremental n+ 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745280349a2651393.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论