workerholic@xxxxxxxxxxxx wrote:
hi andrew i think you understand my problem a little,
but if 100 user load this query at the same time, the two mysql server
had a lot to do!
so i think to cache this query as xml to the application server local
make thinks faster,
but, i would like to have the same performance to read this xml document
as read the query from mysql server...
i dont know why php is so slow to read the xml file...
Are you saving to file or caching as a query result?
Also note that you can cache an array of rows (at least with APC but I
suspect memcache as well) - say my_fetch(key) is you function to fetch
from cache and my_store(key,data,life) is your function to store.
$result = my_fetch('big_query');
if (! $result) {
$sql = 'your query';
$rs = mysql_query($sql);
while ($row = mysql_fetch_object($rs)) {
$result[] = $row;
}
my_store('big_query',$result,21600);
}
No xml involved and you can loop through the results.
If you'd rather do it as xml, you can cache the xml as a string and then
fetch it, importing it into a DOM or whatever to extract your results.
$xml = my_fetch('queryResultAsXML');
if (! $xml) {
generate xml and cache it
}
$dom = new DOMDocument('1.0','utf-8');
$dom->loadXML($xml);
Not sure what you are doing, apoligize if these suggestions are useless
or already considered.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php