{"id":2250,"date":"2019-05-16T14:21:47","date_gmt":"2019-05-16T12:21:47","guid":{"rendered":"https:\/\/2019.sevilla.wordcamp.org\/?post_type=wcb_session&#038;p=2250"},"modified":"2019-11-04T20:29:32","modified_gmt":"2019-11-04T19:29:32","slug":"querying-posts-by-custom-fields-vs-taxonomys-terms-is-there-a-difference-in-performance-english","status":"publish","type":"wcb_session","link":"https:\/\/sevilla.wordcamp.org\/2019-developers\/session\/querying-posts-by-custom-fields-vs-taxonomys-terms-is-there-a-difference-in-performance-english\/","title":{"rendered":"Querying posts by custom fields vs. taxonomy\u2019s terms &#8211; is there a difference in performance? (English)"},"content":{"rendered":"\n<p>Let\u2019s take a closer look on the SQL queries that are executed when we are listing posts with WP_Query. Is there any difference in performance between querying posts by custom fields vs. by taxonomy\u2019s terms? It is oftentimes the case that when we need to attach an extra information to the post, we would store it as a custom field, e.g. using the Advanced Custom Fields plugin. But are there any situations in which it would be better to store it as a term in a custom taxonomy? Let\u2019s dive into WordPress database schema, common SQL queries that are fetching the posts and let\u2019s try to understand which factors have the biggest influence on query performance.<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"525\" height=\"296\" src=\"https:\/\/www.youtube.com\/embed\/eECkm3FoHCE?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=es-ES&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span>\n<\/div><\/figure>\n\n\n<ul class=\"wordcamp-block wordcamp-post-list has-layout-list wordcamp-speakers\"><li class=\"wordcamp-post-list__post wordcamp-clearfix\">\n<div class=\"wordcamp-speaker wordcamp-speakers__post slug-magdalena-paciorek\">\n\t<h3 class=\"wordcamp-block__item-title wordcamp-speakers__title\"><a href=\"https:\/\/sevilla.wordcamp.org\/2019-developers\/speaker\/magdalena-paciorek\/\">Magdalena Paciorek<\/a><\/h3>\n\t\t\t<div class=\"wordcamp-image__avatar-container align-none\">\n\t\t\t<a href=\"https:\/\/sevilla.wordcamp.org\/2019-developers\/speaker\/magdalena-paciorek\/\" class=\"wordcamp-image__avatar-link\">\n\t\t\t\t<img decoding=\"async\" src=\"https:\/\/secure.gravatar.com\/avatar\/43dacba6ead4e05bdfa29c0a3b0247ed3f2f031c1572eae667387eb56b6e7089?s=150&amp;d=mm&amp;r=g\" alt=\"Avatar de Magdalena Paciorek\" \/>\t\t\t<\/a>\n\t\t<\/div>\n\t\n\t\t\t<div class=\"wordcamp-block__item-content wordcamp-speakers__content is-full\"><p>Magdalena work as freelancer and a part time WordPress developer from Poland. After hours organizing WordCamps and local WordPress meetups.<\/p>\n<\/div>\t\n\t<\/div>\n\n<\/li><\/ul>\n\n\n<h2 class=\"wp-block-heading\">Aperitivo formativo<\/h2>\n\n\n\n<p>Durante las pr\u00f3ximas semanas vamos a ir publicando material complementario (v\u00eddeos, cursos, tutoriales, etc) para que puedas sacarle todo el partido a esta sesi\u00f3n.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">V\u00eddeo en WordPress.tv <\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s take a closer look on the SQL queries that are executed when we are listing posts with WP_Query. Is there any difference in performance between querying posts by custom fields vs. by taxonomy\u2019s terms? It is oftentimes the case that when we need to attach an extra information to the post, we would store &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/sevilla.wordcamp.org\/2019-developers\/session\/querying-posts-by-custom-fields-vs-taxonomys-terms-is-there-a-difference-in-performance-english\/\" class=\"more-link\">Continuar leyendo<span class=\"screen-reader-text\"> \u00abQuerying posts by custom fields vs. taxonomy\u2019s terms &#8211; is there a difference in performance? (English)\u00bb<\/span><\/a><\/p>\n","protected":false},"author":14992222,"featured_media":5739,"template":"","meta":{"jetpack_post_was_ever_published":false,"_wcpt_session_time":1570273200,"_wcpt_session_duration":3000,"_wcpt_session_type":"session","_wcpt_session_slides":"","_wcpt_session_video":"https:\/\/wordpress.tv\/2019\/11\/04\/magdalena-paciorek-querying-posts-by-custom-fields-vs-taxonomys-terms\/","_wcpt_speaker_id":[3298],"footnotes":""},"session_track":[164407],"session_category":[385609],"class_list":["post-2250","wcb_session","type-wcb_session","status-publish","has-post-thumbnail","hentry","wcb_track-auditorio","wcb_session_category-charla"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/papmcC-Ai","session_date_time":{"date":"5 de octubre de 2019","time":"13:00"},"session_speakers":[{"id":"3298","slug":"magdalena-paciorek","name":"Magdalena Paciorek","link":"https:\/\/sevilla.wordcamp.org\/2019-developers\/speaker\/magdalena-paciorek\/"}],"session_cats_rendered":"Charla \/ Talk","_links":{"self":[{"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/sessions\/2250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/sessions"}],"about":[{"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/types\/wcb_session"}],"version-history":[{"count":8,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/sessions\/2250\/revisions"}],"predecessor-version":[{"id":5758,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/sessions\/2250\/revisions\/5758"}],"speakers":[{"embeddable":true,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/speakers\/3298"}],"author":[{"embeddable":true,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wporg\/v1\/users\/magdalenapaciorek"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/media\/5739"}],"wp:attachment":[{"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/media?parent=2250"}],"wp:term":[{"taxonomy":"wcb_track","embeddable":true,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/session_track?post=2250"},{"taxonomy":"wcb_session_category","embeddable":true,"href":"https:\/\/sevilla.wordcamp.org\/2019-developers\/wp-json\/wp\/v2\/session_category?post=2250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}