PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Applying LIMIT to SELECT count(*)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Applying LIMIT to SELECT count(*)

Réponse
 
LinkBack Outils de la discussion
Vieux 21/12/2007, 10h53   #1
Urms
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Applying LIMIT to SELECT count(*)


Hi,

My task is to limit calculation of total number of items in the database
that satisfy certain conditions. I join two tables using WHERE and there are
millions of records as the result. When I do SELECT count(*) .... it takes
really too long. The table has appropriate indexes and I experimented with
replacing the conditions, etc., so I don't think there is a way to make it
work any faster. In my case it would be anough to say that there are "more
than e.g. 50 000" of items instead of calculating the exact quantity. My
question is how to apply a certain limit to count() function in order it
would either return the real quantity if it is smaller than the limit or
return the limit and stop further calculation, quite same as when using
SELECT * FROM ... LIMIT 0, 100

Another option could be estimating approximate quantity in the result but it
seems to me much more complex and I honestly don't know where to start from.

Thanks!
--
View this message in context: http://www.nabble.com/Applying-LIMIT...p14453544.html
Sent from the MySQL - General mailing list archive at Nabble.com.

  Réponse avec citation
Vieux 21/12/2007, 17h10   #2
js
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Applying LIMIT to SELECT count(*)

If exact number isn't important,
you might want to try table_rows in information_schema.tables or show
table status.

On Dec 21, 2007 7:53 PM, Urms <andreym@bigmir.net> wrote:
>
> Hi,
>
> My task is to limit calculation of total number of items in the database
> that satisfy certain conditions. I join two tables using WHERE and there are
> millions of records as the result. When I do SELECT count(*) .... it takes
> really too long. The table has appropriate indexes and I experimented with
> replacing the conditions, etc., so I don't think there is a way to make it
> work any faster. In my case it would be anough to say that there are "more
> than e.g. 50 000" of items instead of calculating the exact quantity. My
> question is how to apply a certain limit to count() function in order it
> would either return the real quantity if it is smaller than the limit or
> return the limit and stop further calculation, quite same as when using
> SELECT * FROM ... LIMIT 0, 100
>
> Another option could be estimating approximate quantity in the result but it
> seems to me much more complex and I honestly don't know where to start from.
>
> Thanks!
> --
> View this message in context: http://www.nabble.com/Applying-LIMIT...p14453544.html
> Sent from the MySQL - General mailing list archive at Nabble.com.
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=ebgssth@gmail.com
>
>

  Réponse avec citation
Vieux 21/12/2007, 18h00   #3
Urms
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Applying LIMIT to SELECT count(*)


The problem is that there are certain conditions after WHERE different for
each query and the results number can be very different.
--
View this message in context: http://www.nabble.com/Applying-LIMIT...p14459808.html
Sent from the MySQL - General mailing list archive at Nabble.com.

  Réponse avec citation
Vieux 21/12/2007, 23h06   #4
js
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Applying LIMIT to SELECT count(*)

Oh, I misunderstood,sorry.
Using summary tables doesn't work for you?

On Dec 22, 2007 3:00 AM, Urms <andreym@bigmir.net> wrote:
>
> The problem is that there are certain conditions after WHERE different for
> each query and the results number can be very different.
> --
> View this message in context: http://www.nabble.com/Applying-LIMIT...p14459808.html
>
> Sent from the MySQL - General mailing list archive at Nabble.com.
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=ebgssth@gmail.com
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h03.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09590 seconds with 12 queries