Opened 2 years ago
Last modified 2 years ago
#61695 new enhancement
Suggestion: Add a post_type column in the wp_postmeta table
| Reported by: | rajinsharwar | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
An Enhancement: I am wondering if we can add a post_type column in the wp_postmeta table. This would allow us to query for the mey keys using the post_type column, instead of querying each individually with post_ids.
A simple use case is, I was building a contact list plugin. There, I had a CPT of "my_emails". Now, in that CPT, there were multiple meta fields of "email", "first_name", "last_name" etc. Now to fetch all the meta fields of "email", I need to query through the whole wp_postmeta table to find instances of "email" meta_key. It would have been much easier and faster I believe if we could have a post_type column as well in the table, which tells the post_type that meta is of.
Replying to rajinsharwar:
Hi @rajinsharwar, if we add a column of
post_typeto the post-meta table, that would go against the concept of Normalization in SQL. However, I understand your point and I guess that for certain use-cases it would reduce multiple database queries.