Fastest way to determine if record exists

前端 未结 11 1178
清歌不尽
清歌不尽 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:38

    Nothing can beat -

    SELECT TOP 1 1 FROM products WHERE id = 'some value';
    

    You don't need to count to know if there is a data in table. And don't use alias when not necessary.

提交回复
热议问题