Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 43.3Mb
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.2Kb
Man Pages (Zip) - 402.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
Excerpts from this Manual

MySQL 8.0 Reference Manual  / ...  / The InnoDB Storage Engine  / InnoDB memcached Plugin  /  InnoDB memcached Multiple get and Range Query Support

17.20.4 InnoDB memcached Multiple get and Range Query Support

Thedaemon_memcached plugin supports multiple get operations (fetching multiple key-value pairs in a singlememcached query) and range queries.

Multiple get Operations

The ability to fetch multiple key-value pairs in a singlememcached query improves read performance by reducing communication traffic between the client and server. ForInnoDB, it means fewer transactions and open-table operations.

The following example demonstrates multiple-get support. The example uses thetest.city table described inCreating a New Table and Column Mapping.

mysql> USE test;mysql> SELECT * FROM test.city;+---------+-----------+-------------+---------+-------+------+--------+| city_id | name      | state       | country | flags | cas  | expiry |+---------+-----------+-------------+---------+-------+------+--------+| B       | BANGALORE | BANGALORE   | IN      |     0 |    1 |      0 || C       | CHENNAI   | TAMIL NADU  | IN      |     0 |    0 |      0 || D       | DELHI     | DELHI       | IN      |     0 |    0 |      0 || H       | HYDERABAD | TELANGANA   | IN      |     0 |    0 |      0 || M       | MUMBAI    | MAHARASHTRA | IN      |     0 |    0 |      0 |+---------+-----------+-------------+---------+-------+------+--------+

Run aget command to retrieve all values from thecity table. The results are returned in a key-value pair sequence.

telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.get B C D H MVALUE B 0 22BANGALORE|BANGALORE|INVALUE C 0 21CHENNAI|TAMIL NADU|INVALUE D 0 14DELHI|DELHI|INVALUE H 0 22HYDERABAD|TELANGANA|INVALUE M 0 21MUMBAI|MAHARASHTRA|INEND

When retrieving multiple values in a singleget command, you can switch tables (using@@containers.name notation) to retrieve the value for the first key, but you cannot switch tables for subsequent keys. For example, the table switch in this example is valid:

get @@aaa.AA BBVALUE @@aaa.AA 8 12HELLO, HELLOVALUE BB 10 16GOODBYE, GOODBYEEND

Attempting to switch tables again in the sameget command to retrieve a key value from a different table is not supported.

There is no limit the number of keys that can be retrieved by a multiple get operation, but there is a 128MB memory limit for storing the result.

Range Queries

For range queries, thedaemon_memcached plugin supports the following comparison operators:<,>,<=,>=. An operator must be preceded by an@ symbol. When a range query finds multiple matching key-value pairs, results are returned in a key-value pair sequence.

The following examples demonstrate range query support. The examples use thetest.city table described inCreating a New Table and Column Mapping.

mysql> SELECT * FROM test.city;+---------+-----------+-------------+---------+-------+------+--------+| city_id | name      | state       | country | flags | cas  | expiry |+---------+-----------+-------------+---------+-------+------+--------+| B       | BANGALORE | BANGALORE   | IN      |     0 |    1 |      0 || C       | CHENNAI   | TAMIL NADU  | IN      |     0 |    0 |      0 || D       | DELHI     | DELHI       | IN      |     0 |    0 |      0 || H       | HYDERABAD | TELANGANA   | IN      |     0 |    0 |      0 || M       | MUMBAI    | MAHARASHTRA | IN      |     0 |    0 |      0 |+---------+-----------+-------------+---------+-------+------+--------+

Open a telnet session:

telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.

To get all values greater thanB, enterget @>B:

get @>BVALUE C 0 21CHENNAI|TAMIL NADU|INVALUE D 0 14DELHI|DELHI|INVALUE H 0 22HYDERABAD|TELANGANA|INVALUE M 0 21MUMBAI|MAHARASHTRA|INEND

To get all values less thanM, enterget @<M:

get @<MVALUE B 0 22BANGALORE|BANGALORE|INVALUE C 0 21CHENNAI|TAMIL NADU|INVALUE D 0 14DELHI|DELHI|INVALUE H 0 22HYDERABAD|TELANGANA|INEND

To get all values less than and includingM, enterget @<=M:

get @<=MVALUE B 0 22BANGALORE|BANGALORE|INVALUE C 0 21CHENNAI|TAMIL NADU|INVALUE D 0 14DELHI|DELHI|INVALUE H 0 22HYDERABAD|TELANGANA|INVALUE M 0 21MUMBAI|MAHARASHTRA|IN

To get values greater thanB but less thanM, enterget @>B@<M:

get @>B@<MVALUE C 0 21CHENNAI|TAMIL NADU|INVALUE D 0 14DELHI|DELHI|INVALUE H 0 22HYDERABAD|TELANGANA|INEND

A maximum of two comparison operators can be parsed, one being either a 'less than' (@<) or 'less than or equal to' (@<=) operator, and the other being either a 'greater than' (@>) or 'greater than or equal to' (@>=) operator. Any additional operators are assumed to be part of the key. For example, if you issue aget command with three operators, the third operator (@>C) is treated as part of the key, and theget command searches for values smaller thanM and greater thanB@>C.

get @<M@>B@>CVALUE C 0 21CHENNAI|TAMIL NADU|INVALUE D 0 14DELHI|DELHI|INVALUE H 0 22HYDERABAD|TELANGANA|IN