Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You want the key length to be just wide enough so that most cases are unique and no wider. If you have existing data, look how many characters wide the key would have to be so that almost all cities can be represented as distinct strings in the selected width. If you don't have existing data, google a list of cities for the geography you're interested in (e.g. USA, whole world) and use that as your guide.</p> <p>For example, if your key width is only 5 characters wide, cities like</p> <pre><code>Saint Louis Saint Petersberg </code></pre> <p>would both be represented as "Saint" in the key, causing the key to be a less-than-perfect discriminator.</p> <p>If that were the whole set of cities to be considered, a key length of 7 would be ideal. Your keys would be</p> <pre><code>Saint L Saint P </code></pre> <p>Here's the MySQL manual page that covers that:</p> <p><a href="http://dev.mysql.com/doc/refman/5.6/en/create-index.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.6/en/create-index.html</a></p> <p>Look for the text <code>CREATE INDEX part_of_name ON customer (name(10));</code></p> <p>For a list of cities, if you want to just consider the most populous cities:</p> <p><a href="http://en.wikipedia.org/wiki/List_of_United_States_cities_by_population" rel="nofollow">http://en.wikipedia.org/wiki/List_of_United_States_cities_by_population</a></p> <p>For a full list:</p> <p><a href="http://geonames.usgs.gov/domestic/download_data.htm" rel="nofollow">http://geonames.usgs.gov/domestic/download_data.htm</a></p> <p>(Topical Gazetteers, Populated Places)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload