Wow... well, I was certainly not speaking from direct experience, only from
what seemed to make sense to me. This tells me that their is some serious
room for improvement in PHP de-serialization code...

   td


Sorry Tony, I should have been more clear.  I already know that
storing session data in MySQL is faster than storing it in files.  I
know that goes against what you're saying, but there are some
examples if you Google "PHP MySQL session performance".  One of the
more interesting examples is http://shiflett.org/articles/guru-speak-
jan2005.  PHP session management defaults to files because it's more
portable and the performance difference doesn't matter for small
sites with few concurrent users.  MySQL also provides better
scaleability and security for session data.

On Oct 14, 2006, at 2:51 PM, Larry Garfield wrote:
> 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.

Good points Larry.  I have to look back, but I think we were
originally talking about basic user data.  ie. the user logs into the
site and we store their login information and access rights in a
session.  That seems like basic enough information that it's better
to just store the user id in session data and grab the rest of their
information from the db - not much of a difference in performance,
plus you end up avoiding stale data.  Anyway, I like your distinction
between simple and complex objects.

-Ed

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




--
Publish technical articles @ skilledwords.com and get 100% of the
ad-revenue!
http://www.skilledwords.com

Reply via email to