My db table will have a col “a” TEXT with long strings, like multiple paragraphs. Given an input string, I want to find the one matching record. If the table has millions of rows, what would be faster? A simple
WHERE a = ?
Or should I calc and store a md5 hash of each row and then match that? Suggestions welcome.
If you want an exact match, it will be much quicker to store the hash and compare to that. It will preclude substring searches, but it’s much quicker to compare say 4 characters than to check thousands.
There will be some overhead to calculate the hash on your search parameter, but it’s nothing compared to a string comparison against that much data.