Bug 1436207 - Use a subquery instead of a left join when inserting synced bookmark URLs into Places. r?markh
MozReview-Commit-ID: 3dBY63ibu9v
--- a/toolkit/components/places/SyncedBookmarksMirror.jsm
+++ b/toolkit/components/places/SyncedBookmarksMirror.jsm
@@ -1013,25 +1013,26 @@ class SyncedBookmarksMirror {
MirrorLog.debug("Rewriting tag queries in mirror");
await this.rewriteRemoteTagQueries();
MirrorLog.debug("Inserting new URLs into Places");
await this.db.execute(`
INSERT OR IGNORE INTO moz_places(url, url_hash, rev_host, hidden,
frecency, guid)
SELECT u.url, u.hash, u.revHost, 0,
- (CASE SUBSTR(u.url, 1, 6) WHEN 'place:' THEN 0 ELSE -1 END),
- IFNULL(h.guid, u.guid)
+ (CASE v.kind WHEN :queryKind THEN 0 ELSE -1 END),
+ IFNULL((SELECT h.guid FROM moz_places h
+ WHERE h.url_hash = u.hash AND
+ h.url = u.url), u.guid)
FROM items v
JOIN urls u ON u.id = v.urlId
- LEFT JOIN moz_places h ON h.url_hash = u.hash AND
- h.url = u.url
JOIN mergeStates r ON r.mergedGuid = v.guid
WHERE r.valueState = :valueState`,
- { valueState: BookmarkMergeState.TYPE.REMOTE });
+ { queryKind: SyncedBookmarksMirror.KIND.QUERY,
+ valueState: BookmarkMergeState.TYPE.REMOTE });
await this.db.execute(`DELETE FROM moz_updatehostsinsert_temp`);
// Deleting from `newRemoteItems` fires the `insertNewLocalItems` and
// `updateExistingLocalItems` triggers.
MirrorLog.debug("Updating value states for local bookmarks");
await this.db.execute(`DELETE FROM newRemoteItems`);
// Update the structure. The mirror stores structure info in a separate