countries where people drive on the right, and the average size of countries whose names start with “U” : 

mysql> SELECT AVG(population) FROM multicol WHERE drive_side = ’R’; +-------------------+ | avg(population) | +-------------------+ | 261304724.7142857 | +-------------------+ mysql> SELECT SUM(area_sq_km) FROM multicol WHERE country LIKE ’U%’; +-----------------+ | sum(area_sq_km) | +-----------------+ | 10153885 | +-----------------+ 

Because the population  and area_sq_km  columns store character data rather than strongly typed numeric data, functions such as AVG()  and SUM()  work by converting each value to a number first. This approach does not work  for operators such as <  or > , for example, when comparing character- based values, 9 > 1000 , which is not expected from a clause such as ORDER BY population DESC . For the most accurate type treatment, perform queries against views that cast numeric columns to the appropriate types. This technique lets you issue simple SELECT *  queries from database applications, while ensuring that casting, filtering, and ordering is correct. The following example shows a view that can be queried to find the top three countries in descending order of population, with the results reflecting the latest data in the multicol  table, and with population and area figures treated as numbers: 

mysql> CREATE VIEW populous_countries AS SELECT country, cast(population as unsigned integer) population, cast(area_sq_km as unsigned integer) area_sq_km, drive_side FROM multicol ORDER BY CAST(population as unsigned integer) DESC LIMIT 3; mysql> SELECT * FROM populous_countries; +---------+------------+------------+------------+ | country | population | area_sq_km | drive_side | +---------+------------+------------+------------+ | China | 1347350000 | 9640821 | R | | India | 1210193422 | 3287263 | L | | USA | 314242000 | 9826675 | R | +---------+------------+------------+------------+ mysql> DESC populous_countries; +------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------------+------+-----+---------+-------+ | country | varchar(128) | NO | | | | | population | bigint(10) unsigned | YES | | NULL | | | area_sq_km | int(9) unsigned | YES | | NULL | | | drive_side | varchar(1) | YES | | NULL | | +------------+---------------------+------+-----+---------+-------+ 

## 15.20.6.2 Adapting a memcached Application for the InnoDB memcached Plugin 

Consider these aspects of MySQL and InnoDB  tables when adapting existing memcached  applications to use the daemon_memcached  plugin: 

•If there are key values longer than a few bytes, it may be more efficient to use a numeric auto-increment column as the primary key of the InnoDB  table, and to create a unique secondary index on the column 

