1

I have a csv of 65,000+ rows. Each row only has two fields, an ID code and a Description. This csv will get updated every year or so. The users needs to be able to type in the code and get a list of related posts (which I'll handle with a custom meta box).

It seems like these 65,000 items would really clutter up the wp_posts table and maybe the wp_postmeta table and make searches slow. This is a site with hundreds of posts (thousands counting revisions) in various CPTs already.

I'm not a database guy, so I really don't know the best way to handle this. Would be something better handled in it's own custom table?

1 Answer 1

0

This would be best handled as a custom taxonomy.

Why? Because taxonomy is already optimized for finding related content. Using a custom taxonomy means you automatically get post edit metaboxes, archive templates, admin screen searches, and more.

Creating posts for each item and using a post_meta search would be orders of magnitude slower. I'm running into this issue myself with 100k posts related to 14k authors via an ACF post_meta field. Sloooow.

Structure:

Each ID code would be the term name. Each description would be the term description — term description is a standard field in WordPress but it's not exposed by default. You'd want to search elsewhere for the code to expose the term description in various admin screens and frontend pages.

Relationship:

Each post gets one or more of these terms assigned. How you assign them is up to you.

Import:

WPAllImport can handle taxonomy term imports. One advantage of WPAI is that you can re-run an import with a new source csv and update your previous import. To do that, each row would need a unique ID — you could use the term name if that's unique and unchanging from one import to the next update, or create a third row with a unique id used just for importing.

2
  • Great advice! I hadn't thought of using them exclusively as taxonomy terms. Jun 7, 2018 at 13:27
  • This seems like a perfect use case for a taxonomy. And then there's little need to muck about with custom functions or custom tables. If this works please check my answer as accepted, thanks!
    – Slam
    Jun 8, 2018 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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