Re: Is php4 Array searching faster than MySQL?

From: Date: Tue, 05 Sep 2000 09:30:43 +0000
Subject: Re: Is php4 Array searching faster than MySQL?
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-db+get-2613@lists.php.net to get a copy of this message
Hi, I'm in the process of moving as much information from MySQL tables (albeit HEAP ones) to PHP internal data structures i.e., arrays. I've identified the following pros and cons: + PHP arrays & objects can implement complex data structures, such as trees. Expressing these data structures in the relational framework, although possible, is sometimes a bit too abstract. + Getting the data out of the relational model often takes several queries. + With PHP's associative arrays, one has all the functionality of indices on a relational table. + One can save the overhead of: * constructing the SQL query string * sending the query from PHP to MySQL * parsing the SQL query in MySQL * planning the execution of the query * actually executing it, with possible disk accesses * sending the data back to PHP - Another phase of page generation pops up: The phase of initializing the internal data structures. I'm trying to employ some shared memory mechanisms to avoid the need to initialize the data structures for every page I generate. - The data volumes in-core are typically orders of magnitude lower than the data volumes for on-disk databases with a specialized server. Which need not be a problem if you take out just the `difficult bits' that are used often. Yes, I know I should use an object database with PHP bindings. Is there one? Jan Derek Sivers wrote: > > Has anyone found out the speed difference between > making an ARRAY of a full MySQL table, then SEARCHING > (if(in_array(...))) or finding values by > ($Array[table][value]) instead of doing MySQL queries > repeatedly? > > Just a GENERAL idea. I know it depends on how big the > table, how much RAM, disk speed, processor speed. > But just in general, anyone? > > I'm just at the start of a project, so the tables > aren't big enough for me to test it myself. But it's > for a high-traffic site so I'd like to plan ahead. > > Thanks!! > > Derek Sivers > linuxbaby@yahoo.com

« previous php.db (#2613) next »