Click here to get back home

Does the mysql_query function already fetch the data ?

 HomeNewsGroups | Search

comp.lang.php - PHP programming language discussions 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Does the mysql_query function already fetch the data ? Johannes Keßle 02-08-2010
Posted by Johannes Keßle on February 8, 2010, 10:06 am
Please log in for more thread options


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

the documentation says:
The returned result resource should be passed to mysql_fetch_array(), and other
functions for dealing with result tables, to access the returned data.

Does this mean that all the data is already fetched from the DB and loaded into
RAM and I only need the mysql_fetch_* functions to extract it ?

eg.

$query = mysql_query("SELECT * FROM `table`");

If in table are rows worth some megaBytes, are those megabytes already loaded
into RAM or is this only happening if if I use mysql_fetch_assoc/array etc.

eg.

$query = mysql_query("SELECT * FROM `table`");
// is the data already here loaded into RAM
while($result = mysql_fetch_assoc($query)) {
$newArray[] = $result;
// or at this point ?
}


regards,
johannes keßler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAktwKHUACgkQE++2Zdc7Etd1PwCfcJttayTQuImXhipHk5ocdY2M
VdMAn2nZJIyCaThw+zXDRYBaDqx7wJCR
=b1CY
-----END PGP SIGNATURE-----

Posted by Jerry Stuckle on February 8, 2010, 11:33 am
Please log in for more thread options


Johannes Keßler wrote:
show/hide quoted text

These are mysql calls. Try asking in comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Posted by Peter H. Coffin on February 8, 2010, 11:37 am
Please log in for more thread options


On Mon, 08 Feb 2010 16:06:30 +0100, Johannes Keßler wrote:
show/hide quoted text

hmmm... If I remember correctly, it doesn't fetch ALL the data
necessarily, just enough to fill the connection buffers. Looping through
and filling an array will (eventually) put all the data into memory (the
array) but that runs the risk of becoming Very Large, possibly too large
for the allowed memory of the php process.

--
93. If I decide to hold a double execution of the hero and an underling
who failed or betrayed me, I will see to it that the hero is
scheduled to go first.
        --Peter Anspach's list of things to do as an Evil Overlord

Posted by matt on February 8, 2010, 2:45 pm
Please log in for more thread options


wrote:
show/hide quoted text
other
show/hide quoted text
d into
show/hide quoted text
aded
show/hide quoted text
c.
show/hide quoted text

You could always run some tests with memory_get_usage()


Posted by C. (http://symcbean.blogspot.c on February 9, 2010, 7:55 am
Please log in for more thread options


show/hide quoted text
nd other
show/hide quoted text
ded into
show/hide quoted text
loaded
show/hide quoted text
etc.
show/hide quoted text

No - the client libs will buffer the results (potentially the complete
result set even before any call to mysql_fetch_....) but outside the
PHP memory area - IIRC memory_get_usage only reports memory allocated
by PHP.

C.

Similar ThreadsPosted
fetch array function July 2, 2008, 6:12 pm
How to "fetch" a certain id November 16, 2006, 9:07 pm
Fetch username February 10, 2009, 10:13 pm
pop3 mail fetch with PHP August 18, 2005, 4:13 am
select on updated value during the fetch June 16, 2006, 3:52 am
Fetch array, display and update, all in one.. ? September 2, 2004, 1:03 pm
Fetch array, display and update, all in one.. ? September 7, 2004, 1:17 pm
Fetch childNodes Array using SimpleXMLElement September 13, 2009, 5:05 pm
IMDB fetch with PowermovieList Hangs for exact matches May 6, 2008, 9:06 am
function to simplify data September 4, 2005, 10:10 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy