Uses tables ogr2ogr param to avoid heavy query on pg_class and friends
Fixes #204
Newer versions of ogr2ogr don't use that heavy query so it should work
Ref 2e3eeefd0f
This commit is contained in:
parent
db03235c4a
commit
b6e53f7326
@ -286,6 +286,8 @@ function handleQuery(req, res) {
|
||||
req.profiler.done('init');
|
||||
}
|
||||
|
||||
var affectedTables;
|
||||
|
||||
// 1. Get database from redis via the username stored in the host header subdomain
|
||||
// 2. Run the request through OAuth to get R/W user id if signed
|
||||
// 3. Get the list of tables affected by the query
|
||||
@ -404,6 +406,7 @@ function handleQuery(req, res) {
|
||||
};
|
||||
tableCache.set(sql_md5, tableCacheItem);
|
||||
}
|
||||
affectedTables = tables;
|
||||
|
||||
if ( !authenticated && tableCacheItem ) {
|
||||
var affected_tables = tableCacheItem.affected_tables;
|
||||
@ -467,6 +470,7 @@ function handleQuery(req, res) {
|
||||
// TODO: drop this, fix UI!
|
||||
sql = new PSQL.QueryWrapper(sql).orderBy(orderBy, sortOrder).window(limit, offset).query();
|
||||
|
||||
|
||||
var opts = {
|
||||
username: cdbUsername,
|
||||
dbopts: dbopts,
|
||||
@ -476,6 +480,7 @@ function handleQuery(req, res) {
|
||||
skipfields: skipfields,
|
||||
sql: sql,
|
||||
filename: filename,
|
||||
affectedTables: affectedTables,
|
||||
bufferedRows: global.settings.bufferedRows,
|
||||
callback: params.callback,
|
||||
abortChecker: checkAborted
|
||||
|
@ -141,12 +141,18 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback
|
||||
|
||||
var ogrsql = 'SELECT ' + columns.join(',') + ' FROM (' + sql + ') as _cartodbsqlapi';
|
||||
|
||||
var tables = 'fake';
|
||||
if (options.affectedTables && options.affectedTables.length) {
|
||||
tables = options.affectedTables.join(',');
|
||||
}
|
||||
|
||||
var ogrargs = [
|
||||
'-f', out_format,
|
||||
'-lco', 'ENCODING=UTF-8',
|
||||
'-lco', 'LINEFORMAT=CRLF',
|
||||
out_filename,
|
||||
"PG:host=" + dbhost + " port=" + dbport + " user=" + dbuser + " dbname=" + dbname + " password=" + dbpass,
|
||||
'tables=' + tables,
|
||||
'-sql', ogrsql
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user