From d9e2c7daf43ea69f56fb6cd67bde7e2ba9f5de19 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 5 Oct 2021 15:19:21 +0200 Subject: [PATCH] cmd/ido2icingadb: reason not actually used INNER JOINs --- cmd/ido2icingadb/cache.go | 4 ++++ cmd/ido2icingadb/main.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/ido2icingadb/cache.go b/cmd/ido2icingadb/cache.go index dfef5231..c6e24409 100644 --- a/cmd/ido2icingadb/cache.go +++ b/cmd/ido2icingadb/cache.go @@ -46,6 +46,8 @@ func buildEventTimeCache(ht *historyType, idoColumns []string) { sliceIdoHistory( ht.snapshot, "SELECT "+strings.Join(idoColumns, ", ")+" FROM "+ht.idoTable+ + // For actual migration icinga_objects will be joined anyway, + // so it makes no sense to take vanished objects into account. " xh USE INDEX (PRIMARY) INNER JOIN icinga_objects o ON o.object_id=xh.object_id WHERE xh."+ ht.idoIdColumn+" > ? ORDER BY xh."+ht.idoIdColumn+" LIMIT ?", nil, checkpoint.MaxId.Int64, @@ -171,6 +173,8 @@ func buildPreviousHardStateCache(ht *historyType, idoColumns []string) { sliceIdoHistory( ht.snapshot, "SELECT "+strings.Join(idoColumns, ", ")+" FROM "+ht.idoTable+ + // For actual migration icinga_objects will be joined anyway, + // so it makes no sense to take vanished objects into account. " xh USE INDEX (PRIMARY) INNER JOIN icinga_objects o ON o.object_id=xh.object_id WHERE xh."+ ht.idoIdColumn+" < ? ORDER BY xh."+ht.idoIdColumn+" DESC LIMIT ?", nil, checkpoint, diff --git a/cmd/ido2icingadb/main.go b/cmd/ido2icingadb/main.go index 45aeb548..fafd51cd 100644 --- a/cmd/ido2icingadb/main.go +++ b/cmd/ido2icingadb/main.go @@ -175,6 +175,8 @@ func countIdoHistory() { types.forEach(func(ht *historyType) { err := ht.snapshot.Get( &ht.total, + // For actual migration icinga_objects will be joined anyway, + // so it makes no sense to take vanished objects into account. "SELECT COUNT(*) FROM "+ht.idoTable+" xh INNER JOIN icinga_objects o ON o.object_id=xh.object_id", ) if err != nil { @@ -199,6 +201,8 @@ func computeProgress(c *Config, idb *icingadb.DB) { query := "SELECT xh." + strings.Join(append(append([]string(nil), ht.idoColumns...), ht.idoIdColumn), ", xh.") + " id FROM " + + // For actual migration icinga_objects will be joined anyway, + // so it makes no sense to take vanished objects into account. ht.idoTable + " xh USE INDEX (PRIMARY) INNER JOIN icinga_objects o ON o.object_id=xh.object_id WHERE " + ht.idoIdColumn + " > ? ORDER BY xh." + ht.idoIdColumn + " LIMIT ?"