Skip to content

Commit

Permalink
address rytaft feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
taroface committed Mar 28, 2024
1 parent 487c1e5 commit b7c44db
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

If you disable full scans, you can set the [`large_full_scan_rows` session variable]({% link {{ page.version.version }}/set-vars.md %}#large-full-scan-rows) to specify the maximum table size allowed for a full scan. If no alternative plan is possible, the optimizer will return an error.

If you disable full scans, and you provide an [index hint]({% link {{ page.version.version }}/indexes.md %}#selection), the optimizer will try to avoid a full scan while also respecting the index hint. If this is not possible, the optimizer will return an error. If you do not provide an index hint, the optimizer will return an error, the full scan will be logged, and the `sql.guardrails.full_scan_rejected.count` [metric]({% link {{ page.version.version }}/ui-overview-dashboard.md %}) will be updated.
If you disable full scans, and you provide an [index hint]({% link {{ page.version.version }}/indexes.md %}#selection), the optimizer will try to avoid a full scan while also respecting the index hint. If this is not possible, the optimizer will return an error. If you do not provide an index hint and it is not possible to avoid a full scan, the optimizer will return an error, the full scan will be logged, and the `sql.guardrails.full_scan_rejected.count` [metric]({% link {{ page.version.version }}/ui-overview-dashboard.md %}) will be updated.
4 changes: 3 additions & 1 deletion src/current/_includes/v23.2/sql/no-full-scan.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
{% include_cached copy-clipboard.html %}
~~~ sql
SELECT * FROM table_name@{FORCE_INDEX=index_name,NO_FULL_SCAN} WHERE b > 0;
~~~
~~~

This will force a constrained scan of the partial index. If a constrained scan of the partial index is not possible, an error will be returned.
2 changes: 1 addition & 1 deletion src/current/_includes/v23.2/sql/transactions-limit-rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ALTER ROLE ALL SET transaction_rows_read_err = 1000;
~~~

- When the `transaction_rows_written_err` [session setting]({% link {{ page.version.version }}/set-vars.md %}#transaction-rows-written-err) is enabled, transactions that write more than the specified number of rows will fail. In addition, the [optimizer]({% link {{ page.version.version }}/cost-based-optimizer.md %}) will not create query plans with scans that exceed the specified row limit. For example, to set a default value for all users at the cluster level:
- When the `transaction_rows_written_err` [session setting]({% link {{ page.version.version }}/set-vars.md %}#transaction-rows-written-err) is enabled, transactions that write more than the specified number of rows will fail. For example, to set a default value for all users at the cluster level:

{% include_cached copy-clipboard.html %}
~~~ sql
Expand Down
6 changes: 5 additions & 1 deletion src/current/v23.2/performance-best-practices-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ When the `disallow_full_table_scans` [session setting]({% link {{page.version.ve

{% include {{ page.version.version }}/sql/disallow-full-table-scans.md %}

#### Disallow transactions from reading or writing many rows
#### Disallow query plans that scan more than a number of rows

When the `transaction_rows_read_err` [session setting]({% link {{ page.version.version }}/set-vars.md %}#transaction-rows-read-err) is enabled, the [optimizer]({% link {{ page.version.version }}/cost-based-optimizer.md %}) will not create query plans with scans that exceed the specified row limit. See [Disallow transactions from reading or writing many rows](#disallow-transactions-from-reading-or-writing-many-rows).

### Disallow transactions from reading or writing many rows

{% include {{ page.version.version }}/sql/transactions-limit-rows.md %}

Expand Down
2 changes: 1 addition & 1 deletion src/current/v23.2/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ You can limit the number of rows written or read in a transaction at the cluster

{% include {{ page.version.version }}/sql/transactions-limit-rows.md %}

The limits are enforced after each statement of a transaction has been fully executed. The "write" limits apply to `INSERT`, `INSERT INTO SELECT FROM`, `INSERT ON CONFLICT`, `UPSERT`, `UPDATE`, and `DELETE` SQL statements. The "read" limits apply to the `SELECT` statement in addition to the statements subject to the "write" limits. The limits **do not** apply to `CREATE TABLE AS`, `SELECT`, `IMPORT`, `TRUNCATE`, `DROP`, `ALTER TABLE`, `BACKUP`, `RESTORE`, or `CREATE STATISTICS` statements.
The limits are enforced after each statement of a transaction has been fully executed. The "write" limits apply to `INSERT`, `INSERT INTO SELECT FROM`, `INSERT ON CONFLICT`, `UPSERT`, `UPDATE`, and `DELETE` SQL statements. The "read" limits apply to the `SELECT` statement in addition to the statements subject to the "write" limits. The limits **do not** apply to `CREATE TABLE AS`, `IMPORT`, `TRUNCATE`, `DROP`, `ALTER TABLE`, `BACKUP`, `RESTORE`, or `CREATE STATISTICS` statements.

{{site.data.alerts.callout_info}}
Enabling `transaction_rows_read_err` disables a performance optimization for mutation statements in implicit transactions where CockroachDB can auto-commit without additional network round trips.
Expand Down

0 comments on commit b7c44db

Please sign in to comment.