[wp-hackers] Like Posts - Store Data in DB, User_Meta or Post_Meta

Andrew Bartel andrew.bartel at gmail.com
Mon Nov 11 18:42:13 UTC 2013


I have to respectfully disagree with Chris, I wouldn't store it in both,
storing duplicate data in general is a dangerous path to go down.  It might
make sense at this moment, but say you want to add a feature six months
from now where someone can unlike a page from their profile and you only
write code to update the post_meta table, forgetting to update the
user_meta table.  Or maybe you bring another developer on and forget to
document that in the comments of every place that the updates can take
place.

Figure out which one is going to be the more expensive set or queries
(probably retrieving a list of users that have liked a post if you have a
large site) and store it there.  Cache the results for the other one if you
have to.  You shouldn't hit a performance bottleneck for quite a while
though if you use built in WP functions.

-Andrew


On Mon, Nov 11, 2013 at 10:18 AM, Gregory Lancaster <
greglancaster71 at gmail.com> wrote:

> Alright that is what I thought might be best, but I often get awesome
> suggestions here for simplifying code I wrote so I had to ask.  Thanks
>
>
> On Mon, Nov 11, 2013 at 10:16 AM, chriscct7 <hello at chriscct7.com> wrote:
>
> > Sounds like the best thing would be to store it in both places. Saves two
> > potentially expensive query's as your site scales up.
> >
> > -Chris
> >
> >
> >
> > --
> > View this message in context:
> >
> http://wordpress-hackers.1065353.n5.nabble.com/Like-Posts-Store-Data-in-DB-User-Meta-or-Post-Meta-tp42769p42772.html
> > Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list