Separate Database Tables For Different Post Types

admin2025-06-07  31

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749256472a317661.html

最新回复(0)