Is it faster to search for a large string in a DB by its hashcode?

前端 未结 10 2500
余生分开走
余生分开走 2020-12-17 19:32

If I need to retrieve a large string from a DB, Is it faster to search for it using the string itself or would I gain by hashing the string and storing the hash in the DB as

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 20:02

    In general: probably not, assuming the column is indexed. Database servers are designed to do such lookups quickly and efficiently. Some databases (e.g. Oracle) provide options to build indexes based on hashing.

    However, in the end this can be only answered by performance testing with representative (of your requirements) data and usage patterns.

提交回复
热议问题