Is there a way to dispatch stored procedure invocation on particular shard, based on sharding key (passed as procedure argument or somehow separately)?
For example we have a table, sharded between 3 nodes using HASH sharding strategy. All rows with key A
are stored on node 1
. I'd like to be sure that when I run procedure(A)
, it applies on node1
.
We are going to use Mysql Fabric tool, but other options considered as well.
1 Answer 1
Off the wall...
- Turn the Procedure into a function. Simply return
0
, or something irrelevant. Instead of
CALLing
the Procedure, invoke the Function this way:SELECT 0 WHERE key = 'A' AND routine(key);
The hope is that the sharding will kick in for the first part of the WHERE
and send the SELECT
only to the desired shard.
BTW, it appears that Fabric is being decommissioned.
-
Hi, thank you for the answer! Indeed, Fabric github repo looks abandoned. What's the alternative might be? We hope to avoid app-level sharding if possiblesilent-box– silent-box2017年04月07日 21:58:20 +00:00Commented Apr 7, 2017 at 21:58
-
Check out Spider. Sharding across only 3 nodes does not sound very severe; are you expecting a lot more? What brick wall has sent you to look at sharding - CPU? I/O? disk space? something else?Rick James– Rick James2017年04月07日 23:32:20 +00:00Commented Apr 7, 2017 at 23:32
-
Our use case is very specific actually - there is a huge amount of rows in one big table, and we can easily avoid multi-shard queries. The main goal is to scale writes and be sure indexes fit in RAM.silent-box– silent-box2017年04月08日 13:20:59 +00:00Commented Apr 8, 2017 at 13:20
-
"Fit in RAM" because you have lots of
SELECTs
?Rick James– Rick James2017年04月08日 14:23:25 +00:00Commented Apr 8, 2017 at 14:23 -
We want indexes to fit in RAM for performance reasons - the table is going to be huge + many fields on it have indexessilent-box– silent-box2017年04月08日 15:51:57 +00:00Commented Apr 8, 2017 at 15:51