为了避免全表扫描, 应该这样写:
Sql代码
![复制代码](http://macrochen.javaeye.com/images/icon_copy.gif)
- select spu_id
- from tbcat2.spu
- where category_id = #value#
- and (status = 0 or status is null)
- and rownum < 2
select spu_id from tbcat2.spu where category_id = #value# and (status = 0 or status is null) and rownum < 2
而不是实用count(*)函数, 对于海量数据全表扫描性能是极差的