Skip to content

Commit

Permalink
remove distinct because aparently that is much more expensive then I …
Browse files Browse the repository at this point in the history
…thought
  • Loading branch information
calvinmetcalf committed Mar 7, 2018
1 parent b3fd46b commit a2c4bd0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var swap = Bluebird.coroutine(function * swap(table, tempTable, remove, db, conf
return db.raw(`
${remove ? escape('DELETE from %I', table) : ''};
INSERT into ?? (${toFields.join(',')})
SELECT DISTINCT ${fromFields.join(',')} from ??
SELECT ${fromFields.join(',')} from ??
${groupFields.length ? `group by ${groupFields.join(',')}` : ''};
`,[table, tempTable]).batch().onSuccess(db.raw('DROP TABLE ??;', [tempTable])).onError(db.raw('DROP TABLE ??;', [tempTable]));
});
Expand Down
24 changes: 0 additions & 24 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,31 +439,7 @@ test('crud', function (t) {
t.error(err, 'no error');
});
});
t.test('test dedupping', function (t) {
t.plan(3);
var stream1 = intoCartodb(auth.user, auth.key, table, function (err) {
t.error(err);
cartodb(table).count('*').exec(function (err, resp) {
t.error(err);
t.deepEquals(resp, [{count: 3}]);
});
});

var i = -1;
while (++i < 100) {
stream1.write({
type: 'Feature',
properties: {
num: i % 3
},
geometry: {
type: 'Point',
coordinates: [i % 3, i % 3]
}
});
}
stream1.end();
});
t.test('maybe delete with dash', function (t) {
t.plan(1);
cartodb.schema.dropTableIfExists(tablewithOutDash).exec(function (err) {
Expand Down

0 comments on commit a2c4bd0

Please sign in to comment.