I'm not sure. You could run a test. I'd be surprised if counting rows
from the resultset was slower.
Charles So wrote:
>
> which is more efficient?
>
> 1) find num from rs or
> 2) select count(*) from table?
>
> cheers,
> Charles
>
> On Saturday, August 16, 2003, at 05:01 AM, Jeff Mathis wrote:
>
> > you can move the curser in a ResultSet, which may help.
> >
> > for example, let rs be your ResultSet.
> >
> > int num = 0;
> > while(rs.next()) {
> > num++;
> > }
> >
> > // then to get back to the beginning
> > rs.first();
> >
> > jeff
> >
> > [EMAIL PROTECTED] wrote:
> >>
> >> I'm pretty sure that there's been a thread on this topic, but I
> >> cannot find it in my archives, and the archives on the website don't
> >> seem to be searchable.
> >>
> >> Anyway, is there a way to obtain the number of rows that have been
> >> retrieved by a SELECT SQL statement? I'm particularly interested in
> >> the case of a ResultSet from a PreparedStatement.
> >>
> >> Failing that, Is it possible to determine if an executeQuery() has
> >> returned ANY rows or NO rows?
> >>
> >> Doc pointers gratefully received, tho' I've just come from Sun's site
> >> and the doc on java.sql...
> >>
> >> Regards,
> >> Terry Fuller
> >> [EMAIL PROTECTED]
> >> -------------------------------------------------------
> >>
> >> --
> >> MySQL Java Mailing List
> >> For list archives: http://lists.mysql.com/java
> >> To unsubscribe:
> >> http://lists.mysql.com/[EMAIL PROTECTED]
> >
> > --
> > Jeff Mathis, Ph.D. 505-955-1434
> > The Prediction Company [EMAIL PROTECTED]
> > 525 Camino de los Marquez, Ste 6 http://www.predict.com
> > Santa Fe, NM 87505
> >
> > --
> > MySQL Java Mailing List
> > For list archives: http://lists.mysql.com/java
> > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
> >
--
Jeff Mathis, Ph.D. 505-955-1434
The Prediction Company [EMAIL PROTECTED]
525 Camino de los Marquez, Ste 6 http://www.predict.com
Santa Fe, NM 87505
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]