1 This chapter describes the various operations the Nominatim database administrator
 
   2 may use to clean and maintain the database. None of these operations is mandatory
 
   3 but they may help improve the performance and accuracy of results.
 
   8 Command: `nominatim refresh --postcodes`
 
  10 Postcode centroids (aka 'calculated postcodes') are generated by looking at all
 
  11 postcodes of a country, grouping them and calculating the geometric centroid.
 
  12 There is currently no logic to deal with extreme outliers (typos or other
 
  13 mistakes in OSM data). There is also no check if a postcodes adheres to a
 
  14 country's format, e.g. if Swiss postcodes are 4 digits.
 
  16 When running regular updates, postcodes results can be improved by running
 
  17 this command on a regular basis. Note that only the postcode table and the
 
  18 postcode search terms are updated. The postcode that is assigned to each place
 
  19 is only updated when the place is updated.
 
  21 The command takes around 70min to run on the planet and needs ca. 40GB of
 
  25 ## Updating word counts
 
  27 Command: `nominatim refresh --word-counts`
 
  29 Nominatim keeps frequency statistics about all search terms it indexes. These
 
  30 statistics are currently used to optimise queries to the database. Thus better
 
  31 statistics mean better performance. Word counts are created once after import
 
  32 and are usually sufficient even when running regular updates. You might want
 
  33 to rerun the statistics computation when adding larger amounts of new data,
 
  34 for example, when adding an additional country via `nominatim add-data`.
 
  37 ## Forcing recomputation of places and areas
 
  39 Command: `nominatim refresh --data-object [NWR]<id> --data-area [NWR]<id>`
 
  41 When running replication updates, Nominatim tries to recompute the search
 
  42 and address information for all places that are affected by a change. But it
 
  43 needs to restrict the total number of changes to make sure it can keep up
 
  44 with the minutely updates. Therefore it will refrain from propagating changes
 
  45 that affect a lot of objects.
 
  47 The administrator may force an update of places in the database.
 
  48 `nominatim refresh --data-object` invalidates a single OSM object.
 
  49 `nominatim refresh --data-area` invalidates an OSM object and all dependent
 
  50 objects. That are usually the places that inside its area or around the
 
  51 center of the object. Both commands expect the OSM object as an argument
 
  52 of the form OSM type + OSM id. The type must be `N` (node), `W` (way) or
 
  55 After invalidating the object, indexing must be run again. If continuous
 
  56 update are running in the background, the objects will be recomputed together
 
  57 with the next round of updates. Otherwise you need to run `nominatim index`
 
  58 to finish the recomputation.
 
  61 ## Removing large deleted objects
 
  63 Nominatim refuses to delete very large areas because often these deletions are
 
  64 accidental and are reverted within hours. Instead the deletions are logged in
 
  65 the `import_polygon_delete` table and left to the administrator to clean up.
 
  67 There is currently no command to do that. You can use the following SQL
 
  68 query to force a deletion on all objects that have been deleted more than
 
  69 a certain timespan ago (here: 1 month):
 
  72 SELECT place_force_delete(p.place_id) FROM import_polygon_delete d, placex p
 
  73 WHERE p.osm_type = d.osm_type and p.osm_id = d.osm_id
 
  74       and age(p.indexed_date) > '1 month'::interval