最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Separate Database Tables For Different Post Types

matteradmin47PV0评论

one big problem with wordpress is that everything on it is a post(a record in wp-posts table)! images, posts, pages, products(for example in woocommerce), portfolios, Post Revisions... Almost everything exists as a record in wp-posts table and the main difference between them is that their "post type" field are different! so by passing time your wp-posts table getting bigger and bigger and you can't do a thing about it unless remove posts like "Revisions" to make the table a bit lighter! is there a way to put main posts like "pages", "posts" and "medias" into separate tables?

one big problem with wordpress is that everything on it is a post(a record in wp-posts table)! images, posts, pages, products(for example in woocommerce), portfolios, Post Revisions... Almost everything exists as a record in wp-posts table and the main difference between them is that their "post type" field are different! so by passing time your wp-posts table getting bigger and bigger and you can't do a thing about it unless remove posts like "Revisions" to make the table a bit lighter! is there a way to put main posts like "pages", "posts" and "medias" into separate tables?

Share Improve this question edited Feb 17, 2015 at 9:18 Mostafa Ghanbari asked Feb 16, 2015 at 20:42 Mostafa GhanbariMostafa Ghanbari 4541 gold badge5 silver badges16 bronze badges 9
  • 2 it's probably easier to do some MySQL tuning and query modification rather than trying to split tables. I've seen WordPress installs with millions of rows in the posts table that were running fine with a few tweaks. – Milo Commented Feb 16, 2015 at 21:21
  • Interesting question. You wrote: "i know i can make custom post types into another table" - How did you handle WP_Query queries with multiple post types, including the separated ones and the unique post ID's ? – birgire Commented Feb 16, 2015 at 21:22
  • @birgire actually i didnt do it yet but with some search on google seems that it is possible! take a look at Pod Framework: wordpress/plugins/pods – Mostafa Ghanbari Commented Feb 17, 2015 at 5:21
  • 1 you could use PODs plugin to store data in custom table pods.io/tutorials/how-tos-sceencasts-series/… – PayteR Commented Dec 21, 2017 at 18:07
  • 2 I'd recommend against using pods, for the sake of scaling and maintainability. But that's just my personal experience. – admcfajn Commented Jan 4, 2018 at 23:39
 |  Show 4 more comments

1 Answer 1

Reset to default 2

So the only reason you want to re-architect WordPress to use multiple tables for different post types is because your posts table is getting bigger too fast? I assume the underlying issue for you is that performance is suffering?

Instead, I suggest adding appropriate indexes to the post table for the queries you are finding unacceptably slow. This will be a whole lot easier and you won't have to have a nonstandard version of WP to deal with for everythi.g else you want to do.

Here's one reference to help with indexing.

Post a comment

comment list (0)

  1. No comments so far