我有两个表:maskedindextable 和 dictionarytable。
字典表有四列:
ID (primary key)
filelocation
dictionaryEncryptedIndex
dictionaryEncryptedWord
值如下所示:
ID | filelocation | dictionaryencryptedindex | dictionaryEncryptedWord
0 | c:/test.txt | 0x01 | EAD64zef6z
1 | c:/test.txt | 0x02 | 5ez4f
2 | c:/test.txt | 0x03 | ze654f
3 | c:/john.txt | 0x01 | 6ze5f4
4 | c:/john.txt | 0x02 | ze5f68z4f
5 | c:/john.txt | 0x03 | EAD64zef6z
6 | c:/smith.txt | 0x01 | er6g4
7 | c:/smith.txt | 0x02 | z6e58g4
8 | c:/smith.txt | 0x03 | a64zef6z
9 | c:/laura.txt | 0x01 | EAD64zef6z
该表有 700 000 个值
maskedindextable 有四列:
ID (primary key)
filelocation
maskedIndexEncryptedIndex
maskedIndexEncryptedValue
值如下所示:
ID | filelocation | maskedIndexEncryptedIndex | maskedIndexEncryptedValue
0 | c:/test.txt | 0x01 | 5z1ef
1 | c:/test.txt | 0x02 | e6rh546er4g
2 | c:/test.txt | 0x03 | z6ef548ezf
3 | c:/john.txt | 0x01 | (y48try68
4 | c:/john.txt | 0x02 | iu47k
5 | c:/john.txt | 0x03 | 6tkj
6 | c:/smith.txt | 0x01 | 6ez5r48
7 | c:/smith.txt | 0x02 | 6i5
8 | c:/smith.txt | 0x03 | 6e5rg
9 | c:/laura.txt | 0x01 | ze654f
该表也有 700 000 个值
表 dictionarytable 中的 dictionaryencryptedindex & filelocation 组合对应于表 maskedindextable 中的 maskedIndexEncryptedIndex & filelocation。我想找到对应的maskedindexencryptedvalue,其加密字为EAD64zef6z。目前我正在使用以下查询:
SELECT DISTINCT MaskedIndexTable.filelocation,
dictionaryencryptedindex,
maskedindexencryptedvalue
FROM MaskedIndexTable
INNER JOIN DictionaryTable
ON MaskedIndexTable.maskedIndexEncryptedIndex =
DictionaryTable.dictionaryEncryptedIndex
WHERE MaskedIndexTable.Id IN
(SELECT DictionaryTable.Id
FROM DictionaryTable
WHERE `dictionaryEncryptedWord` LIKE 'EAD64zef6z')
AND `dictionaryEncryptedWord` LIKE 'EAD64zef6z';
但是这个查询运行得非常慢(需要 3 秒)。有谁知道我可以如何优化我的查询?