PHWinfo banniere

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

Réponse
 
LinkBack Outils de la discussion
Vieux 22/12/2007, 14h55   #1
llothar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Fast way to do "SELECT count(*) FROM table"

Hello. I start to write a simple Database management tool and i want
to display the number of rows in a table. Unfortunately MySQL is
extremely slow on this "SELECT count(*) FROM table" statements. Looks
like a full table scan for me. Is there any other way to retrieve this
information?
  Réponse avec citation
Vieux 22/12/2007, 15h43   #2
SigPower@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Fast way to do "SELECT count(*) FROM table"

On Dec 22, 9:55 am, llothar <llot...@web.de> wrote:
> Hello. I start to write a simple Database management tool and i want
> to display the number of rows in a table. Unfortunately MySQL is
> extremely slow on this "SELECT count(*) FROM table" statements. Looks
> like a full table scan for me. Is there any other way to retrieve this
> information?


What engine are you using? I use MyISAM almost exclusively and I can
assure you that this engine does not need a table scan to return the
number of records in a table. I did a select count(*) on a MyISAM
table with just over 20 million rows in .72 seconds on my slow
laptop. The number of records is part of the table's metadata.
  Réponse avec citation
Vieux 22/12/2007, 19h24   #3
Kees Nuyt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Fast way to do "SELECT count(*) FROM table"

On Sat, 22 Dec 2007 06:55:07 -0800 (PST), llothar
<llothar@web.de> wrote:

>Hello. I start to write a simple Database management tool and i want
>to display the number of rows in a table. Unfortunately MySQL is
>extremely slow on this "SELECT count(*) FROM table" statements. Looks
>like a full table scan for me. Is there any other way to retrieve this
>information?


Does your table have a PRIMARY KEY ?
--
( Kees
)
c[_] Nostalgia. Sure ain't what it used to be.... (#26)
  Réponse avec citation
Vieux 26/12/2007, 04h54   #4
John Nagle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Fast way to do "SELECT count(*) FROM table"

SigPower@gmail.com wrote:
> On Dec 22, 9:55 am, llothar <llot...@web.de> wrote:
>> Hello. I start to write a simple Database management tool and i want
>> to display the number of rows in a table. Unfortunately MySQL is
>> extremely slow on this "SELECT count(*) FROM table" statements. Looks
>> like a full table scan for me. Is there any other way to retrieve this
>> information?

>
> What engine are you using? I use MyISAM almost exclusively and I can
> assure you that this engine does not need a table scan to return the
> number of records in a table. I did a select count(*) on a MyISAM
> table with just over 20 million rows in .72 seconds on my slow
> laptop. The number of records is part of the table's metadata.


MyISAM has a record count, so COUNT(*) is cheap. InnoDB tables
do not, so COUNT(*) there can be expensive. There's the issue that
"number of records" is non-trivial to measure when transactions are
in progress.

John Nagle
  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 10h40.


É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,15678 seconds with 12 queries