Repository navigation
Expand file tree
/
Copy pathindexes.workbook
More file actions
639 lines (639 loc) · 43.8 KB
/
Copy pathindexes.workbook
File metadata and controls
639 lines (639 loc) · 43.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
{
"version": "Notebook/1.0",
"items": [
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "aed9584f-f4f7-4414-85f4-a610507b84b3",
"version": "KqlParameterItem/1.0",
"name": "indexType",
"label": "Index types",
"type": 2,
"description": "Select one or more index types",
"isRequired": true,
"multiSelect": true,
"quote": "",
"delimiter": ",",
"typeSettings": {
"additionalResourceOptions": [
"value::all"
],
"selectAllValue": "\"\"",
"showDefault": false
},
"jsonData": "[\r\n {\"value\":\"CLUSTERED\",\"label\":\"Clustered\"},\r\n {\"value\":\"HEAP\",\"label\":\"Heap\"},\r\n {\"value\":\"NONCLUSTERED\",\"label\":\"Nonclustered\"},\r\n {\"value\":\"CLUSTERED COLUMNSTORE\",\"label\":\"Clustered columnstore\"},\r\n {\"value\":\"NONCLUSTERED COLUMNSTORE\",\"label\":\"Nonclustered columnstore\"}\r\n]",
"timeContext": {
"durationMs": 86400000
},
"defaultValue": "value::all",
"value": [
"value::all"
]
},
{
"version": "KqlParameterItem/1.0",
"name": "indexOperations",
"label": "Index operations",
"type": 2,
"description": "Filter indexes by the type of index operations. Index reads include single row seeks/lookups and range/full scans. Index writes include inserts, updates, and deletes.",
"isRequired": true,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[\r\n {\"value\":\"A\",\"label\":\"All\"},\r\n {\"value\":\"R\",\"label\":\"Reads only\"},\r\n {\"value\":\"W\",\"label\":\"Writes only\"},\r\n {\"value\":\"RW\",\"label\":\"Reads and writes\"},\r\n {\"value\":\"N\",\"label\":\"None\"}\r\n]",
"timeContext": {
"durationMs": 86400000
},
"value": "A",
"id": "4362f22d-bd66-4430-bad3-0196d6c41593"
},
{
"id": "161a0b54-2199-4262-8563-940c51b2c920",
"version": "KqlParameterItem/1.0",
"name": "maxPartitions",
"label": "Number of partitions",
"type": 2,
"description": "For partitioned tables, include up to this number of partitions",
"isRequired": true,
"typeSettings": {
"additionalResourceOptions": [],
"showDefault": false
},
"jsonData": "[\r\n {\"value\":1,\"label\":\"1\"},\r\n {\"value\":10,\"label\":\"10\"},\r\n {\"value\":50,\"label\":\"50\"},\r\n {\"value\":100,\"label\":\"100\"},\r\n {\"value\":200,\"label\":\"200\"}\r\n]",
"timeContext": {
"durationMs": 86400000
},
"value": "10"
}
],
"style": "above",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"name": "index_metadata_parameters"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"AzureDataExplorerQuery/1.0\",\"queryText\":\"let current_snapshot = materialize(\\r\\nsqldb_database_index_metadata\\r\\n| where sample_time_utc between (\\r\\n iif(({timeRange:end} - {timeRange:start}) <= 1h, ({timeRange:start} - 1h), {timeRange:start})\\r\\n ..\\r\\n iif(({timeRange:end} - {timeRange:start}) <= 1h, ({timeRange:end} + 1h), {timeRange:end})\\r\\n ) // Expand the range if selected range is shorter than the least frequent collection interval (1h)\\r\\n| where logical_server_name =~ @\\\"{serverName}\\\"\\r\\n| where database_name == @\\\"{databaseName}\\\"\\r\\n| where ({haReplica} and replica_type == \\\"HA secondary\\\") or (not ({haReplica}) and replica_type != \\\"HA secondary\\\")\\r\\n| where strlen(\\\"{indexType}\\\") == 0 or index_type in ({indexType:value})\\r\\n| where isempty(columnstore_internal_rowset_type)\\r\\n| project-away logical_server_name, database_name\\r\\n| extend in_row_partition_size_mb = toreal(in_row_partition_size_mb), row_overflow_partition_size_mb = toreal(row_overflow_partition_size_mb), lob_partition_size_mb = toreal(lob_partition_size_mb)\\r\\n| sort by object_id asc, index_id asc, partition_number asc, sample_time_utc asc\\r\\n| extend delta_leaf_insert_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and leaf_insert_count >= prev(leaf_insert_count), leaf_insert_count - prev(leaf_insert_count), long(null)),\\r\\n delta_leaf_delete_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and leaf_delete_count >= prev(leaf_delete_count), leaf_delete_count - prev(leaf_delete_count), long(null)),\\r\\n delta_leaf_update_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and leaf_update_count >= prev(leaf_update_count), leaf_update_count - prev(leaf_update_count), long(null)),\\r\\n delta_leaf_ghost_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and leaf_ghost_count >= prev(leaf_ghost_count), leaf_ghost_count - prev(leaf_ghost_count), long(null)),\\r\\n delta_range_scan_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and range_scan_count >= prev(range_scan_count), range_scan_count - prev(range_scan_count), long(null)),\\r\\n delta_singleton_lookup_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and singleton_lookup_count >= prev(singleton_lookup_count), singleton_lookup_count - prev(singleton_lookup_count), long(null)),\\r\\n delta_forwarded_fetch_count = iif(database_engine_start_time_utc == prev(database_engine_start_time_utc) and object_id == prev(object_id) and index_id == prev(index_id) and partition_number == prev(partition_number) and forwarded_fetch_count >= prev(forwarded_fetch_count), forwarded_fetch_count - prev(forwarded_fetch_count), long(null))\\r\\n| summarize arg_max(sample_time_utc, schema_name, object_name, index_name, index_type, is_unique, is_primary_key, is_unique_constraint, is_padded, is_disabled, has_filter, ignore_dup_key, auto_created, optimize_for_sequential_key, fill_factor, allow_row_locks, allow_page_locks, partition_compression, page_compression_attempt_count, page_compression_success_count, key_columns, included_columns, columnstore_order_columns, partitioning_column, filter_definition, partition_row_count, in_row_partition_size_mb, row_overflow_partition_size_mb, lob_partition_size_mb, is_xml_compressed),\\r\\n interval_start = min(sample_time_utc),\\r\\n leaf_insert_count = sum(delta_leaf_insert_count),\\r\\n leaf_delete_count = sum(delta_leaf_delete_count),\\r\\n leaf_update_count = sum(delta_leaf_update_count),\\r\\n leaf_ghost_count = sum(delta_leaf_ghost_count),\\r\\n range_scan_count = sum(delta_range_scan_count),\\r\\n singleton_lookup_count = sum(delta_singleton_lookup_count),\\r\\n forwarded_fetch_count = sum(delta_forwarded_fetch_count)\\r\\n by object_id, index_id, partition_number\\r\\n// Partition numbers are not necessarily 1-based because we are collecting the last N most recently added partitions.\\r\\n// From this set of partitions, restrict to up to maxPartitions, preferring higher numbered partitions.\\r\\n| sort by object_id asc, index_id asc, partition_number desc\\r\\n| extend partition_row_number = row_number(1, object_id != prev(object_id) or index_id != prev(index_id)),\\r\\n leaf_delete_count = leaf_delete_count + leaf_ghost_count,\\r\\n is_unique = is_unique and not (is_primary_key) and not (is_unique_constraint),\\r\\n interval_end = sample_time_utc\\r\\n| where partition_row_number <= {maxPartitions}\\r\\nand\\r\\n(\\r\\n\\\"{indexOperations}\\\" == \\\"A\\\"\\r\\nor\\r\\n\\\"{indexOperations}\\\" == \\\"R\\\" and (leaf_insert_count == 0 and leaf_delete_count == 0 and leaf_update_count == 0 and (singleton_lookup_count > 0 or range_scan_count > 0))\\r\\nor\\r\\n\\\"{indexOperations}\\\" == \\\"W\\\" and ((leaf_insert_count > 0 or leaf_delete_count > 0 or leaf_update_count > 0) and singleton_lookup_count == 0 and range_scan_count == 0)\\r\\nor\\r\\n\\\"{indexOperations}\\\" == \\\"RW\\\" and (leaf_insert_count > 0 or leaf_delete_count > 0 or leaf_update_count > 0 or singleton_lookup_count > 0 or range_scan_count > 0)\\r\\nor\\r\\n\\\"{indexOperations}\\\" == \\\"N\\\" and (leaf_insert_count == 0 and leaf_delete_count == 0 and leaf_update_count == 0 and singleton_lookup_count == 0 and range_scan_count == 0)\\r\\n)\\r\\n| project-away sample_time_utc, leaf_ghost_count\\r\\n);\\r\\n// column labels for each grid\\r\\nlet column_labels_string = dynamic(\\r\\n[\\r\\n\\\"key_columns\\\",\\\"included_columns\\\",\\\"columnstore_order_columns\\\",\\\"partitioning_column\\\",\\\"filter_definition\\\",\\\"partition_compression\\\"\\r\\n]);\\r\\nlet column_labels_number = dynamic(\\r\\n[\\r\\n\\\"fill_factor\\\",\\\"partition_row_count\\\"\\r\\n]);\\r\\nlet column_labels_number_id = dynamic(\\r\\n[\\r\\n\\\"object_id\\\",\\\"index_id\\\"\\r\\n]);\\r\\nlet column_labels_number_mb = dynamic(\\r\\n[\\r\\n\\\"in_row_partition_size_mb\\\",\\\"row_overflow_partition_size_mb\\\",\\\"lob_partition_size_mb\\\"\\r\\n]);\\r\\nlet column_labels_bool = dynamic(\\r\\n[\\r\\n\\\"is_unique\\\",\\\"ignore_dup_key\\\",\\\"is_primary_key\\\",\\\"is_unique_constraint\\\",\\\"is_padded\\\",\\\"is_disabled\\\",\\\"allow_row_locks\\\",\\\"allow_page_locks\\\",\\\"has_filter\\\",\\\"auto_created\\\",\\\"optimize_for_sequential_key\\\",\\\"is_xml_compressed\\\"\\r\\n]);\\r\\nlet column_labels_datetime = dynamic(\\r\\n[\\r\\n\\\"interval_start\\\",\\\"interval_end\\\"\\r\\n]);\\r\\n// result set for strings grid\\r\\nlet index_details_string = (\\r\\ncurrent_snapshot\\r\\n| project object_id, index_id, partition_number, key_columns, included_columns, columnstore_order_columns, partitioning_column, filter_definition,partition_compression\\r\\n| project object_id, index_id, partition_number, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_string to typeof(string) on (project column_label, column_value = tostring(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project object_id, index_id, partition_number, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_string = dynamic_to_json(make_list(c)) by object_id, index_id, partition_number // for each partition, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\n// result set for numbers grid\\r\\nlet index_details_number = (\\r\\ncurrent_snapshot\\r\\n| project object_id, index_id, partition_number, fill_factor, partition_row_count\\r\\n| project object_id, index_id, partition_number, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_number to typeof(string) on (project column_label, column_value = tolong(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project object_id, index_id, partition_number, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_number = dynamic_to_json(make_list(c)) by object_id, index_id, partition_number // for each partition, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\n// result set for id numbers grid\\r\\nlet index_details_number_id = (\\r\\ncurrent_snapshot\\r\\n| project object_id, index_id, partition_number\\r\\n| project object_id, index_id, partition_number, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_number_id to typeof(string) on (project column_label, column_value = toint(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project object_id, index_id, partition_number, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_number_id = dynamic_to_json(make_list(c)) by object_id, index_id, partition_number // for each partition, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\n// result set for mb numbers grid\\r\\nlet index_details_number_mb = (\\r\\ncurrent_snapshot\\r\\n| project object_id, index_id, partition_number, in_row_partition_size_mb, row_overflow_partition_size_mb, lob_partition_size_mb\\r\\n| project object_id, index_id, partition_number, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_number_mb to typeof(string) on (project column_label, column_value = toreal(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project object_id, index_id, partition_number, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_number_mb = dynamic_to_json(make_list(c)) by object_id, index_id, partition_number // for each partition, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\n// result set for boolean grid\\r\\nlet index_details_bool = (\\r\\ncurrent_snapshot\\r\\n| project object_id, index_id, partition_number, is_unique, ignore_dup_key, is_primary_key, is_unique_constraint, is_padded, is_disabled, allow_row_locks, allow_page_locks, has_filter, auto_created, optimize_for_sequential_key, is_xml_compressed\\r\\n| project object_id, index_id, partition_number, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_bool to typeof(string) on (project column_label, column_value = toboolean(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project object_id, index_id, partition_number, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_bool = dynamic_to_json(make_list(c)) by object_id, index_id, partition_number // for each partition, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\n// result set for datetime grid\\r\\nlet index_details_datetime = (\\r\\ncurrent_snapshot\\r\\n| project object_id, index_id, partition_number, interval_start, interval_end\\r\\n| project object_id, index_id, partition_number, columns = pack_all() // put all columns into a property bag\\r\\n| mv-apply column_label = column_labels_datetime to typeof(string) on (project column_label, column_value = todatetime(columns[column_label])) // create a row for each name/value pair\\r\\n| project-away columns\\r\\n| sort by column_label asc //make_list later will preserve sort order\\r\\n| project object_id, index_id, partition_number, c = pack(\\\"Property\\\", column_label, \\\"Value\\\", column_value) // introduce \\\"Property\\\" and \\\"Value\\\" column names\\r\\n| summarize details_datetime = dynamic_to_json(make_list(c)) by object_id, index_id, partition_number // for each partition, aggregate rowset into a json array of rows, to be used as grid source\\r\\n);\\r\\ncurrent_snapshot\\r\\n| lookup index_details_string on object_id, index_id, partition_number\\r\\n| lookup index_details_number on object_id, index_id, partition_number\\r\\n| lookup index_details_number_id on object_id, index_id, partition_number\\r\\n| lookup index_details_number_mb on object_id, index_id, partition_number\\r\\n| lookup index_details_bool on object_id, index_id, partition_number\\r\\n| lookup index_details_datetime on object_id, index_id, partition_number\\r\\n| extend total_index_ops = leaf_insert_count + leaf_delete_count + leaf_update_count + range_scan_count + singleton_lookup_count + forwarded_fetch_count,\\r\\n index_read_write_ratio = toreal(range_scan_count + singleton_lookup_count) / toreal(leaf_insert_count + leaf_delete_count + leaf_update_count),\\r\\n page_compression_success_ratio = toreal(page_compression_success_count) / toreal(page_compression_attempt_count)\\r\\n| extend is_unused_index = (not (is_unique or is_primary_key or is_unique_constraint) and index_type == \\\"NONCLUSTERED\\\" and total_index_ops == 0),\\r\\n is_write_only_index = (not (is_unique or is_primary_key or is_unique_constraint) and index_type == \\\"NONCLUSTERED\\\" and isfinite(index_read_write_ratio) and index_read_write_ratio == 0),\\r\\n is_write_mostly_index = (not (is_unique or is_primary_key or is_unique_constraint) and index_type == \\\"NONCLUSTERED\\\" and isfinite(index_read_write_ratio) and index_read_write_ratio > 0 and index_read_write_ratio <= 0.1),\\r\\n is_low_fill_factor = (fill_factor < 80 and fill_factor != 0 and index_type in (\\\"CLUSTERED\\\", \\\"NONCLUSTERED\\\")),\\r\\n is_row_locks_disabled = (not (allow_row_locks) and index_type in (\\\"CLUSTERED\\\", \\\"NONCLUSTERED\\\")),\\r\\n is_page_locks_disabled = (not (allow_page_locks) and index_type in (\\\"CLUSTERED\\\", \\\"NONCLUSTERED\\\")),\\r\\n is_inefficient_page_compression = (partition_compression == \\\"PAGE\\\" and isfinite(page_compression_success_ratio) and page_compression_success_ratio > 0.5),\\r\\n is_high_heap_forward_fetches = (index_type == \\\"HEAP\\\" and forwarded_fetch_count > 10000),\\r\\n index_tooltip = strcat(\\r\\n iif(is_primary_key, \\\"🔑 Primary key constraint\\\\n\\\", \\\"\\\"),\\r\\n iif(is_unique_constraint, \\\"🔑 Unique constraint\\\\n\\\", \\\"\\\"),\\r\\n iif(is_unique, \\\"1️⃣ Unique\\\\n\\\", \\\"\\\"),\\r\\n iif(has_filter, \\\"▼ Filtered\\\\n\\\", \\\"\\\"),\\r\\n iif(ignore_dup_key, \\\"Ignores duplicate key\\\\n\\\", \\\"\\\"),\\r\\n iif(is_padded, \\\"Padded\\\\n\\\", \\\"\\\"),\\r\\n iif(is_disabled, \\\"Disabled\\\\n\\\", \\\"\\\"),\\r\\n iif(auto_created, \\\"Auto-created\\\\n\\\", \\\"\\\"),\\r\\n iif(optimize_for_sequential_key, \\\"Optimized for sequential key\\\\n\\\", \\\"\\\")\\r\\n ),\\r\\n index_type = case(\\r\\n index_type == \\\"CLUSTERED\\\", \\\"Clustered\\\",\\r\\n index_type == \\\"HEAP\\\", \\\"Heap\\\",\\r\\n index_type == \\\"NONCLUSTERED\\\", \\\"Nonclustered\\\",\\r\\n index_type == \\\"CLUSTERED COLUMNSTORE\\\", \\\"Clustered columnstore\\\",\\r\\n index_type == \\\"NONCLUSTERED COLUMNSTORE\\\", \\\"Nonclustered columnstore\\\",\\r\\n index_type\\r\\n ),\\r\\n compression = case(\\r\\n partition_compression == \\\"NONE\\\", \\\"None\\\",\\r\\n partition_compression == \\\"ROW\\\", \\\"Row\\\",\\r\\n partition_compression == \\\"PAGE\\\", \\\"Page\\\",\\r\\n partition_compression == \\\"COLUMNSTORE\\\", \\\"Columnstore\\\",\\r\\n partition_compression == \\\"COLUMNSTORE_ARCHIVE\\\", \\\"Columnstore archive\\\",\\r\\n \\\"\\\"\\r\\n ),\\r\\n is_no_compression = (partition_compression == \\\"NONE\\\"),\\r\\n is_row_compression = (partition_compression == \\\"ROW\\\"),\\r\\n is_page_compression = (partition_compression == \\\"PAGE\\\"),\\r\\n is_columnstore_compression = (partition_compression == \\\"COLUMNSTORE\\\"),\\r\\n is_columnstore_archive_compression = (partition_compression == \\\"COLUMNSTORE_ARCHIVE\\\")\\r\\n| extend count_iw = iif(is_unused_index, 1, 0) + iif(is_write_only_index, 1, 0) + iif(is_write_mostly_index, 1, 0) + iif(is_low_fill_factor, 1, 0) + iif(is_row_locks_disabled, 1, 0) + iif(is_page_locks_disabled, 1, 0) + iif(is_inefficient_page_compression, 1, 0) + iif(is_high_heap_forward_fetches, 1, 0),\\r\\nindex_warnings =\\r\\nstrcat(\\r\\niif(is_unused_index, \\\"|⚠️ This index was not used by any query during the selected time interval. If all critical workloads have executed during this time, consider dropping this index to reduce storage overhead. Before dropping the index, review index operations on all readable replicas of this database, if any.|\\\\r\\\\n\\\", \\\"\\\"),\\r\\niif(is_write_only_index, \\\"|⚠️ During the selected time interval, this index was not used by any query, but was written to. If all critical workloads have executed during this time, consider dropping this index to avoid the overhead of unnecessary writes, and to reduce storage overhead. Before dropping the index, review index operations on all readable replicas of this database, if any.|\\\\r\\\\n\\\", \\\"\\\"),\\r\\niif(is_write_mostly_index, \\\"|⚠️ During the selected time interval, this index was used for reads much less than for writes. If all critical workloads have executed during this time, consider dropping this index to avoid the overhead of unnecessary writes, and to reduce storage overhead. Before dropping the index, review index operations on all readable replicas of this database, if any.|\\\\r\\\\n\\\", \\\"\\\"),\\r\\niif(is_low_fill_factor, strcat(\\\"|⚠️ The fill factor for this index is \\\", tostring(fill_factor), \\\"%, while the default and recommended fill factor is 100%. A lower fill factor increases memory, storage, and IO overhead. Execute `ALTER INDEX \\\", index_name, \\\" ON \\\", schema_name, \\\".\\\", object_name, \\\" REBUILD WITH (ONLINE = ON, MAXDOP = 8, FILLFACTOR = 100);` to set the fill factor to 100. Index rebuild can be a long-running and resource-intensive operation.|\\\\r\\\\n\\\"), \\\"\\\"),\\r\\niif(is_row_locks_disabled, strcat(\\\"|❗ Row locks for this index are disabled. This often leads to concurrency problems such as blocking and deadlocks. Execute `ALTER INDEX \\\", index_name, \\\" ON \\\", schema_name, \\\".\\\", object_name, \\\" SET (ALLOW_ROW_LOCKS = ON);` to enable index row locks.|\\\\r\\\\n\\\"), \\\"\\\"),\\r\\niif(is_page_locks_disabled, strcat(\\\"|❗ Page locks for this index are disabled. This often leads to concurrency problems such as blocking and deadlocks. Execute `ALTER INDEX \\\", index_name, \\\" ON \\\", schema_name, \\\".\\\", object_name, \\\" SET (ALLOW_PAGE_LOCKS = ON);` to enable index page locks.|\\\\r\\\\n\\\"), \\\"\\\"),\\r\\niif(is_inefficient_page_compression, strcat(\\\"|⚠️ This index partition uses page compression, however most page compression attempts are abandoned because they do not achieve sufficiently high compression ratio. To avoid the CPU overhead of ineffective compression attempts, execute `ALTER INDEX \\\", index_name, \\\" ON \\\", schema_name, \\\".\\\", object_name, \\\" REBUILD WITH (ONLINE = ON, MAXDOP = 8, DATA_COMPRESSION = ROW);` to rebuild the index with row compression. If the table is partitioned, execute `ALTER INDEX \\\", index_name, \\\" ON \\\", schema_name, \\\".\\\", object_name, \\\" REBUILD PARTITION = \\\", tostring(partition_number), \\\" WITH (ONLINE = ON, MAXDOP = 8, DATA_COMPRESSION = ROW);` to rebuild just this partition.|\\\\r\\\\n\\\"), \\\"\\\"),\\r\\niif(is_high_heap_forward_fetches, strcat(\\\"|⚠️ Reads from this partition of a heap table resulted in extra IO because the partition contains many forwarding pointers. Execute `ALTER TABLE \\\", schema_name, \\\".\\\", object_name, \\\" REBUILD WITH (ONLINE = ON, MAXDOP = 8);` to rebuild this heap and remove forwarding pointers. If the table is partitioned, execute `ALTER TABLE \\\", schema_name, \\\".\\\", object_name, \\\" REBUILD PARTITION = \\\", tostring(partition_number), \\\" WITH (ONLINE = ON, MAXDOP = 8);` to rebuild just this partition. Alternatively, create a clustered index on this table.|\\\\r\\\\n\\\"), \\\"\\\")\\r\\n)\\r\\n| extend count_iw = iif(count_iw > 0, count_iw, int(null))\\r\\n| project schema_name, object_name, index_name, index_type, partition_number, compression, total_index_ops, count_iw, index_warnings, index_tooltip, is_no_compression, is_row_compression, is_page_compression, is_columnstore_compression, is_columnstore_archive_compression, is_primary_key, is_unique_constraint, is_unique, has_filter, ignore_dup_key, is_padded, is_disabled, auto_created, optimize_for_sequential_key, leaf_insert_count, leaf_delete_count, leaf_update_count, range_scan_count, singleton_lookup_count, forwarded_fetch_count, details_string, details_number, details_number_id, details_number_mb, details_bool, details_datetime\\r\\n| sort by tolower(schema_name) asc,\\r\\n tolower(object_name) asc,\\r\\n case(\\r\\n index_type == \\\"Clustered\\\", 1,\\r\\n index_type == \\\"Heap\\\", 2,\\r\\n index_type == \\\"Clustered columnstore\\\", 3,\\r\\n index_type == \\\"Nonclustered\\\", 4,\\r\\n index_type == \\\"Nonclustered columnstore\\\", 5,\\r\\n 10\\r\\n ) asc,\\r\\n tolower(index_name) asc,\\r\\n partition_number asc\\r\\n;\",\"clusterName\":\"{adxClusterUri}\",\"databaseName\":\"{adxDatabase}\"}",
"size": 0,
"showAnalytics": true,
"noDataMessage": "There is no data for specified parameters.",
"exportedParameters": [
{
"fieldName": "index_warnings",
"parameterName": "index_warnings"
},
{
"fieldName": "details_string",
"parameterName": "details_string",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_number",
"parameterName": "details_number",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_number_id",
"parameterName": "details_number_id",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_number_mb",
"parameterName": "details_number_mb",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_bool",
"parameterName": "details_bool",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
},
{
"fieldName": "details_datetime",
"parameterName": "details_datetime",
"parameterType": 1,
"defaultValue": "[{\"Property\":\"\",\"Value\":\"\"}]"
}
],
"showExportToExcel": true,
"queryType": 9,
"visualization": "table",
"gridSettings": {
"formatters": [
{
"columnMatch": "index_type",
"formatter": 22,
"formatOptions": {
"compositeBarSettings": {
"labelText": "[\"index_type\"]",
"columnSettings": [
{
"columnName": "is_primary_key",
"color": "blueDark"
},
{
"columnName": "is_unique_constraint",
"color": "blue"
},
{
"columnName": "is_unique",
"color": "lightBlue"
},
{
"columnName": "has_filter",
"color": "turquoise"
},
{
"columnName": "ignore_dup_key",
"color": "yellow"
},
{
"columnName": "is_padded",
"color": "yellowDark"
},
{
"columnName": "is_disabled",
"color": "gray"
},
{
"columnName": "auto_created",
"color": "pink"
},
{
"columnName": "optimize_for_sequential_key",
"color": "purple"
}
]
}
},
"tooltipFormat": {
"tooltip": "[\"index_tooltip\"]"
}
},
{
"columnMatch": "compression",
"formatter": 22,
"formatOptions": {
"compositeBarSettings": {
"labelText": "[\"compression\"]",
"columnSettings": [
{
"columnName": "is_no_compression",
"color": "green"
},
{
"columnName": "is_row_compression",
"color": "greenDark"
},
{
"columnName": "is_page_compression",
"color": "magenta"
},
{
"columnName": "is_columnstore_compression",
"color": "pink"
},
{
"columnName": "is_columnstore_archive_compression",
"color": "purple"
}
],
"noRowsScaling": true
},
"customColumnWidthSetting": "17ch"
}
},
{
"columnMatch": "total_index_ops",
"formatter": 22,
"formatOptions": {
"compositeBarSettings": {
"labelText": "",
"columnSettings": [
{
"columnName": "singleton_lookup_count",
"color": "lightBlue"
},
{
"columnName": "range_scan_count",
"color": "grayBlue"
},
{
"columnName": "leaf_insert_count",
"color": "redBright"
},
{
"columnName": "leaf_update_count",
"color": "red"
},
{
"columnName": "leaf_delete_count",
"color": "redDark"
},
{
"columnName": "forwarded_fetch_count",
"color": "yellow"
}
],
"noRowsScaling": true
}
},
"tooltipFormat": {
"tooltip": "Total index operations in the selected time range, including [\"singleton_lookup_count\"] single-row lookups/seeks (light blue), [\"range_scan_count\"] range or full scans (gray blue), [\"leaf_insert_count\"] inserts (bright red), [\"leaf_update_count\"] updates (red), [\"leaf_delete_count\"] deletes (dark red), and [\"forwarded_fetch_count\"] forwarded fetches (yellow)"
}
},
{
"columnMatch": "count_iw",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "icons",
"thresholdsGrid": [
{
"operator": ">",
"thresholdValue": "0",
"representation": "2",
"text": "{0}{1}"
},
{
"operator": "Default",
"thresholdValue": null,
"representation": "Blank",
"text": "{0}{1}"
}
]
}
},
{
"columnMatch": "index_warnings",
"formatter": 5
},
{
"columnMatch": "index_tooltip",
"formatter": 5
},
{
"columnMatch": "is_no_compression",
"formatter": 5
},
{
"columnMatch": "is_row_compression",
"formatter": 5
},
{
"columnMatch": "is_page_compression",
"formatter": 5
},
{
"columnMatch": "is_columnstore_compression",
"formatter": 5
},
{
"columnMatch": "is_columnstore_archive_compression",
"formatter": 5
},
{
"columnMatch": "is_primary_key",
"formatter": 5
},
{
"columnMatch": "is_unique_constraint",
"formatter": 5
},
{
"columnMatch": "is_unique",
"formatter": 5
},
{
"columnMatch": "has_filter",
"formatter": 5
},
{
"columnMatch": "ignore_dup_key",
"formatter": 5
},
{
"columnMatch": "is_padded",
"formatter": 5
},
{
"columnMatch": "is_disabled",
"formatter": 5
},
{
"columnMatch": "auto_created",
"formatter": 5
},
{
"columnMatch": "optimize_for_sequential_key",
"formatter": 5
},
{
"columnMatch": "leaf_insert_count",
"formatter": 5
},
{
"columnMatch": "leaf_delete_count",
"formatter": 5
},
{
"columnMatch": "leaf_update_count",
"formatter": 5
},
{
"columnMatch": "range_scan_count",
"formatter": 5
},
{
"columnMatch": "singleton_lookup_count",
"formatter": 5
},
{
"columnMatch": "forwarded_fetch_count",
"formatter": 5
},
{
"columnMatch": "details_string",
"formatter": 5
},
{
"columnMatch": "details_number",
"formatter": 5
},
{
"columnMatch": "details_number_id",
"formatter": 5
},
{
"columnMatch": "details_number_mb",
"formatter": 5
},
{
"columnMatch": "details_bool",
"formatter": 5
},
{
"columnMatch": "details_datetime",
"formatter": 5
}
],
"filter": true,
"labelSettings": [
{
"columnId": "schema_name",
"label": "Schema"
},
{
"columnId": "object_name",
"label": "Object"
},
{
"columnId": "index_name",
"label": "Index"
},
{
"columnId": "index_type",
"label": "Type"
},
{
"columnId": "partition_number",
"label": "Partition"
},
{
"columnId": "compression",
"label": "Compression"
},
{
"columnId": "total_index_ops",
"label": "Operations"
},
{
"columnId": "count_iw",
"label": "Warnings"
}
]
}
},
"name": "index_metadata"
},
{
"type": 1,
"content": {
"json": "|Index warnings|\r\n|:--|\r\n{index_warnings}"
},
"conditionalVisibility": {
"parameterName": "index_warnings",
"comparison": "isNotEqualTo"
},
"name": "index_warnings"
},
{
"type": 12,
"content": {
"version": "NotebookGroup/1.0",
"groupType": "editable",
"title": "Selected index details",
"expandable": true,
"expanded": true,
"items": [
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"1.0.0\",\"content\":\"{details_number_id}\",\"transformers\":null}",
"size": 3,
"noDataMessage": "Unknown",
"queryType": 8
},
"customWidth": "50",
"name": "index_details_number_id"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"1.0.0\",\"content\":\"{details_number}\",\"transformers\":null}",
"size": 3,
"noDataMessage": "Unknown",
"queryType": 8,
"gridSettings": {
"formatters": [
{
"columnMatch": "Value",
"formatter": 0,
"numberFormat": {
"unit": 0,
"options": {
"style": "decimal",
"useGrouping": true
}
}
}
]
}
},
"customWidth": "50",
"name": "index_details_number"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"1.0.0\",\"content\":\"{details_bool}\",\"transformers\":null}",
"size": 3,
"noDataMessage": "Unknown",
"queryType": 8,
"gridSettings": {
"formatters": [
{
"columnMatch": "Value",
"formatter": 18,
"formatOptions": {
"thresholdsOptions": "icons",
"thresholdsGrid": [
{
"operator": "==",
"thresholdValue": "true",
"representation": "Check",
"text": ""
},
{
"operator": "==",
"thresholdValue": "false",
"representation": "Inactive",
"text": ""
},
{
"operator": "Default",
"thresholdValue": null,
"representation": "Blank",
"text": "{0}{1}"
}
]
},
"numberFormat": {
"unit": 0,
"options": {
"style": "decimal",
"useGrouping": false
}
}
}
]
}
},
"customWidth": "50",
"name": "index_details_bool"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"1.0.0\",\"content\":\"{details_string}\",\"transformers\":null}",
"size": 3,
"noDataMessage": "Unknown",
"queryType": 8
},
"customWidth": "50",
"name": "index_details_string"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"1.0.0\",\"content\":\"{details_number_mb}\",\"transformers\":null}",
"size": 3,
"noDataMessage": "Unknown",
"queryType": 8,
"gridSettings": {
"formatters": [
{
"columnMatch": "Value",
"formatter": 0,
"numberFormat": {
"unit": 4,
"options": {
"style": "decimal",
"useGrouping": true
}
}
}
]
}
},
"customWidth": "50",
"name": "index_details_number_mb"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "{\"version\":\"1.0.0\",\"content\":\"{details_datetime}\",\"transformers\":null}",
"size": 3,
"noDataMessage": "Unknown",
"queryType": 8,
"gridSettings": {
"formatters": [
{
"columnMatch": "Value",
"formatter": 6,
"numberFormat": {
"unit": 4,
"options": {
"style": "decimal",
"useGrouping": true
}
},
"dateFormat": {
"showUtcTime": null,
"formatName": "shortDateTimeNoMsPattern"
}
}
],
"sortBy": [
{
"itemKey": "Property",
"sortOrder": 2
}
]
},
"sortBy": [
{
"itemKey": "Property",
"sortOrder": 2
}
]
},
"customWidth": "50",
"name": "index_details_datetime"
}
],
"exportParameters": true
},
"conditionalVisibilities": [
{
"parameterName": "sqldb_database_index_metadata",
"comparison": "isEqualTo",
"value": "1"
},
{
"parameterName": "tabName",
"comparison": "isEqualTo",
"value": "Indexes"
}
],
"name": "index_details"
}
],
"$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}