Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom index information #2100

Merged
merged 5 commits into from
May 22, 2016
Merged

Conversation

pnorman
Copy link
Collaborator

@pnorman pnorman commented Mar 30, 2016

These custom indexes should speed up rendering, particularly at low and middle zooms.

Fixes #207

cc @woodpeck @jburgess777 @Firefishy

I'm not recommending any way_area indexes, not because I don't think they're worth it, but because they're more complicated to get right, and I'd rather go ahead and recommend a number of indexes I already know help performance.

These custom indexes should speed up rendering, particularly at low
and middle zooms.

Fixes gravitystorm#207
@pnorman
Copy link
Collaborator Author

pnorman commented Mar 31, 2016

Suggested to me was an index for low zoom admin polygons to reflect the switch to OSM data for low zoom labeling. My benchmarking was prior to this, but I recall it being a good idea.

@rrzefox
Copy link

rrzefox commented Apr 4, 2016

The IF NOT EXISTS will only work for postgresql >= 9.5. 9.4 or older do not have it (so in particular, the 9.3 in ubuntu 14.04 does not have it).

This feature is only available in recent versions of PostgreSQL
@pnorman
Copy link
Collaborator Author

pnorman commented Apr 5, 2016

The IF NOT EXISTS will only work for postgresql >= 9.5. 9.4 or older do not have it (so in particular, the 9.3 in ubuntu 14.04 does not have it).

Updated.


CREATE INDEX planet_osm_point_name
ON planet_osm_point USING gist (way)
WHERE name IS NOT NULL;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This index is 653MB and only used by text-point, so I'm not this is worth the additional memory cache pressure.

@pnorman
Copy link
Collaborator Author

pnorman commented May 14, 2016

I have a WIP changing how these are defined to allow creation of SQL statements to reindex, etc.

@pnorman
Copy link
Collaborator Author

pnorman commented May 16, 2016

  • indexes.sql is now a generated file, but shouldn't need to be changed much
  • The script options are
  -h, --help            show this help message and exit
  --concurrent          Generate indexes CONCURRENTLY
  --fillfactor FILLFACTOR
                        Custom fillfactor to use
  --notexist            Use IF NOT EXISTS (requires 9.5)
  --osm2pgsql           Include indexes normally built by osm2pgsql
  --reindex             Rebuild existing indexes

Examples are
default:

CREATE INDEX planet_osm_roads_admin
  ON planet_osm_roads USING GIST (way)
  WHERE boundary = 'administrative';

--fillfactor 100:

CREATE INDEX planet_osm_roads_admin
  ON planet_osm_roads USING GIST (way)
  WITH (fillfactor=100)
  WHERE boundary = 'administrative';

--concurrent:

CREATE INDEX CONCURRENTLY planet_osm_roads_admin
  ON planet_osm_roads USING GIST (way)
  WHERE boundary = 'administrative';

--reindex:

REINDEX planet_osm_roads_admin;

--reindex --concujrrent

ALTER INDEX planet_osm_roads_admin RENAME TO planet_osm_roads_admin_old;
CREATE INDEX CONCURRENTLY planet_osm_roads_admin
  ON planet_osm_roads USING GIST (way)
  WHERE boundary = 'administrative';
DROP INDEX planet_osm_roads_admin_old;

--osm2pgsql simply adds statements for planet_osm_[point|line|polygon|roads]_index

admin:
where: boundary = 'administrative'
roads_ref:
where: WHERE highway IS NOT NULL AND ref IS NOT NULL
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't have the WHERE here

@pnorman
Copy link
Collaborator Author

pnorman commented May 19, 2016

I think this is ready

@matthijsmelissen matthijsmelissen merged commit 7365ad1 into gravitystorm:master May 22, 2016
@matthijsmelissen
Copy link
Collaborator

Thanks!

@pnorman pnorman deleted the indexes branch June 15, 2016 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants