是否可以索引或优化查询,例如下面的内容?
SELECT path,
(254-i0)*(254-i0) + (254-i1)*(254-i1) + (254-i2)*(254-i2) + (218-i3)*(218-i3) + (143-i4)*(143-i4) + (223-i5)*(223-i5) + (254-i6)*(254-i6) + (248-i7)*(248-i7) + (247-i8)*(247-i8) + (254-i9)*(254-i9) + (254-i10)*(254-i10) + (233-i11)*(233-i11) + (32-i12)*(32-i12) + (0-i13)*(0-i13) + (34-i14)*(34-i14) + (191-i15)*(191-i15) + (254-i16)*(254-i16) + (254-i17)*(254-i17) + (254-i18)*(254-i18) + (254-i19)*(254-i19) + (188-i20)*(188-i20) + (15-i21)*(15-i21) + (0-i22)*(0-i22) + (76-i23)*(76-i23) + (112-i24)*(112-i24) + (254-i25)*(254-i25) + (254-i26)*(254-i26) + (254-i27)*(254-i27) + (254-i28)*(254-i28) + (207-i29)*(207-i29) + (78-i30)*(78-i30) + (22-i31)*(22-i31) + (149-i32)*(149-i32) + (138-i33)*(138-i33) + (254-i34)*(254-i34) + (241-i35)*(241-i35) + (254-i36)*(254-i36) + (254-i37)*(254-i37) + (174-i38)*(174-i38) + (8-i39)*(8-i39) + (10-i40)*(10-i40) + (36-i41)*(36-i41) + (159-i42)*(159-i42) + (240-i43)*(240-i43) + (217-i44)*(217-i44) + (240-i45)*(240-i45) + (251-i46)*(251-i46) + (209-i47)*(209-i47) + (0-i48)*(0-i48) + (0-i49)*(0-i49) + (0-i50)*(0-i50) + (188-i51)*(188-i51) + (227-i52)*(227-i52) + (222-i53)*(222-i53) + (250-i54)*(250-i54) + (250-i55)*(250-i55) + (246-i56)*(246-i56) + (33-i57)*(33-i57) + (0-i58)*(0-i58) + (30-i59)*(30-i59) + (239-i60)*(239-i60) + (240-i61)*(240-i61) + (245-i62)*(245-i62) + (245-i63)*(245-i63) + (247-i64)*(247-i64) + (253-i65)*(253-i65) + (86-i66)*(86-i66) + (0-i67)*(0-i67) + (68-i68)*(68-i68) + (254-i69)*(254-i69) + (247-i70)*(247-i70) + (242-i71)*(242-i71) + (245-i72)*(245-i72) + (246-i73)*(246-i73) + (248-i74)*(248-i74) + (110-i75)*(110-i75) + (0-i76)*(0-i76) + (73-i77)*(73-i77) + (237-i78)*(237-i78) + (222-i79)*(222-i79) + (232-i80)*(232-i80) + (231-i81)*(231-i81) + (234-i82)*(234-i82) + (249-i83)*(249-i83) + (79-i84)*(79-i84) + (0-i85)*(0-i85) + (35-i86)*(35-i86) + (230-i87)*(230-i87) + (225-i88)*(225-i88) + (195-i89)*(195-i89) + (199-i90)*(199-i90) + (203-i91)*(203-i91) + (201-i92)*(201-i92) + (105-i93)*(105-i93) + (53-i94)*(53-i94) + (66-i95)*(66-i95) + (167-i96)*(167-i96) + (203-i97)*(203-i97) + (218-i98)*(218-i98) + (203-i99)*(203-i99) + (221-i100)*(221-i100) + (202-i101)*(202-i101) + (62-i102)*(62-i102) + (63-i103)*(63-i103) + (40-i104)*(40-i104) + (137-i105)*(137-i105) + (191-i106)*(191-i106) + (184-i107)*(184-i107) + (194-i108)*(194-i108) + (195-i109)*(195-i109) + (155-i110)*(155-i110) + (2-i111)*(2-i111) + (7-i112)*(7-i112) + (0-i113)*(0-i113) + (124-i114)*(124-i114) + (174-i115)*(174-i115) + (126-i116)*(126-i116) + (184-i117)*(184-i117) + (163-i118)*(163-i118) + (165-i119)*(165-i119) + (32-i120)*(32-i120) + (5-i121)*(5-i121) + (1-i122)*(1-i122) + (152-i123)*(152-i123) + (165-i124)*(165-i124) + (144-i125)*(144-i125) + (193-i126)*(193-i126) + (187-i127)*(187-i127) + (192-i128)*(192-i128) + (46-i129)*(46-i129) + (14-i130)*(14-i130) + (8-i131)*(8-i131) + (125-i132)*(125-i132) + (162-i133)*(162-i133) + (146-i134)*(146-i134) + (150-i135)*(150-i135) + (125-i136)*(125-i136) + (145-i137)*(145-i137) + (64-i138)*(64-i138) + (3-i139)*(3-i139) + (25-i140)*(25-i140) + (130-i141)*(130-i141) + (111-i142)*(111-i142) + (94-i143)*(94-i143) AS score
FROM files f
JOIN signatures s ON f.signature_id=s.id
ORDER BY score DESC
它正在计算我的搜索查询在144列上的平方差异。
答案 0 :(得分:1)
索引可用于join
条件。您可能是files(signature_id)
,signatures(id)
或两者都有的索引。
索引对算术计算没有帮助。