-
Notifications
You must be signed in to change notification settings - Fork 176
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
[Idea] Are there any concerns about creating PostgreSQL exclusion constraints (gist)? #191
Comments
Hey @cbortz, thanks for sharing! From what I can tell, it appears to be unsafe (for existing tables). CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE TABLE t1 (value int);
INSERT INTO t1 SELECT i FROM generate_series(1,1000000) i;
ALTER TABLE t1 ADD CONSTRAINT c1 EXCLUDE USING gist (value WITH =); -- slow, table locked Also, I'm not sure there's a safe way to do it. ALTER TABLE t1 ADD CONSTRAINT c1 EXCLUDE USING gist (value WITH =) NOT VALID;
ERROR: EXCLUDE constraints cannot be marked NOT VALID I've added it to the plan (#177) for when Rails 7.1 rc1 is released. |
@ankane Glad it was helpful. Thanks for sharing that example from your experiment! 🙏 |
Hey @cbortz, added (a little early) in the commit above. Thanks again for the suggestion! |
@ankane As always, thank you for continuing to maintain this library (and all of the others)! |
Hey y'all. Thanks for this super helpful gem.
Last month rails/rails#40224 was merged, which introduces support for PostgreSQL exclusion constraints using gist. Among other things, there is a new migration method
add_exclusion_constraint
.As far as I can tell, it hasn't yet been staged for an official release, but it's in the main branch at this point.
Admittedly, I don't have enough experience to know what might (if anything) make this type of table alteration unsafe, but thought it may be relevant to this project. So, I figured I'd at least get a conversation started.
The text was updated successfully, but these errors were encountered: