Created a quick sed script to filter "BEGIN;" and "END;" from the shp2pgsql output.
Updated the makefile to import the tiger_lines data one row at a time, outside of a transaction.
--- /dev/null
+#!/bin/bash
+
+# Remove all occurrences of the strings "BEGIN;" and "END;" from the
+# input stream. As of Postgis v1.4.0, shp2pgsql inserts them once for
+# every 250 "INSERT" statements.
+
+sed s/"BEGIN;"//g |
+ sed s/"END;"//g
# and leave -I out.
for state in data/census2000/*; do \
for shapefile in $$state/lines/*.shp; do \
+ echo "Importing $$shapefile."; \
$(PG_BINDIR)/shp2pgsql \
-a \
-s $(TIGER_SRID) \
- -D \
$$shapefile \
tiger_lines \
- | psql -U $(DB_USER) -d $(DB_NAME); \
+ | bin/filter-transactions \
+ | psql -U $(DB_USER) -d $(DB_NAME) \
+ > /dev/null; \
done; \
done;
tiger_lines \
| psql -U postgres -d $(DB_NAME) \
> /dev/null
+
+# Add a unique index on the "tlid" column.
+ psql -U postgres \
+ -d census \
+ -f sql/create_tlid_unique_index.sql
--- /dev/null
+/*
+ The TIGER/Line ID (tlid) for each line is supposed to be
+ unique. If it isn't, problems, so we enforce it in the
+ database.
+*/
+
+CREATE UNIQUE INDEX idx_tiger_lines_tlid_unique
+ ON tiger_lines (tlid);