One query can wreck your database performance. Find out how I found this silent killer and sped up my apphttps://schneems.com/2017/07/18/how-i-reduced-my-db-server-load-by-80/ …
-
-
Replying to @schneems
I've got some ideas for how we could fix this in Active Record in the long term, what do you think ?https://www.reddit.com/r/ruby/comments/6o1wk9/how_i_reduced_my_db_server_load_by_80/ …
4 replies 1 retweet 3 likes -
Replying to @schneems
It would be nice of db constraints and rails validations could be auto-in-sync.
4 replies 1 retweet 3 likes -
Replying to @davetron5000 @schneems
The issue is that `valid?` can't work that way. Also determining which column was affected is ugly on not-PG
2 replies 0 retweets 0 likes -
We're doing it just fine in Ecto for Postgres, MySQL and Mongo. The only major problem is with SQLite.
1 reply 0 retweets 1 like -
How are y'all doing it in MySQL? Error doesn't present the relevant info. Or does the wire protocol expose it and just the C API doesn't?
1 reply 0 retweets 0 likes -
The error contains the violated constraint name. We infer the name that would be automatically generated, otherwise, you need to provide it.
2 replies 0 retweets 3 likes -
Ah that makes sense. Thanks for clarifying
1 reply 0 retweets 0 likes -
would that be generalizable? work better than trying to save and re-playing the validation in Ruby?
1 reply 0 retweets 0 likes
SQLite still only has the error message, and we don't have as much control over constraint names. I like your idea of replaying them
-
-
If we have the violated constraint name, maybe we could match the column by finding the constraint in INFORMATION_SCHEMA
1 reply 0 retweets 0 likes -
Replying to @jhawthorn @sgrif and
One downside of that approach is if there's multiple failing fields, we don't know that, only the first failure. Our UI suffers.
0 replies 0 retweets 1 like
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.