|
Posted by Sandman on 11/23/06 23:10
In article <qaydnYZn7rlKvfvYnZ2dnUVZ_qmdnZ2d@comcast.com>,
Jerry Stuckle <jstucklex@attglobal.net> wrote:
> > Eh? I *AM* using MySQL. As shown in my code above. Using MySQL for
> > this takes too long.
>
> OK, I thought you were saying the information you're after was not on
> the database. My misunderstand.
No problem.
> What's "too slow"? 1 second? 10 seconds? 100 seconds? How many rows
> are you talking about?
Everything over 0.1 seconds is way too slow. Today the tables contains
about 9000 members, and the time it takes to fetch information about
them takes around 0.8 seconds, but actually *selecting* them in MySQL
only takes about 0.16 seconds, the rest of the time, I'm assuming, is
moving that data from MySQL to a PHP array.
I assure you that I am quite conscious about time consumptions in my
PHP scripts and use a gauge() function to time pretty much every
important part of producing the HTML for a web page. Each millisecond
counts and I have a performance warning system that activates when a
page takes longer than 2 seconds to create.
All my MySQL tables are quite optimized along the usual optimization
tricks with regards to indexing and direct/matching queries.
> Sure, you can implement this in flat files. But it's going to take
> longer to search your flat files in PHP than MySQL does in compiled
> code. The same is pretty much true for searching an array in PHP -
> small arrays are faster, but as the array grows, the difference becomes
> less.
But I wouldn't be searching. The flatfile would be named
"/path/to/aggregate/members/2837.txt" or something like that.
The data in that could even be serialized for easy management, so
reading it would be like:
function member_name($id){
$member = unserialize(join("", file("/path/to//2837.txt")));
return $member["name"];
}
Problem with this is that this information needs to be aggregated once
in a while...
Plus, what I'd like to know is if:
$member = unserialize(join("", file("/path/to//2837.txt")));
Is faster than:
$q=mysql_query("select x, x, x from member where id = 2837");
$member = mysql_fetch_array($q);
I guess I have to test it. I was hoping that someone here might have
known or knew of a third option for doing the same thing.
> You'd be much better off optimizing your database (and the database
> design, if necessary), and potentially your queries. I can't see why it
> should take all those queries to get the info you want.
It's just one query... And that query takes, today, 0.8 seconds, which
is too long. And when the member count grows, it will take longer and
longer.
--
Sandman[.net]
Navigation:
[Reply to this message]
|