-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: sequences should be automatically added to a table for postgres compatibility #26730
Comments
We could change our serial type to use sequences, but that would make it slower, so would probably be a bad choice for most users. Without doing that, it's unclear what would trigger autocreating the sequence — maybe if we see a |
I'd like to challenge the idea that "serial using sequences would be a bad choice". I think we're gaining more with proper pg compat on this one. We should then propose a crdb-specific feature for replacement if users want more performance. |
The compat win would definitely be nice. Maybe we could try switching our TPCC benchmark roachtest to use sequences, and check the perf impact? I suspect it will slow things down a lot, but I'm not sure. Also, a lot could be done to improve perf of sequences, such as pre-allocating values in memory for each node. This seems par for the course even on single-node databases (see Postgres |
yes a sequence cache is what I had in mind. We'll do some brainstorming about that I'm sure. The overarching problem is to solve #26925. |
28575: sql: introduce virtual sequences and use with SERIAL r=knz a=knz Very good idea by @BramGruneir New features: virtual sequences (opt-in) and create-sequence-upon-SERIAL (opt-in). See individual commits for details and release notes. For reference: - I made everything opt-in here (i.e. default to previous CockroachDB behavior) to minimize risk. - UX with Hibernate will thus not automatically be improved. We need to inform users (and upgrade our tutorials/docs) that this experimental feature is available and how to use it to unblock problems. - It is possible that making the new default be `virtual_sequence` will both be backward-compatible with performance and unlock UX for Hibernate users. This has @awoods187 preference I think. However I propose to only flip that switch after we've seen a week or two pass with this patch merged. Fixes #22607 (using the new setting set to `sql_sequence`). Fixes #24062 (using the new setting set to `sql_sequence`). Fixes #26730 (using the new setting set to either `virtual_sequence` or `sql_sequence`). Co-authored-by: Raphael 'kena' Poss <[email protected]>
This came out of hibernate's test suite, the following tests fail:
Due to a sequence not existing.
Postgres automatically creates a sequence whenever a serial or big serial type is used. We don't do this.
The text was updated successfully, but these errors were encountered: