Skip to content

Commit 77491ec

Browse files
adding note regarding sparse/dense arrays
1 parent af89e68 commit 77491ec

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/4-language-usage/4-control-structures/2-case-if-decode-nvl-nvl2-coalesce/g-4240.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
The `nvl2` function always evaluates all parameters before deciding which one to use. This can be harmful, if parameter 2 or 3 is either a function call or a select statement, as they will be executed regardless of whether parameter 1 contains a `null` value or not.
99

10+
Please note that:
11+
* Varrays are always dense
12+
* Associative arrays (or index-by tables) are either dense or sparse
13+
* Nested tables start dense and may become sparse
14+
1015
## Example (bad)
1116

1217
``` sql

docs/4-language-usage/4-control-structures/2-case-if-decode-nvl-nvl2-coalesce/g-4250.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
Conditions are evaluated top to bottom in branches of a `case` statement or chain of `if`/`elsif` statements. The first condition to evaluate as true leads to that branch being executed, the rest will never execute. Having an identical duplicated condition in another branch will never be reached and will be dead code.
99

10+
Please note that:
11+
* Varrays are always dense
12+
* Associative arrays (or index-by tables) are either dense or sparse
13+
* Nested tables start dense and may become sparse
14+
1015
## Example (bad)
1116

1217
``` sql

docs/4-language-usage/4-control-structures/3-flow-control/g-4360.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
When a loose (also called sparse) array is processed using a *numeric* `for loop` we have to check with all iterations whether the element exist to avoid a `no_data_found` exception. In addition, the number of iterations is not driven by the number of elements in the array but by the number of the lowest/highest element. The more gaps we have, the more superfluous iterations will be done.
99

10+
Please note that:
11+
* Varrays are always dense
12+
* Associative arrays (or index-by tables) are either dense or sparse
13+
* Nested tables start dense and may become sparse
14+
1015
## Example (bad)
1116

1217
``` sql

0 commit comments

Comments
 (0)