Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created June 30, 2013 02:17
Show Gist options
  • Save pnorman/5893523 to your computer and use it in GitHub Desktop.
Save pnorman/5893523 to your computer and use it in GitHub Desktop.
outlines the cgimap nodes flow and some hstore limitations with libpqxx
CREATE TEMPORARY TABLE tmp_nodes (
id bigint primary key,
geom geometry, -- postgis geometry
-- actually other columns as well
tags hstore);
-- nodes has the same columns and indexes as tmp_nodes, bout about 2 billion rows
INSERT INTO tmp_nodes SELECT * FROM nodes WHERE ...; -- assorted WHERE clauses
-- more inserts with joins, complicated conditions, etc
-- what I currently do
SELECT id,geom FROM tmp_nodes;
-- store the results in my C++ code
-- then loop in C++ over the results, and for each row do
SELECT (each(tags)).key as k, (each(tags)).value as v FROM tmp_nodes WHERE id=$1;
-- Then do stuff with these results
-- What I can't do due to libpqxx limitations:
SELECT id,geom,tags FROM tmp_nodes;
SELECT id,geom,hstore_to_array(tags) FROM tmp_nodes;
-- anything else involving an array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment