Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions WordPress/Docs/DB/SlowDBQueryStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Slow DB Query"
>
<standard>
<![CDATA[
Usage of the meta_query, meta_key, meta_value, and tax_query keys in array assignments and query-parameter strings is discouraged and should be carefully evaluated. When passed to WordPress database query APIs, these keys can lead to slow queries, especially on large datasets.
]]>
</standard>
<code_comparison>
<code title="Valid: No potentially slow query keys.">
<![CDATA[
$query = new WP_Query( array(
'post_type' => 'post',
) );


$args = 'post_type=post&orderby=date';
]]>
</code>
<code title="Invalid: Using potentially slow query keys.">
<![CDATA[
$query = new WP_Query( array(
'<em>meta_key</em>' => 'color',
'<em>meta_value</em>' => 'blue',
) );

$args = 'post_type=post&<em>meta_key</em>=featured';
]]>
</code>
</code_comparison>
</documentation>
Loading