Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Share the column and table name quote cache between connections #36637
For apps using multiple database connections, especially if they are shards or replicas, different connections are very likely to share parts or all their table and column names.
Because of this I believe this cache should not be stored as an instance variable of
Should it use a Concurrent::Map ?
I believe it doesn't need it because if a race condition was to happen, both thread would generate the same value. So the locking needed would cause more harm than good.
Jul 10, 2019
@casperisfine I know this PR is a week old, but you said in your description:
Doesn’t this change make the assumption that all connections will share these and effectively break scenarios where databases don’t match?
I might be missing something completely obvious, so thought I’d ask.
@ryantownsend I'm not quite sure to understand what you mean exactly.
The change make it so that the cache is now shared on the adapter class. Which mean it's only shared between connections of the exact same type. e.g.
Then, yes you'll only save memory if the two databases shared some column and table names. That's quite a common scenario if you make use of sharding, or simply use a read replica.
Then you don't gain much (I still bet your shards will share a few names such as
If by that you mean eagerloading of the cache, it's in my plans, but it's a little bit tricky.