Skip to content

Commit 8b9c694

Browse files
authored
- Adding More Info to Query Throttling
- Specifying leading wild card in wildcard-characters - Updating query-antipatterns
1 parent 27b81cb commit 8b9c694

File tree

3 files changed

+35
-41
lines changed

3 files changed

+35
-41
lines changed

powerapps-docs/developer/data-platform/includes/cc-query-antipatterns.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Composing optimized queries for Dataverse is vital to ensure applications provid
55

66
### Minimize the number of selected columns
77

8-
Don't include columns you don't need in your query. Queries that return all columns or include a large number of columns can encounter performance issues due to the size of the dataset.
8+
Don't include columns you don't need in your query. Queries that return all columns or include a large number of columns can encounter performance issues due to the size of the dataset or complexity of the query.
99

1010
This practice is especially true for *logical columns*. A logical column contains values that are stored in different database tables. The [AttributeMetadata.IsLogical property](/dotnet/api/microsoft.xrm.sdk.metadata.attributemetadata.islogical) tells you whether a column is a logical column. Queries that contain many logical columns are slower because Dataverse needs to combine the data from other database tables.
1111

@@ -43,25 +43,12 @@ The following example is a FetchXml query that uses a leading wild card:
4343
</fetch>
4444
```
4545

46-
4746
When queries using leading wild cards timeout, the following error is returned:
4847

49-
<!--
50-
51-
Can this link to the current failure text in https://learn.microsoft.com/en-us/power-apps/developer/data-platform/reference/web-service-error-codes
52-
53-
jdaly: No. You can't link to an item within a table.
54-
-->
55-
<!--
56-
57-
Also we should update the throttle page to link back to here for the different rules
58-
59-
-->
60-
61-
> Name: `DataEngineLeadingWildcardQueryThrottling`<br />
62-
> Code: `0x80048644`<br />
63-
> Number: `-2147187132`<br />
64-
> Message: `This query cannot be executed because it conflicts with Query Throttling; the query uses a leading wildcard value in a filter condition, which will cause the query to be throttled more aggressively. Please refer to this document: https://go.microsoft.com/fwlink/?linkid=2162952`
48+
> Name: `LeadingWildcardCauseTimeout`<br />
49+
> Code: `0x80048573`<br />
50+
> Number: `-2147187341`<br />
51+
> Message: `The database operation timed out; this may be due to a leading wildcard value being used in a filter condition. Please consider removing filter conditions on leading wildcard values, as these filter conditions are expensive and may cause timeouts.`
6552
6653
Dataverse heavily throttles leading wild card queries that are identified as a risk to the health of the org to help prevent outages. [Learn more about query throttling](../query-throttling.md)
6754

@@ -72,6 +59,7 @@ If you find yourself using leading wild card queries, look into these options:
7259

7360
[Learn more about using wildcard characters in conditions for string values](../wildcard-characters.md)
7461

62+
7563
### Avoid using formula or calculated columns in filter conditions
7664

7765
[Formula and calculated column](../calculated-rollup-attributes.md#formula-and-calculated-columns) values are calculated in real-time when they're retrieved. Queries that use filters on these columns force Dataverse to calculate the value for each possible record that can be returned so the filter can be applied. Queries are slower because Dataverse can't improve the performance of these queries using SQL.
@@ -90,14 +78,17 @@ To help prevent outages, Dataverse applies throttles on queries that have filter
9078

9179
When you request query results be ordered on a choice column, the results are ordered by the localized label of the choice values. Ordering by the number value stored in the database wouldn't provide a good experience in your application. You should know that ordering on choice columns requires more compute resources to join and sort the rows by the localized label value. This extra work makes the query slower. If possible, try to avoid ordering results by choice column values.
9280

93-
9481
<!--
9582
9683
jdaly: I don't think this example adds much here.
9784
9885
Do you want to mention the fetch element useraworderby attribute?
9986
That might make for a good example
10087
88+
dasuss: I'm conflicted when it comes to useraworderby, yeah its supported and technically works,
89+
but I don't think its worth doing in place of ordering on the name. We would be adding an order that doesn't
90+
make logical sense for the customer (ie the state code Number doesn't mean anything of logical value).
91+
10192
Example query ordering on the statecode choice column:
10293
10394
``` xml
@@ -120,8 +111,7 @@ Ordering by related tables should only be done when needed to as described here:
120111
- [Order rows using QueryExpression](../org-service/queryexpression/order-rows.md)
121112

122113

123-
### Avoid using like conditions on large text columns
124-
114+
### Avoid using conditions on large text columns
125115

126116
Dataverse has two types of columns that can store large strings of text:
127117

@@ -130,7 +120,7 @@ Dataverse has two types of columns that can store large strings of text:
130120

131121
The limit for both of these columns is specified using the `MaxLength` property.
132122

133-
You can use `like` conditions on string columns that have a `MaxLength` configured for less than 850 characters.
123+
You can use conditions on string columns that have a `MaxLength` configured for less than 850 characters.
134124

135125
All memo columns or string columns with a `MaxLength` greater than 850 are defined in Dataverse as large text columns. Large text columns are too large to effectively index, which leads to bad performance when included in a filter condition.
136126

powerapps-docs/developer/data-platform/query-throttling.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,20 @@ application it will affect users that exercise that particular scenario.
3737

3838
## Query throttling behavior
3939

40-
Throttling can manifest in two ways:
40+
Throttling can manifest in three ways:
4141

4242
- A delay is introduced before each execution of the query, making the
4343
scenario that uses it slower
4444

45-
- Some fraction of attempts to execute the query are failing with a dedicated
46-
error:
45+
- Some fraction of attempts to execute the query are failing with any of the following errors:
4746

48-
| **Error code** | **Hex code** | **Message** |
49-
|----------------|--------------|--------------------------------------------------------------------------------------------------------------------------------|
47+
| **Error code** | **Hex code** | **Message** |
48+
|----------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------|
5049
| \-2147187388 | 0x80048544 | This query cannot be executed because it conflicts with query throttling. Please refer to [Query throttling](query-throttling.md) |
50+
| \-2147187132 | 0x80048644 | This query cannot be executed because it conflicts with Query Throttling; the query uses a leading wildcard value in a filter condition, which will cause the query to be throttled more aggressively. Please refer to this document: https://go.microsoft.com/fwlink/?linkid=2162952 |
51+
| \-2147186876 | 0x80048744 | This query cannot be executed because it conflicts with Query Throttling; the query uses a computed column in a filter condition, which will cause the query to be throttled more aggressively. Please refer to this document: https://go.microsoft.com/fwlink/?linkid=2162952 |
52+
53+
For more infromation about more agressively throttled query patterns like leading wild cards can be found in [Optimize performance using FetchXml](fetchxml/optimize-performance.md)
5154

5255
## Common causes
5356

powerapps-docs/developer/data-platform/wildcard-characters.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,50 +67,51 @@ When you use these condition operators, you can use certain characters to repres
6767

6868
You can use the wildcard pattern matching characters as literal characters. To use a wildcard character as a literal character, enclose the wildcard character in brackets. More information: [Using Wildcard Characters As Literals](/sql/t-sql/language-elements/like-transact-sql#using-wildcard-characters-as-literals).
6969

70-
## Don't use trailing wild cards
70+
## Don't use leading wild cards.
7171

72-
Using trailing wildcards isn't supported.
72+
Queries which use condition operators with implicit leading wild cards (ex. ends-with) or explicit leading wild cards will be less performant and can lead to poor performance across the organization in certain scenarios. More information in [Optimize performance using FetchXml](fetchxml/optimize-performance.md).
73+
Queries that use these anti-patterns introduce performance problems because the queries can't be optimized.
7374

7475
# [FetchXml](#tab/fetchxml)
7576

76-
Don't use trailing wild cards in expressions using `begins-with`, `not-begin-with`, `ends-with`, or `not-end-with`.
77+
Don't use trailing wild cards in expressions using `like`, `begins-with`, `not-begin-with`, `ends-with`, or `not-end-with`.
7778
Here are some examples of trailing wildcards:
7879

7980
|Bad Examples |
8081
|---------|
82+
|`<condition attribute='name' operator='like' value='%value' />`|
8183
|`<condition attribute='name' operator='begins-with' value='%value' />`|
8284
|`<condition attribute='name' operator='not-begins-with' value='%value' />`|
83-
|`<condition attribute='name' operator='ends-with' value='value%' />`|
84-
|`<condition attribute='name' operator='not-ends-with' value='value%' />`|
85+
|`<condition attribute='name' operator='ends-with' value='value' />`|
86+
|`<condition attribute='name' operator='not-ends-with' value='value' />`|
8587

8688
# [QueryExpression](#tab/queryexpression)
8789

88-
Don't use trailing wild cards in expressions using `BeginsWith`, `DoesNotBeginWith`, `EndsWith`, or `DoesNotEndWith`.
89-
Here are some examples of trailing wildcards:
90+
Don't use leading wild cards in expressions using `like`, `BeginsWith`, `DoesNotBeginWith`, `EndsWith`, or `DoesNotEndWith`.
91+
Here are some examples of excess wildcards:
9092

9193
|Bad Examples |
9294
|---------|
95+
|`query.Criteria.AddCondition("name", ConditionOperator.Like, "%value");`|
9396
|`query.Criteria.AddCondition("name", ConditionOperator.BeginsWith, "%value");`|
9497
|`query.Criteria.AddCondition("name", ConditionOperator.DoesNotBeginWith, "%value");`|
95-
|`query.Criteria.AddCondition("name", ConditionOperator.EndsWith, "value%");`|
96-
|`query.Criteria.AddCondition("name", ConditionOperator.DoesNotEndWith, "value%");`|
98+
|`query.Criteria.AddCondition("name", ConditionOperator.EndsWith, "value");`|
99+
|`query.Criteria.AddCondition("name", ConditionOperator.DoesNotEndWith, "value");`|
97100

98101
# [Web API](#tab/webapi)
99102

100-
Don't use trailing wild cards in expressions using `startswith`, `not startswith`, `endswith`, or `not endswith`.
101-
Here are some examples of trailing wildcards:
103+
Don't use leading wild cards in expressions using `like`, `startswith`, `not startswith`, `endswith`, or `not endswith`.
104+
Here are some examples of excess wildcards:
102105

103106

104107
|Bad Examples |
105108
|---------|
109+
|`like(name,'%value')`|
106110
|`startswith(name,'%value')`|
107111
|`not startswith(name,'%value')`|
108112
|`endswith(name,'value%')`|
109113
|`not endswith(name,'value%')`|
110114

111-
---
112-
113-
Queries that use these anti-patterns introduce performance problems because the queries can't be optimized.
114115

115116
### See also
116117

0 commit comments

Comments
 (0)