Re: [PHP] A no brainer...



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
.



Relevant Pages

  • Re: [PHP] A no brainer...
    ... 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 ... PHP stores session data in files by default. ... There's gotta be a performance hit for the file access. ...
    (php.general)
  • Re: counting records that are true
    ... you might want to think about your data structure. ... help you normalize the data. ... I've set up a database where I need to count the records where =yes ... really stuck - is this done in a query or the report footer? ...
    (microsoft.public.access.reports)
  • Re: CBO influences
    ... > databases from 8i to 9i, and so have several copies of this database ... > generating an access plan that featured several hash joins, ... Initialization parms idendtical, data structure and volume ...
    (comp.databases.oracle.server)
  • Re: Database Design
    ... duty vehicles, rental equipment, parts used for maintenance. ... For instance one employee may assigned to a vehicle during their shift. ... When you get to convert these entities into tables you can create a Physical Data Structure ERD. ... Each of those entities is likely to become a table in your database and everything you have on your yellow pad is likely to become a field. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Process to modify multiple queries simultaneously
    ... Access is a relational database product. ... Disclaimer: This author may have received products and services mentioned ... you lost me on data structure. ... "Jeff Boyce" wrote: ...
    (microsoft.public.access.queries)

Loading