Skip to content

sql: remove interleaved tables #52009

@jordanlewis

Description

@jordanlewis

Interleaved tables are a mixed bag. Their theoretical pros are:

  • improved performance for bulk inserts across multiple tables, if the data has a shared prefix, since the keys would go to the same range
  • improved performance for joins on co-interleaved tables since data can be read in a single scan on a single range

In reality, they have a large cons list:

  • the interleaved join code is complex, undertested, and planned only in precise circumstances. it also only permits joins of 2 interleaved tables at the same time today, severely limiting the performance upside
  • doing bulk inserts into more than one table is awkward (you'd need to use CTEs)
  • the code today doesn't actually coalesce the writes of these bulk inserts into a single batch anyway, so you get no actual performance gain
  • the code's existence is quite burdensome, as it's complex and provides extra surfaces for bugs to accumulate on, and more things to think about when developing everyday features across every SQL team, plus backup and restore. Schema changes and bulk operations are complicated by the existence of interleaved tables, and often features must be shipped without interleaved support due to the complexity of supporting them.

We should remove interleaved tables altogether from CockroachDB, and that's what this issue tracks.

Primary Key Changes gives us an offramp for people who use interleaved tables. The procedure is that you should alter the primary key of all of the child interleaved tables to no longer be interleaved, one by one, until there are no interleaved children left.

Here's a proposal, using input from the schema team and others:

  • in 20.2, we'll mark interleaved tables as deprecated in the documentation. Creating new interleaved tables will return a deprecation notice, and won't work unless a session (cluster?) setting is enabled.
  • in 21.2, we'll change nodes to fail to join the cluster if any interleaved tables are present in the cluster. In that version or the version after, we can also remove all of the interleave table code from the codebase.

Epic: CRDB-1582

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions