On Thu, Feb 14, 2008 at 4:12 PM, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On Thu, Feb 14, 2008 at 4:06 PM, Ken Prows <[EMAIL PROTECTED]> wrote:
>> Sorry, I forgot to include the limit arg in my example. I do use limit so
>> that I can page the data. I need to know the total matches so that I can
>> determine how many pages there are.
>
>  In that case, I recommend that you avoid FOUND_ROWS.  It's almost
>  always worse than a second COUNT query.  Try it in the mysql shell and
>  see.
>  
> http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/

Not only that, but the number of rows is pretty meaningless if you're
joining across any ...-to-many relationships (in which case what you
really want is the count of the distinct rows from the primary table,
which is what the Manager's *_count() method should give you).

That said, there's been a "hints" API lurking in the Manager for a
while now (since 2006 I think).  I've gone ahead and documented and
expanded it in SVN.  You'll need both the SVN Rose::DB and
Rose::DB::Object.

https://rose.svn.sourceforge.net/svnroot/rose/trunk/modules/Rose-DB
https://rose.svn.sourceforge.net/svnroot/rose/trunk/modules/Rose-DB-Object

It's extremely limited and very MySQL-specific.  It also avoids any
direct injection of parameter values into the SQL string, though maybe
I'll add such a thing at some point.  Anyway, give it a spin.

-John

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to