MySql performance question: MD5 (value)

for security purposes, I make several requests this way:

SELECT avatar_data FROM users WHERE MD5(ID) ='md5value'

So, for example, I have the following entries:

-TABLE.users-
ID | avatar_data
39 | some-data

I am making this request:

SELECT avatar_data FROM users WHERE MD5(ID) ='d67d8ab4f4c10bf22aa353e27879133c'

'd67d8ab4f4c10bf22aa353e27879133c'is the value '39'filtered by MD5.

I have a VERY large database with many entries. I wonder if this approach can compromise database performance?

+3
source share
4 answers

Since you are using the function in the column you want to find (MD5 (ID) =), MySQL will have to perform a full table scan.

, , , .

, :

SELECT * FROM WHERE MD5_ID = 'D67d8ab4f4c10bf22aa353e27879133c'

+4

, . , , .

+2

, , , , . MD5 "39" . , , . , .

Perhaps you should talk more about what you are doing. For example: is it a web administration tool? Is password protected? Etc.

0
source

if you want this kind of protection is probably better if you save your passwords as an md5 hash. Encoding ID does not provide security

0
source

Source: https://habr.com/ru/post/1725921/


All Articles