Skip to content

Instantly share code, notes, and snippets.

@pnorman
Last active January 3, 2019 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnorman/5f93e4909d694816c040a9fd10479545 to your computer and use it in GitHub Desktop.
Save pnorman/5f93e4909d694816c040a9fd10479545 to your computer and use it in GitHub Desktop.
e (external) 11291.733
m (main) 11256.321
x (extended) 11321.855
e (external) 27983.542
m (main) 27274.032
x (extended) 28402.639
update pg_type set typstorage='e' where typname='geometry';
-- also test with m and x
\timing
create table adm2 as select * from planet_osm_polygon where boundary='administrative' and admin_level='2' ORDER BY ST_GeoHash(ST_Transform(ST_Envelope(way),4326),10);
create table cities as select * from planet_osm_point where place='city' ORDER BY ST_GeoHash(ST_Transform(ST_Envelope(way),4326),10);
CREATE INDEX ON adm2 USING gist (way) WITH (fillfactor=100);
CREATE INDEX ON cities USING gist (way) WITH (fillfactor=100);
VACUUM ANALYZE adm2;
VACUUM ANALYZE cities;
-- repeat 4 times, throw away first, take median time
EXPLAIN ANALYZE SELECT COUNT(*), c.name FROM adm2 c JOIN cities p ON ST_Intersects(c.way, p.way) GROUP BY c.name;
DROP TABLE adm2; DROP TABLE cities;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment