By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Get total number of results but still use LIMIT?

P: n/a
Is there a (better) way to get the toal number of results from a query
but still limit them with a LIMIT clause. For example, in a Google
search result, it displays 1-100 of 10,000,000 results. Do they hit
the database once for results, and again for a total count or is it
all in one query? Thanks -Nick
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
interesting.

I've noticed that if the amount is a big number, google gives only a approx
number.

And sometimes a small amount is not accurate to the real result number that
google returns.

I personal believe there's some stat in their index.

Waiting for more info here with Nick :-)
ccton
--
www.vicdir.com
"Nick" <nb********@hotmail.com> ????
news:ce**************************@posting.google.c om...
Is there a (better) way to get the toal number of results from a query
but still limit them with a LIMIT clause. For example, in a Google
search result, it displays 1-100 of 10,000,000 results. Do they hit
the database once for results, and again for a total count or is it
all in one query? Thanks -Nick

Jul 20 '05 #2

P: n/a
Nick wrote:
Is there a (better) way to get the toal number of results from a query but still limit them with a LIMIT clause. For example, in a Google
search result, it displays 1-100 of 10,000,000 results. Do they hit
the database once for results, and again for a total count or is it
all in one query? Thanks -Nick


Donít know what google is doing, but e.g. PHPBB bulletin board queries
completely, and then only shows the top xx results. So it does not do
a limit.

You can easily do a benchmark between:
(a) doing two queries, one using a limit
(b) using a single query, and then showing the top xx results

Otherwise, I donít believe what you asking is possible.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/mySQL-total-...ict125578.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=432463
Jul 20 '05 #3

P: n/a
For right now im doing...

SELECT
(SELECT count(id) FROM table1) as totalResults,
id,
field1,
field2

FROM table1

I guess this works for my situation. -Nick
Jul 20 '05 #4

P: n/a
Nick wrote:
Is there a (better) way to get the toal number of results from a query but still limit them with a LIMIT clause. For example, in a Google
search result, it displays 1-100 of 10,000,000 results. Do they hit
the database once for results, and again for a total count or is it
all in one query? Thanks -Nick


Donít know what google is doing, but e.g. PHPBB bulletin board queries
completely, and then only shows the top xx results. So it does not do
a limit.

You can easily do a benchmark between:
(a) doing two queries, one using a limit
(b) using a single query, and then showing the top xx results

Otherwise, I donít believe what you asking is possible.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/mySQL-total-...ict125578.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=432463
Jul 20 '05 #5

P: n/a
For right now im doing...

SELECT
(SELECT count(id) FROM table1) as totalResults,
id,
field1,
field2

FROM table1

I guess this works for my situation. -Nick
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.