Memcache access for MySQL Cluster (or NDBCluster) provides faster access to the data because it avoids the SQL parsing overhead for simple lookups – which is a great feature. But what happens if I try to get multiple records via memcache API (multi-GET) and via SQL (SELECT with IN())? I’ve encountered this a few times now, so I decided to blog about it. I did a very simple benchmark with the following script:
#!/bin/bash mysql_server="192.168.56.75" mc_server="192.168.56.75" mysql_cmd="mysql -h${mysql_server} --silent --silent" mysql_schema="percona" mysql_table="memcache_t" mc_port=11211 mc_prefix="mt:" function populate_data () { nrec=$1 $mysql_cmd -e "delete from ${mysql_table};" $mysql_schema > /dev/null 2>&1 for rec in `seq 1 $nrec` do $mysql_cmd -e "insert into ${mysql_table} values ($rec, repeat('a',10), 0, 0);" $mysql_schema > /dev/null 2>&1 done } function mget_via_sql() { nrec=$1 in_list='' for rec in …[Read more]