I have a huge table to work with . I want to check if there are some records whose parent\_id equals my passing value . 
currently what I implement this is by using "select count(\*) from mytable where parent\_id = :id"; if the result > 0 , means the they do exist.

Because this is a very huge table , and I don't care what's the exactly number of records that exists , I just want to know whether it exists , so I think count(\*) is a bit inefficient.

How do I implement this requirement in the fastest way ? I am using Oracle 10.

#

According to hibernate Tips & Tricks <https://www.hibernate.org/118.html#A2>

It suggests to write like this :

Integer count = (Integer) session.createQuery("select count(\*) from ....").uniqueResult();

I don't know what's the magic of uniqueResult() here ? why does it make this fast ?

Compare to "select 1 from mytable where parent\_id = passingId and rowrum < 2 " , which is more efficient ?