Try tuning mysql for faster queries.

You could try indexing you domain name, If you have data fields which have a
common value you can index the rest of the rows by the one common value.
Takes up a bit more space but is faster.

more info @
http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Optimization
.html#MySQL_indexes

cheers

Leon

-----Original Message-----
From: Chris Blessing [mailto:[EMAIL PROTECTED]]
Sent: 18 October 2001 15:20
To: Leon Noble
Subject: RE: general sql question


Leon-

Thank you very much for your help.  I tried what you stated below and I
think the problem is the selection/transfering of the 800,000+ email address
values rather than the mysql_num_rows() php function (regarding how slow the
page loads).

Any other ideas?  Thanks again, you've been very helpful.

-Chris

-----Original Message-----
From: Leon Noble [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 18, 2001 10:13 AM
To: Chris Blessing
Subject: RE: general sql question


Hi Chris,

give this a try

$result = mysql_query("select distinct email, count(*) as mycount from
subscribes");

cheers

Leon.

-----Original Message-----
From: Chris Blessing [mailto:[EMAIL PROTECTED]]
Sent: 18 October 2001 15:05
To: [EMAIL PROTECTED]
Subject: general sql question


Hi all-

I know this might seem simple, but for some reason I'm stumped.  What I'm
trying to do is get a count (from one table) of all the distinct values in a
particular field.  So for example, I'd be trying to find out how many unique
email addresses are in the table.

Right now I'm doing this with PHP, and while it works, it's very slow and
very clumsy.  Here's the code:

$result = mysql_query("select distinct email from subscribes");
$total = mysql_num_rows($result);

So it has to retreive ALL the email addresses (in this case, about 800,000)
and then count them.  I want to be able to do something like:

select count(distinct(email)) from subscribes;

But that's not legal.  Any thoughts/ideas you all could send in would be
great.  TIA!

Chris Blessing
[EMAIL PROTECTED]
http://www.330i.net


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to