Skip to content

document reference table source field#1270

Merged
frouioui merged 2 commits intoprodfrom
maxeng-ref-source
Dec 14, 2022
Merged

document reference table source field#1270
frouioui merged 2 commits intoprodfrom
maxeng-ref-source

Conversation

@maxenglander
Copy link
Copy Markdown
Collaborator

@maxenglander maxenglander commented Dec 4, 2022

Accompanies vitessio/vitess#11875.

Document improvements to routing for reference tables:

  • Support for globally routing reference tables that are identically named with their source.
  • Optimize joining so that reference tables are joined with the optimal keyspace.
  • Redirect DML for reference tables back to their source.

Given:

  • An unsharded keyspace k1 and an sharded keyspace k2.
  • Source table k1.r and reference table k2.r.
  • Unsharded table k1.a
  • Sharded table k2.b.

And these queries:

  1. SELECT k2.b JOIN k1.r
  2. SELECT a JOIN r
  3. SELECT b JOIN r
  4. INSERT INTO r

The first query will succeed but will issue queries to both k1 and k2, even though the query could be satisifed just by routing to k2.

The next three queries will fail with https://github.com/vitessio/vitess/blob/4ff02c0f7af35a520bfc90d32e77fc13810dfdd9/go/vt/vtgate/vindexes/vschema.go#L566

This PR documents new support for optimally joining and globally routing these three queries:

  1. The first query is routed exclusively to k2.
  2. The second query will join k1.a to k1.r.
  3. The third query will join k2.b to k2.r.
  4. The fourth query will be routed to the unsharded source table r.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 4, 2022

Deploy Preview for vitess ready!

Name Link
🔨 Latest commit 6cb03d6
🔍 Latest deploy log https://app.netlify.com/sites/vitess/deploys/63937f2a3bb6360009a8a95f
😎 Deploy Preview https://deploy-preview-1270--vitess.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@maxenglander maxenglander force-pushed the maxeng-ref-source branch 2 times, most recently from af3e939 to 96a4540 Compare December 4, 2022 01:57
Signed-off-by: Max Englander <max@planetscale.com>
This differs from the standard mysql, in mysql unqualified tables will fail if the correct database is not set on the connection.

This feature works only for unique table names provided in the [VSchema](https://vitess.io/docs/concepts/vschema/), and only when no default keyspace is set on the connection.
This feature works only for unique table names provided in the [VSchema](https://vitess.io/docs/concepts/vschema/), and only when no default keyspace is set on the connection. One exception to the uniqueness rule is [Reference Tables](../../../user-guides/vschema-guide/advanced-vschema/#reference-tables) that share a name with an explicitly specified `source` table.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no default keyspace is set on the connection
Do you have a link to 'default keyspace' documentation. Can you u hyperlink it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rsajwani I do not, as far as I can tell this is the only page that use this phrase.

@rsajwani
Copy link
Copy Markdown
Collaborator

rsajwani commented Dec 7, 2022

cc: @vitessio/query-serving

Signed-off-by: Max Englander <max@planetscale.com>
Copy link
Copy Markdown
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good to me.

@frouioui frouioui merged commit 0c5cd18 into prod Dec 14, 2022
@frouioui frouioui deleted the maxeng-ref-source branch December 14, 2022 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants