I would suggest using stored procedures to get exactly the number of row
you want. Transferring more data than you need in a query takes time as
mentioned in earlier replies from everyone. Other issues are related to
connection pooling and scalability. If you're query returns several
hundred or thousand rows, the query itself is fairly quick in a DB like
oracle, but you're using the connection for a longer duration. If the
website is only serving a few concurrent connections you're fine. On the
otherhand, if you're serving hundreds of connections per second, getting
800 rows to only show 20 will likely result in timeouts.

I don't know mysql, but another thing to consider.

peter


Paul DuBois wrote:
> 
> At 14:57 -0700 5/6/02, Hans Bergsten wrote:
> >Paul DuBois wrote:
> >>After issuing a SELECT query with <sql:query>, you can access the row
> >>count with ${rs.rowCount} (where rs is the result set variable).
> >>
> >>However, in other APIs such as Perl DBI, the equivalent construct
> >>is deprecated because some drivers do not return a count reliably;
> >>the recommended course of action is to count the rows as you fetch
> >>them.
> >>
> >>Is there any such constraint or caution in JSTL?
> >
> >The "rowCount" property of the Result class contains the number of rows
> >in the Result. In other words, if you have limited the amount of
> >rows with the "maxRows" attribute, "rowCount" has the same value as
> >"maxRows" and "isLimitedByMaxRows" is "true".
> >
> >It's true that JDBC drivers can not provide the number of rows returned
> >for a query until you retrieve them, but with <sql:query> all rows (upto
> >"startRow" + "maxRows") are retrieved and the "rowsCount" value is
> >therefore an accurate number for the number of rows in the Result.
> >
> >I hope that made some kind of sense ;-)
> 
> Well, let's see if I understood you. :-) Assuming that I haven't limited
> the result set with maxRows, then rowCount should indeed contain the
> number of rows returned by the query.  Right?
> 
> >
> >Hans
> >--
> >Hans Bergsten          [EMAIL PROTECTED]
> >Gefion Software                http://www.gefionsoftware.com
> >JavaServer Pages       http://TheJSPBook.com
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to