forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved version of osm2pgsql-dev#1058 Needs more testing.
- Loading branch information
Showing
4 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
# Bucket index for slim mode | ||
|
||
Osm2pgsql since version XXX uses an index for way node lookups in slim mode | ||
that needs a lot less disk space than before. For a planet the savings can be | ||
about 200 GB! Lookup times are slightly slower, but this shouldn't be an issue | ||
for most people. | ||
|
||
If you are not using slim mode and/or not doing updates of your database, this | ||
does not apply to you. | ||
|
||
Osm2pgsql will **not** update an existing database to the new index. | ||
|
||
## Update for normal users | ||
|
||
If your database was created with an older version of osm2pgsql you might want | ||
to start again from an empty database. Just do a reimport and osm2pgsql will | ||
use the new space-saving index. | ||
|
||
## Update for expert users | ||
|
||
This is only for users who are very familiar with osm2pgsql and PostgreSQL | ||
operation. You can break your osm2pgsql database beyond repair if something | ||
goes wrong here and you might not even notice. | ||
|
||
You can create the index yourself by following these steps: | ||
|
||
Drop the existing index. Replace `{prefix}` by the prefix you are using. | ||
Usually this is `planet_osm`: | ||
|
||
``` | ||
DROP INDEX {prefix}_ways_nodes_idx; | ||
``` | ||
|
||
Create the `index_bucket` function needed for the index. Replace | ||
`{index_bucket_size}` by the bucket size you want. If you don't have a reason | ||
to use something else, use `32`: | ||
|
||
``` | ||
CREATE FUNCTION index_bucket(int8[]) RETURNS int8[] AS $$ | ||
SELECT ARRAY(SELECT DISTINCT unnest($1)/{index_bucket_size}) | ||
$$ LANGUAGE SQL IMMUTABLE; | ||
``` | ||
|
||
Now you can create the new index. Again, replace `{prefix}` by the prefix | ||
you are using: | ||
|
||
``` | ||
CREATE INDEX ON {prefix}_ways | ||
USING GIN (index_bucket(nodes)) | ||
WITH (fastupdate = off); | ||
``` | ||
|
||
If you want to create the index in a specific tablespace you can do this: | ||
|
||
``` | ||
CREATE INDEX ON {prefix}_ways | ||
USING GIN (index_bucket(nodes)) | ||
WITH (fastupdate = off) TABLESPACE {tablespace}; | ||
``` | ||
|
||
## Bucket size (for experts) | ||
|
||
When creating a new database (when used in create mode with slim option), | ||
osm2pgsql will create a bucket index using bucket size 32. | ||
|
||
You can set the environment variable `OSM2PGSQL_INDEX_BUCKET_SIZE` to the | ||
bucket size you want. Values between about 8 and 64 might make sense. | ||
|
||
To completely disable the bucket index and create an index compatible with | ||
earlier versions of osm2pgsql, set `OSM2PGSQL_INDEX_BUCKET_SIZE` to `0`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters