Skip to content

Commit

Permalink
Interleaving deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ericharmeling committed Mar 23, 2021
1 parent d32b50c commit 7e36a77
Show file tree
Hide file tree
Showing 47 changed files with 199 additions and 411 deletions.
5 changes: 0 additions & 5 deletions _includes/v20.2/faq/when-to-interleave-tables.html

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Within a single [transaction](transactions.html):

- DDL statements cannot be mixed with DML statements. As a workaround, you can split the statements into separate transactions. For more details, [see examples of unsupported statements](online-schema-changes.html#examples-of-statements-that-fail).
- As of version v2.1, you can run schema changes inside the same transaction as a [`CREATE TABLE`](create-table.html) statement. For more information, [see this example](online-schema-changes.html#run-schema-changes-inside-a-transaction-with-create-table).
- A `CREATE TABLE` statement containing [`FOREIGN KEY`](foreign-key.html) or [`INTERLEAVE`](interleave-in-parent.html) clauses cannot be followed by statements that reference the new table.
- A `CREATE TABLE` statement containing a [`FOREIGN KEY`](foreign-key.html) constraint cannot be followed by statements that reference the new table.
- Database, schema, table, and user-defined type names cannot be reused. For example, you cannot drop a table named `a` and then create (or rename) a different table with the name `a`. Similarly, you cannot rename a database named `a` to `b` and then create (or rename) a different database with the name `a`. As a workaround, split `RENAME TO`, `DROP`, and `CREATE` statements that reuse object names into separate transactions.
- [Schema change DDL statements inside a multi-statement transaction can fail while other statements succeed](#schema-change-ddl-statements-inside-a-multi-statement-transaction-can-fail-while-other-statements-succeed).
- As of v19.1, some schema changes can be used in combination in a single `ALTER TABLE` statement. For a list of commands that can be combined, see [`ALTER TABLE`](alter-table.html). For a demonstration, see [Add and rename columns atomically](rename-column.html#add-and-rename-columns-atomically).
Expand Down
5 changes: 0 additions & 5 deletions _includes/v21.1/faq/when-to-interleave-tables.html

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Within a single [transaction](transactions.html):

- DDL statements cannot be mixed with DML statements. As a workaround, you can split the statements into separate transactions. For more details, [see examples of unsupported statements](online-schema-changes.html#examples-of-statements-that-fail).
- As of version v2.1, you can run schema changes inside the same transaction as a [`CREATE TABLE`](create-table.html) statement. For more information, [see this example](online-schema-changes.html#run-schema-changes-inside-a-transaction-with-create-table).
- A `CREATE TABLE` statement containing [`FOREIGN KEY`](foreign-key.html) or [`INTERLEAVE`](interleave-in-parent.html) clauses cannot be followed by statements that reference the new table.
- A `CREATE TABLE` statement containing a [`FOREIGN KEY`](foreign-key.html) clause cannot be followed by statements that reference the new table.
- Database, schema, table, and user-defined type names cannot be reused. For example, you cannot drop a table named `a` and then create (or rename) a different table with the name `a`. Similarly, you cannot rename a database named `a` to `b` and then create (or rename) a different database with the name `a`. As a workaround, split `RENAME TO`, `DROP`, and `CREATE` statements that reuse object names into separate transactions.
- [Schema change DDL statements inside a multi-statement transaction can fail while other statements succeed](#schema-change-ddl-statements-inside-a-multi-statement-transaction-can-fail-while-other-statements-succeed).
- As of v19.1, some schema changes can be used in combination in a single `ALTER TABLE` statement. For a list of commands that can be combined, see [`ALTER TABLE`](alter-table.html). For a demonstration, see [Add and rename columns atomically](rename-column.html#add-and-rename-columns-atomically).
Expand Down
4 changes: 2 additions & 2 deletions releases/v20.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ Before [upgrading to CockroachDB v20.2](../v20.2/upgrade-cockroach-version.html)
- Cross-database references are deprecated in v20.2 (see [tracking issue](https://github.com/cockroachdb/cockroach/issues/55791)). In v20.2, creating cross-database references is disabled for [foreign keys](../v20.2/foreign-key.html), [views](../v20.2/views.html), and [sequence ownership](../v20.2/create-sequence.html) with the `sql.cross_db_fks.enabled`, `sql.cross_db_views.enabled`, and `sql.cross_db_sequence_owners.enabled` [cluster settings](../v20.2/cluster-settings.html) set to `false` by default. Note that any cross-database references that were created prior to a v20.2 upgrade are still allowed and are unaffected by these cluster settings.

After upgrading to v20.2, we recommend removing all cross-database references, and, if necessary, creating object references across user-defined schemas instead. For details on migrating a cluster that does not use user-defined schemas in its naming hierarchy, see [Migrating namespaces from previous versions of CockroachDB](../v20.2/sql-name-resolution.html#migrating-namespaces-from-previous-versions-of-cockroachdb).
- [Interleaved tables](../v20.2/interleave-in-parent.html) will be deprecated in a future release.
- [Interleaved tables](../v20.2/interleave-in-parent.html) are deprecated in CockroachDB v20.2, and will be permanently disabled in a future release (see [tracking issue](https://github.com/cockroachdb/cockroach/issues/52009)).

After upgrading to v20.2, we recommend that you convert any existing interleaved tables to non-interleaved tables and replace any existing interleaved secondary indexes with non-interleaved indexes. For instructions, see [Convert interleaved tables to non-interleaved tables](../v20.2/interleave-in-parent.html#convert-interleaved-tables-to-non-interleaved-tables).
After upgrading to v20.2, we recommend that you convert any existing interleaved tables to non-interleaved tables and replace any existing interleaved secondary indexes with non-interleaved indexes. For instructions, see [`INTERLEAVE IN PARENT` Deprecation](../v20.2/interleave-in-parent.html#deprecation).

### Known limitations

Expand Down
1 change: 0 additions & 1 deletion v20.2/alter-primary-key.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ To change an existing primary key without creating a secondary index from that p
-----------|-------------
`table_name` | The name of the table with the primary key that you want to modify.
`index_params` | The name of the column(s) that you want to use for the primary key. These columns replace the current primary key column(s).
`opt_interleave` | You can potentially optimize query performance by [interleaving tables](interleave-in-parent.html), which changes how CockroachDB stores your data.<br>{{site.data.alerts.callout_info}}[Hash-sharded indexes](hash-sharded-indexes.html) cannot be interleaved.{{site.data.alerts.end}}
`USING HASH WITH BUCKET COUNT` | Creates a [hash-sharded index](hash-sharded-indexes.html) with `n_buckets` number of buckets.<br>{{site.data.alerts.callout_info}}To enable hash-sharded indexes, set the `experimental_enable_hash_sharded_indexes` [session variable](set-vars.html) to `on`.{{site.data.alerts.end}}

## Required privileges
Expand Down
1 change: 0 additions & 1 deletion v20.2/backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Object | Depends On
Table with [foreign key](foreign-key.html) constraints | The table it `REFERENCES`; however, this dependency can be [removed during the restore](restore.html#skip_missing_foreign_keys).
Table with a [sequence](create-sequence.html) | The sequence it uses; however, this dependency can be [removed during the restore](restore.html#skip_missing_sequences).
[Views](views.html) | The tables used in the view's `SELECT` statement.
[Interleaved tables](interleave-in-parent.html) | The parent table in the [interleaved hierarchy](interleave-in-parent.html#interleaved-hierarchy).

### Users and privileges

Expand Down
1 change: 0 additions & 1 deletion v20.2/cockroach-workload.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ Flag | Description
`--fks` | Add foreign keys.<br><br>**Applicable commands:** `init` or `run`<br>**Default:** `true`
`--histograms` | The file to write per-op incremental and cumulative histogram data to.<br><br>**Applicable command:** `run`
`--init` | **Deprecated.** Use the `init` command instead.<br><br>**Applicable command:** `run`
`--interleaved` | Use [interleaved tables](interleave-in-parent.html).<br><br>**Applicable commands:** `init` or `run`
`--max-ops` | The maximum number of operations to run.<br><br>**Applicable command:** `run`
`--max-rate` | The maximum frequency of operations (reads/writes).<br><br>**Applicable command:** `run`<br>**Default:** `0`, which means unlimited.
`--mix` | Weights for the transaction mix.<br><br>**Applicable commands:** `init` or `run`<br>**Default:** `newOrder=10,payment=10,orderStatus=1,delivery=1,stockLevel=1`, which matches the [TPC-C specification](http://www.tpc.org/tpc_documents_current_versions/current_specifications.asp).
Expand Down
2 changes: 0 additions & 2 deletions v20.2/cost-based-optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ If it is not possible to use the algorithm specified in the hint, an error is si


{{site.data.alerts.callout_info}}
With queries on [interleaved tables](interleave-in-parent.html), the optimizer might choose to use a merge join to perform a [foreign key](foreign-key.html) check when a lookup join would be more optimal.

<span class="version-tag">New in v20.2:</span> To make the optimizer prefer lookup joins to merge joins when performing foreign key checks, set the `prefer_lookup_joins_for_fks` [session variable](set-vars.html) to `on`.
{{site.data.alerts.end}}

Expand Down
1 change: 0 additions & 1 deletion v20.2/create-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Parameter | Description
`column_name` | The name of the column you want to index.
`ASC` or `DESC`| Sort the column in ascending (`ASC`) or descending (`DESC`) order in the index. How columns are sorted affects query results, particularly when using `LIMIT`.<br><br>__Default:__ `ASC`
`STORING ...`| Store (but do not sort) each column whose name you include.<br><br>For information on when to use `STORING`, see [Store Columns](#store-columns). Note that columns that are part of a table's [`PRIMARY KEY`](primary-key.html) cannot be specified as `STORING` columns in secondary indexes on the table.<br><br>`COVERING` and `INCLUDE` are aliases for `STORING` and work identically.
`opt_interleave` | You can potentially optimize query performance by [interleaving indexes](interleave-in-parent.html), which changes how CockroachDB stores your data.<br>{{site.data.alerts.callout_info}}[Hash-sharded indexes](hash-sharded-indexes.html) cannot be interleaved.{{site.data.alerts.end}}
`opt_partition_by` | An [enterprise-only](enterprise-licensing.html) option that lets you [define index partitions at the row level](partitioning.html).
`opt_where_clause` | <span class="version-tag">New in v20.2:</span> An optional `WHERE` clause that defines the predicate boolean expression of a [partial index](partial-indexes.html).
`USING HASH WITH BUCKET COUNT` | Creates a [hash-sharded index](hash-sharded-indexes.html) with `n_buckets` number of buckets.<br>{{site.data.alerts.callout_info}}To enable hash-sharded indexes, set the `experimental_enable_hash_sharded_indexes` [session variable](set-vars.html) to `on`.{{site.data.alerts.end}}
Expand Down
5 changes: 2 additions & 3 deletions v20.2/create-table-as.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ table td:first-child {

## Limitations

Tables created with `CREATE TABLE ... AS` are not [interleaved](interleave-in-parent.html) with other tables.
The default rules for [column families](column-families.html) apply.
- The default rules for [column families](column-families.html) apply.

The [primary key](primary-key.html) of tables created with `CREATE TABLE ... AS` is not automatically derived from the query results. You must specify new primary keys at table creation. For examples, see [Specify a primary key](create-table-as.html#specify-a-primary-key) and [Specify a primary key for partitioning](create-table-as.html#specify-a-primary-key-for-partitioning).
- The [primary key](primary-key.html) of tables created with `CREATE TABLE ... AS` is not automatically derived from the query results. You must specify new primary keys at table creation. For examples, see [Specify a primary key](create-table-as.html#specify-a-primary-key) and [Specify a primary key for partitioning](create-table-as.html#specify-a-primary-key-for-partitioning).

## Examples

Expand Down
8 changes: 1 addition & 7 deletions v20.2/create-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ The user must have the `CREATE` [privilege](authorization.html#assign-privileges
{% include {{ page.version.version }}/sql/diagrams/like_table_option_list.html %}
</div>

**opt_interleave ::=**

<div>
{% include {{ page.version.version }}/sql/diagrams/opt_interleave.html %}
</div>

**opt_with_storage_parameter_list ::=**

Expand All @@ -100,7 +95,6 @@ Parameter | Description
`family_def` | An optional, comma-separated list of [column family definitions](column-families.html). Column family names must be unique within the table but can have the same name as columns, constraints, or indexes.<br><br>A column family is a group of columns that are stored as a single key-value pair in the underlying key-value store. CockroachDB automatically groups columns into families to ensure efficient storage and performance. However, there are cases when you may want to manually assign columns to families. For more details, see [Column Families](column-families.html).
`table_constraint` | An optional, comma-separated list of [table-level constraints](constraints.html). Constraint names must be unique within the table but can have the same name as columns, column families, or indexes.
`LIKE table_name like_table_option_list` | <span class="version-tag">New in v20.2:</span> Create a new table based on the schema of an existing table, using supported specifiers. For details, see [Create a table like an existing table](#create-a-table-like-an-existing-table). For examples, see [Create a new table from an existing one](#create-a-new-table-from-an-existing-one).
`opt_interleave` | You can potentially optimize query performance by [interleaving tables](interleave-in-parent.html), which changes how CockroachDB stores your data.<br>{{site.data.alerts.callout_info}}[Hash-sharded indexes](hash-sharded-indexes.html) cannot be interleaved.{{site.data.alerts.end}}
`opt_partition_by` | An [enterprise-only](enterprise-licensing.html) option that lets you define table partitions at the row level. You can define table partitions by list or by range. See [Define Table Partitions](partitioning.html) for more information.
`opt_where_clause` | <span class="version-tag">New in v20.2:</span> An optional `WHERE` clause that defines the predicate boolean expression of a [partial index](partial-indexes.html).
`opt_with_storage_parameter_list` | <span class="version-tag">New in v20.2:</span> A comma-separated list of [spatial index tuning parameters](spatial-indexes.html#index-tuning-parameters). Supported parameters include `fillfactor`, `s2_max_level`, `s2_level_mod`, `s2_max_cells`, `geometry_min_x`, `geometry_max_x`, `geometry_min_y`, and `geometry_max_y`. The `fillfactor` parameter is a no-op, allowed for PostgreSQL-compatibility.<br><br>For details, see [Spatial index tuning parameters](spatial-indexes.html#index-tuning-parameters). For an example, see [Create a spatial index that uses all of the tuning parameters](spatial-indexes.html#create-a-spatial-index-that-uses-all-of-the-tuning-parameters).
Expand Down Expand Up @@ -131,7 +125,7 @@ The following options are supported:
To exclude specifiers, use the `EXCLUDING` keyword. Excluding specifiers can be useful if you want to use `INCLUDING ALL`, and exclude just one or two specifiers. The last `INCLUDING`/`EXCLUDING` keyword for a given specifier takes priority.

{{site.data.alerts.callout_info}}
Column families, interleavings, partitioning, and foreign key constraints
Column families, partitioning, and foreign key constraints
cannot be preserved from the old table and will have to be recreated
manually in the new table if the user wishes.
{{site.data.alerts.end}}
Expand Down
5 changes: 1 addition & 4 deletions v20.2/foreign-key.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ Parameter | Description

Because the foreign key constraint requires per-row checks on two tables, statements involving foreign key or referenced columns can take longer to execute. You're most likely to notice this with operations like bulk inserts into the table with the foreign keys. For bulk inserts into new tables, use the [`IMPORT`](import.html) statement instead of [`INSERT`](insert.html).

You can improve the performance of some statements that use foreign keys by also using [`INTERLEAVE IN PARENT`](interleave-in-parent.html), but there are tradeoffs. For more information about the performance implications of interleaved tables (as well as the limitations), see the **Interleave tables** section of [Performance best practices](performance-best-practices-overview.html#interleave-tables).

{{site.data.alerts.callout_danger}}
Using [`IMPORT INTO`](import-into.html) will invalidate foreign keys without a [`VALIDATE CONSTRAINT`](validate-constraint.html) statement.
{{site.data.alerts.end}}
Expand Down Expand Up @@ -194,8 +192,7 @@ CREATE TABLE packages (
delivery_date DATE,
PRIMARY KEY (customer, "order", id),
CONSTRAINT fk_order FOREIGN KEY (customer, "order") REFERENCES orders
) INTERLEAVE IN PARENT orders (customer, "order")
;
);
~~~

## Usage examples
Expand Down
4 changes: 0 additions & 4 deletions v20.2/hash-sharded-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ To create a hash-sharded index, set the `experimental_enable_hash_sharded_indexe

To change the bucket size of an existing hash-sharded primary key index, use an [`ALTER PRIMARY KEY`](alter-primary-key.html) statement with a [`USING HASH WITH BUCKET_COUNT = n_buckets` clause](sql-grammar.html#opt_hash_sharded) that specifies the new bucket size and the existing primary key columns.

{{site.data.alerts.callout_info}}
Hash-sharded indexes cannot be [interleaved](interleave-in-parent.html).
{{site.data.alerts.end}}

## Examples

For an example of a hash-sharded index, see [Create a hash-sharded secondary index](create-index.html#create-a-hash-sharded-secondary-index).
Expand Down
1 change: 0 additions & 1 deletion v20.2/import-into.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ Google Cloud:
- While importing into an existing table, the table is taken offline.
- After importing into an existing table, [constraints](constraints.html) will be un-validated and need to be [re-validated](validate-constraint.html).
- Imported rows must not conflict with existing rows in the table or any unique secondary indexes.
- `IMPORT INTO` works for only a single existing table, and the table must not be [interleaved](interleave-in-parent.html).
- `IMPORT INTO` cannot be used within a [transaction](transactions.html).
- `IMPORT INTO` can sometimes fail with a "context canceled" error, or can restart itself many times without ever finishing. If this is happening, it is likely due to a high amount of disk contention. This can be mitigated by setting the `kv.bulk_io_write.max_rate` [cluster setting](cluster-settings.html) to a value below your max disk write speed. For example, to set it to 10MB/s, execute:
{% include copy-clipboard.html %}
Expand Down
Loading

0 comments on commit 7e36a77

Please sign in to comment.