In the course of finding some way to “optimize” support for the planet on our server, here is an index which speeds things up greatly for city name lookups:
create index admin_city_names on planet_osm_line (boundary,admin_level,name) where (boundary='administrative' and admin_level='8');
This creates a partial index which greatly optimizes queries such as:
select 1 from planet_osm_line where boundary='administrative' and admin_level='8' and name='Tours';
Figures speak for themselves… Prior to the index, such a query would take around 3 to 4 minutes. With that index, “explain analyze” tells me it takes 40.554ms on our current server.