Hello all,

A best practices question for you regarding
performance. the scenario is this....I need to print
out a subset of records from a table (e.g. 1-10) and
a total count to print, say, on a search results
page....which practice is quicker/more efficient than
the other.

1.) Use two queries....one to extract records 1 to
10....a second to extract the total count.

SELECT * FROM myTable LIMIT 0,10;

2.) One query that selects all records.....use PHP to extract the count
(in an array like...in php it would be
mysql_numrows)....then use a loop to push the
records out (for 1 to 10).

SELECT * FROM myTable;


for(1 to 10){

//print result

I was having a discussion with a co-worker about
this and was hoping for your opinions as we are now
trying to implement some best practices with coding.

Two queries would seem to be slower because it
accesses the disk twice opposed to once....while the
second is seeking much more from the disk albeit
with only one disk access.

Thoughts? Many thanks!!!!