You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: whats-eating-up-your-snowflake-warehouse-part-2.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,11 @@ select * from customers where full_name = 'Ali';
12
12
13
13
## match_recognize
14
14
15
-
Armed with `query_parameterized_hash` we will write a `match_recognize` query to identify queries that are getting worse progressively. Snowflake’s `MATCH_RECOGNIZE` clause can perform Pattern Matching over a set of rows. `MATCH_RECOGNIZE` does this by assigning labels to events, finding the events within an ordered partition, and pulling out any sequences that match the given pattern. In our case, we need a identify a sequence of execution of the same query where the execution time is increasing each time the query is executed.
15
+
Armed with `query_parameterized_hash` we will write a [MATCH_RECOGNIZE](applied-overview-of-MATCH_RECOGNIZE-clause.md) query to identify queries that are getting worse progressively. Snowflake’s [MATCH_RECOGNIZE](applied-overview-of-MATCH_RECOGNIZE-clause.md) clause can perform Pattern Matching over a set of rows. [MATCH_RECOGNIZE](applied-overview-of-MATCH_RECOGNIZE-clause.md) does this by assigning labels to events, finding the events within an ordered partition, and pulling out any sequences that match the given pattern. In our case, we need a identify a sequence of execution of the same query where the execution time is increasing each time the query is executed.
16
16
17
17
### match_recognize SQL query
18
18
19
-
The following `match_recognize` can be used to identify queries that are progessively getting worse rapidly.
19
+
The following [MATCH_RECOGNIZE](applied-overview-of-MATCH_RECOGNIZE-clause.md) can be used to identify queries that are progessively getting worse rapidly.
20
20
21
21
```sql
22
22
with query_history as (
@@ -45,15 +45,15 @@ order by query_parameterized_hash, start_time asc;
45
45
;
46
46
```
47
47
48
-
The `MATCH_RECOGNIZE` clause has several different parts. The `DEFINE` part contains the variable definition, which can later be used in the other parts. We defined the following variables:
48
+
The [MATCH_RECOGNIZE](applied-overview-of-MATCH_RECOGNIZE-clause.md) clause has several different parts. The `DEFINE` part contains the variable definition, which can later be used in the other parts. We defined the following variables:
49
49
50
50
1.`UPTREND` – We defined as the `execution_time_in_mins` greater than the previous execution of the same query. We are also ignoring small increases of 5% or less in execution times by multiplying by `1.05`.
51
51
52
52
The `pattern` we used is the following: `UPTREND{3,}$`
53
53
54
54
It means that we are looking for queries that whose execution time increased in progression 3 or more times, and the `$` indicates that latest execution time is also slower that the previous one
55
55
56
-
The above `match_recognize` query will produce the following output:
56
+
The above [MATCH_RECOGNIZE](applied-overview-of-MATCH_RECOGNIZE-clause.md) query will produce the following output:
0 commit comments