我们正在尝试将数据从 Excel 上传到数据库。在上传之前,我们想在与我们的数据库进行比较的同时预览具有匹配状态计数的数据(例如:不匹配、相似匹配、完全匹配)。
下面的查询需要 3 分钟的时间从数据库中获取 100 行的信息。我们将有一个用户可以上传超过 5K 行数据的案例。请让我们知道您的建议,以提高以下查询的性能。
select IF(
count(distinct ID) <= 0, (
select case when count(ID) > 0 then 'Similar Match' else 'No Match' end as MatchType from masterTable where (
soundex(BarCode) like soundex('12069B0') or soundex(ProductName) like soundex('FreezerZX')
) and (
levenshtein(BarCode,'12069B0') < 3 or (levenshtein(ProductName,'FreezerZX') < 3)
)
),
'Exact Match'
) as MatchType from masterTable where BarCode= '12069B0' and ProductName= 'FreezerZX';