Re: A no brainer...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 14 October 2006 11:02, Ed Lazor wrote:
> > Of course, the cost of serialization and deserialization is non-
> > trivial for
> > any data structure that is of interesting size, and you have to
> > keep in mind
> > that if you aren't syncing to the database periodically then you
> > will end up
> > with stale data objects.  (An issue in any case, but the longer the
> > object
> > representing a view of your database exists, the more of a problem it
> > becomes.  YMMV depending on the data you're holding.)
>
> Has anyone done tests on the difference between the value and
> performance of serializing data structures versus just pulling the
> data from the database?
>
> PHP stores session data in files by default.  There's gotta be a
> performance hit for the file access.  If you store session data in
> MySQL, you're still making a DB query.  It seems to me that the
> performance is almost the same, which means grabbing the current
> record ends up better because you avoid stale data.  What do you think?
>
> -Ed

It depends on what your data is.  

Is your data basic (a few elements in a linear array) or complex (a deeply 
nested multi-dimensional array or complex object?)  Deserializing a complex 
data structure can get expensive.

Is your data built by a single simple query against the database, a single but 
very complex query with lots of joins and subqueries, or a bunch of separate 
queries over the course of the program?  A single SQL query for cached data 
is likely faster than lots of little queries.

Is your data something that's going to change every few seconds, every few 
minutes, or every few days?  Caching something that will change by your next 
page request anyway is a waste of cycles.

Is your data needed on every page load?  Putting a complex data structure into 
the session if you only need it occasionally is a waste of cycles.  You're 
better off rebuilding it each time or implementing your own caching mechanism 
that only loads on demand.

There is no general answer here.

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux