1

I am making a news aggregation site on wordpress. I've to save domains of source urls somewhere. Sometimes source url could be same for multiple posts. So I'm confused how should I save the data.

I've two options

  1. Creating custom taxonomy and then save domain as terms.
  2. Create custom post meta for each post.

By using custom post meta, every post will get its separate meta data entry. On the other hand once the domain name is saved as term it can be added to any post just like tags. In future I'll need post ids having same domain name. Also I know my news aggregation site will grow into something mega. While keeping these two methods to save data (term/post meta) in mind I want my site speedy and database smaller in size.

So which method should I use. I want to know expert opinion about efficiency, speed and smart data storage techniques.

0

First option:

Creating custom taxonomy and then save domain as terms.

  • Basically "taxonomy" is a grouping mechanism. In your requiremnt there would not be too many CPTs are of same taxonomy.
  • For Taxonomy, you have to maintain 3 tables, wp_terms, wp_term_taxonomy and wp_term_relationships.
  • So, while creating a NEWS (your CPT), you will fire queries on these 3 tables.
  • While fetching domain(taxonomy) WordPress will make joins on these tables.

About:

1) Efficiency: You have to create custom taxonomy, assign it to post.

2) Speed: More joins, less speed.

3) Storage: Entry in 3 tables. ( 3 rows ).

Second option:

Create custom post meta for each post.

  • For custom post meta, you need to code to show/save meta on an edit page.

About:

1) Efficiency: You need to add data in post meta field, that's it.

2) Speed: Normally, WordPress fires query by joining 2 tables, wp_posts and wp_postmeta. No more joins, just specify meta key name.

3) Storage: Only one row in wp_postmeta table.

In future if you want to get all post IDs, just simple query on wp_postmeta table.

  • 2
    Term and custom field data are cached by default, so they should not impact performance in any noticeable way. Also, meta queries can be more expensive than a normal taxonomy query. There is no proper benchmark for testing anything because you don't have any concrete data. I would use a non hierarchical taxonomy for the issue looing at it – Pieter Goosen Aug 18 '15 at 9:38
  • 1
    Also, if this is really going to become a mega site as said in the OP, performance will become an issue whether or not you use taxonomies or custom fields. – Pieter Goosen Aug 18 '15 at 9:41
  • Thank you for the detailed answer. Based on your explanation the difference is the increment of one extra table/row in first method. Because I'll be adding further functionalities to site. So to keep the loops and queries simple I'm going with custom taxonomy. – wp student Aug 18 '15 at 9:41
  • by god, if you save large data in postmeta like that, you will soon reach a hellish wp_postmeta table which may go over 2 mil rows and does self joins which last ~11 seconds... In a woocommerce store with 30k products with ~20 meta per product, that's what you get. Evade postmeta. It was not designed for storing large amounts of data which may be needed to list and sort posts. – unity100 Mar 31 '17 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.