{"id":90,"date":"2026-08-26T08:06:20","date_gmt":"2026-08-26T08:06:20","guid":{"rendered":"https:\/\/usestackpulse.com\/optimiser-requetes-sql-wordpress\/"},"modified":"2026-08-30T19:13:00","modified_gmt":"2026-08-30T19:13:00","slug":"optimiser-requetes-sql-wordpress","status":"publish","type":"page","link":"https:\/\/usestackpulse.com\/en\/optimiser-requetes-sql-wordpress\/","title":{"rendered":"Optimize SQL queries for your WordPress themes"},"content":{"rendered":"<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\" style=\"padding-top:32px;padding-right:24px;padding-bottom:8px;padding-left:24px\">\n<p class=\"usp-eyebrow wp-block-paragraph\">Home \/ CMS &amp; DEV \/ Optimize SQL queries<\/p>\n\n\n\n<p class=\"usp-badge wp-block-paragraph\">CMS &amp; DEV<\/p>\n\n\n\n<h1 class=\"wp-block-heading usp-h1\">Optimize SQL queries for your WordPress themes<\/h1>\n\n\n\n<p class=\"usp-meta wp-block-paragraph\">By the team UseStackPulse Updated on August 26, 2026 8 min reading<\/p>\n\n\n\n<p class=\"usp-lede wp-block-paragraph\">A poorly optimized theme can multiply SQL queries by ten. WP_QUERY well configured and the transients drastically reduce the database load.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group usp-ad-slot is-layout-flow wp-block-group-is-layout-flow\" style=\"margin-right:24px;margin-bottom:24px;margin-left:24px\">\n<p class=\"usp-ad-label wp-block-paragraph\">Advertising \/ AD Leaderboard 728\u00d790<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-container-core-group-is-layout-ecfbd4fd wp-block-group-is-layout-flow\" style=\"margin-right:24px;margin-bottom:24px;margin-left:24px\">\n<h2 class=\"wp-block-heading usp-h2\">Avoid redundant requests with WP_QUERY<\/h2>\n\n\n\n<pre class=\"wp-block-code usp-code\"><code>$query = new WP_Query([\n    'post_type' =&gt; 'post',\n    'posts_per_page' =&gt; 10,\n    'no_found_rows' =&gt; true,\n    'update_post_meta_cache' =&gt; false,\n    'update_post_term_cache' =&gt; false,\n]);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading usp-h3\">Caching with the Transients<\/h3>\n\n\n\n<pre class=\"wp-block-code usp-code\"><code>function get_featured_products() {\n    $cached = get_transient('featured_products');\n    if ($cached !== false) return $cached;\n\n    $products = new WP_Query(&#91;'post_type' => 'product', 'meta_key' => 'featured']);\n    set_transient('featured_products', $products->posts, HOUR_IN_SECONDS);\n\n    return $products->posts;\n}<\/code><\/pre>\n\n\n\n<p class=\"usp-tip wp-block-paragraph\">Tip: Enable Query Monitor in the development environment to visualize exactly what queries are slowing down your theme.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group usp-ad-slot is-layout-flow wp-block-group-is-layout-flow\" style=\"margin-right:24px;margin-bottom:24px;margin-left:24px\">\n<p class=\"usp-ad-label wp-block-paragraph\">Advertising \/ AD In-article 336\u00d7280<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-container-core-group-is-layout-b241125f wp-block-group-is-layout-flow\" style=\"margin-right:24px;margin-bottom:40px;margin-left:24px\">\n<h2 class=\"wp-block-heading usp-h2\">frequently asked questions<\/h2>\n\n\n\n<details class=\"wp-block-details usp-faq is-layout-flow wp-block-details-is-layout-flow\"><summary>no_found_rows breaks pagination?<\/summary>\n<p class=\"wp-block-paragraph\" style=\"font-size:13px\">Yes, use it only on queries without pagination; Otherwise keep Found_Rows active.<\/p>\n<\/details>\n\n\n\n<details class=\"wp-block-details usp-faq is-layout-flow wp-block-details-is-layout-flow\"><summary>Do transients survive a Redis cache object?<\/summary>\n<p class=\"wp-block-paragraph\" style=\"font-size:13px\">Yes, with a persistent cache object plugin, transients are automatically stored in memory rather than in base.<\/p>\n<\/details>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Accueil \/ CMS &amp; Dev \/ Optimiser les requ\u00eates SQL CMS &amp; DEV Optimiser les requ\u00eates SQL de vos th\u00e8mes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_zipai_imported":false,"_zipai_import_id":"","footnotes":""},"class_list":["post-90","page","type-page","status-publish","hentry"],"spectra_blocks_featured_image_url":null,"spectra_blocks_author_info":{"display_name":"usestackpulse","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/f2c693076eefeb6a1ac9f8299c6623627456d026be6ffbbb32fd62bd98781cc5?s=96&d=mm&r=g","author_link":"https:\/\/usestackpulse.com\/en\/author\/usestackpulse\/","description":""},"_links":{"self":[{"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/pages\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/pages\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/usestackpulse.com\/en\/wp-json\/wp\/v2\/media?parent=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}