postgis loader issues metadata queries but not data query
Hopefully this is the right place to ask.
When I do something like the following, with logging turned on for my DB, I see that the request is made with limit 0 at the end, which obviously means it returns empty.
var postgis = new mapnik.Datasource({
type: 'postgis',
host: ... etc,
table: 'some_geometry_table',
geometry_field: 'geom',
srid: 4326,
extent: "-180,-85.0511,180,85.0511",
estimate_extent: false,
row_limit: 10 // !! this doesn't seem to do anything
});
var map = new mapnik.Map(256, 256);
var layer = new mapnik.Layer('some_layer');
layer.datasource = postgis;
map.add_layer(layer);
map.render(new mapnik.VectorTile(z, x, y), {}, (err, vtile) => {
if (err) next(err);
var data = vtile.getDataSync({});
var file = path + z + "," + x + "," + y + ".pbf"
console.log(data);
console.log("written: " + file);
fs.writeFileSync(file, data);
next(null);
});
});
Statement as seen in postgres logs:
SELECT * FROM some_geometry_table LIMIT 0
It doesn't seem to matter what I put in row_limit, or if I remove it, I always get limit 0.
Looking at the mapnik src it seems this is the correct name for the param, but I have no idea how this all works.
UPDATE (As mentioned below): the limit-0 query is for metadata. There should be another query that follows it, but I don't see one.
Now posted as a question on SO.
I think those limit 0 queries in the log are fine. Their purpose is to collect some metadata during initialization. See here.
SELECT * FROM some_geometry_table LIMIT 0
This is a query mapnik uses at datasource creation time to get column names and types.
Later, when mapnik actually pulls data for rendering, it never does SELECT *, it always names the columns explicitly, so you should also see SELECT ...something... LIMIT your_row_limit in the log.
I don't see anything else being queried on the table after that first line with the limit-0.
Any ideas what I'm doing wrong? Note I have now posted this as a question on SO. Thanks