Re: [PHP] A no brainer...



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


Relevant Pages

  • Re: [PHP] saving resource objects
    ... ML> from a LAMP box using PHP. ... ML> The first time I print RESS is comes back as RESOURCE OBJECT #12, ... When I look in the session file, ... You will have to rerun the query again. ...
    (php.general)
  • Re: Looking for general advice on security
    ... PHP pages have to be world-readable, ... SSL provides a way for a thief with a browser to communicate with ... cookies because the user can't fake a session with arbitrary contents, ... Try to send a message to the user and see if the mail server ...
    (comp.lang.php)
  • Re: query string passing woes........ help... please....
    ... |> | offer any help other than saying that my validation could be FAR more ... I'm a total newbie at php. ... The easiest way for you would be to make the html form called form.php ... $_SESSION array using the same names. ...
    (alt.php)
  • Advisory 01/2006: PHP ext/session HTTP Response Splitting Vulnerability
    ... PHP ext/session HTTP Response Splitting Vulnerability ... PHP applications using PHP5's session extension are ...
    (Bugtraq)
  • Re: PHP sessions and disabled cookies
    ... Cookies are blocked in my ... I do not see the URL containing the session ID. ... [PHP] ... A warning appears if the specified function is not defined, ...
    (php.general)