admin管理员组文章数量:1391766
Anyone know if there is likely a big performance difference to these two queries?
- get all posts by status = TRASH
- get all posts which have the meta key
_delete_product
and has a value of TRUE
I will be doing a nightly cron purge of all posts which are to be deleted. Best thing is to grab all relevant posts in the most efficient way possible here before looping through them.
Anyone know if there is likely a big performance difference to these two queries?
- get all posts by status = TRASH
- get all posts which have the meta key
_delete_product
and has a value of TRUE
I will be doing a nightly cron purge of all posts which are to be deleted. Best thing is to grab all relevant posts in the most efficient way possible here before looping through them.
Share Improve this question asked Feb 8, 2020 at 13:35 wharfdalewharfdale 3484 silver badges17 bronze badges 1 |1 Answer
Reset to default 2As mentioned in the comments, post_status
is stored in the posts table but postmeta values are stores in postmeta table which is usually a much more heavy table than posts. Using a meta in db queries, results in adding a JOIN clause to the query to join this heavy table!
So using post_status
is definitely a better performance choice.
本文标签: Look up all posts by status or meta valueperformance difference
版权声明:本文标题:Look up all posts by status or meta value - performance difference 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744765905a2624038.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
post_status
means you don't need to do a JOIN to postmeta, so it's almost certainly considerably faster. – Jacob Peattie Commented Feb 8, 2020 at 14:19