Fastest way to determine if record exists

前端 未结 11 1162
清歌不尽
清歌不尽 2020-11-29 16:16

As the title suggests... I\'m trying to figure out the fastest way with the least overhead to determine if a record exists in a table or not.

Sample query:

11条回答
  •  遥遥无期
    2020-11-29 16:39

    SELECT TOP 1 products.id FROM products WHERE products.id = ?; will outperform all of your suggestions as it will terminate execution after it finds the first record.

提交回复
热议问题