[wp-trac] [WordPress Trac] #61695: Suggestion: Add a post_type column in the wp_postmeta table

WordPress Trac noreply at wordpress.org
Thu Jul 18 19:23:29 UTC 2024


#61695: Suggestion: Add a post_type column in the wp_postmeta table
-------------------------------+------------------------------
 Reporter:  rajinsharwar       |       Owner:  (none)
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by debarghyabanerjee):

 Replying to [ticket:61695 rajinsharwar]:
 > **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.

 Hi @rajinsharwar, if we add a column of `post_type` to 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61695#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list