you'd be suprized how fast an index can be.. you should read the manual
on indexes,
http://dev.mysql.com/doc/mysql/en/mysql-indexes.html
"If a table has 1,000 rows, this is at least 100 times faster than
reading sequentially"
while you may not get 100x faster, it will be faster than having no
index.. also try using mysql_num_rows()
$sql = mysql_query("SELECT col FROM tbvara WHERE Varunamn LIKE
'$checkLev%'");
// record count
echo mysql_num_rows($sql);
PS, 'reply all' to list.
Gustav Wiberg wrote:
Hi there!
There are about 300 records.
You're right, I can add an index, but Is that the only way to get a
faster solution?
/mr G
@varupiraten.se
----- Original Message ----- From: "Sebastian"
<sebastian@xxxxxxxxxxxxxxxxxxx>
To: "Gustav Wiberg" <gustav@xxxxxxxxxxxxxx>
Sent: Saturday, August 06, 2005 11:08 PM
Subject: Re: Fast count of recordset in php...
how many records in the table? its going to be slow no matter what,
especially if you have a lot of records.. your searching each record
then counting them.. do you have any indexes? judging by your query
you can add index on Varunamn and it should be more speedy..
Gustav Wiberg wrote:
Hello there!
How do i get a fast count of a recordset in php?
Look at this code:
$sql = "SELECT COUNT(IDVara) cn FROM tbvara WHERE Varunamn LIKE
'$checkLev%'";
$querys = mysql_query($sql);
//Count products in db
//
$dbArray = mysql_fetch_array($querys);
$nrOfProducts = $dbArray["cn"];
It's slow... Why? Any suggestions?
/mr G
@varupiraten.se
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.1/64 - Release Date: 8/4/2005
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date:
2005-08-03
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.1/64 - Release Date: 8/4/2005
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php