Skip to content

Commit 1dbd8ad

Browse files
authored
Merge pull request #2699 from rodrigoprimo/docs-slow-db-query
DB/SlowDBQuery: add XML documentation
1 parent fc69a87 commit 1dbd8ad

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0"?>
2+
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
4+
title="Slow DB Query"
5+
>
6+
<standard>
7+
<![CDATA[
8+
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.
9+
]]>
10+
</standard>
11+
<code_comparison>
12+
<code title="Valid: No potentially slow query keys.">
13+
<![CDATA[
14+
$query = new WP_Query( array(
15+
'post_type' => 'post',
16+
) );
17+
18+
19+
$args = 'post_type=post&orderby=date';
20+
]]>
21+
</code>
22+
<code title="Invalid: Using potentially slow query keys.">
23+
<![CDATA[
24+
$query = new WP_Query( array(
25+
'<em>meta_key</em>' => 'color',
26+
'<em>meta_value</em>' => 'blue',
27+
) );
28+
29+
$args = 'post_type=post&<em>meta_key</em>=featured';
30+
]]>
31+
</code>
32+
</code_comparison>
33+
</documentation>

0 commit comments

Comments
 (0)