Which is the least expensive aggregate function in the absence of ANY()

前端 未结 4 1466
半阙折子戏
半阙折子戏 2020-12-06 17:49

I usally use MAX() or MIN() if a DBMS hasn\'t an ANY() aggregate function.

Is there something less expensive in mySQL and MS-SQL?

4条回答
  •  甜味超标
    2020-12-06 18:32

    Fine, let's rephrase the original question. Instead of ANY, which is ambiguous and not SQL standard, it would be great if EXISTS-aggregate function was provided.

    On several occasions I have used "count(outer.column) > 0" to imitate the "exists(outer.column)", which would be arguably cheaper since counting is discarded anyway.

提交回复
热议问题