Re: SESSIONS vs. MySQL
| From: | Wolf | Date: | Fri, 19 Sep 2008 15:54:02 +0000 |
| Subject: | Re: SESSIONS vs. MySQL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-280514@lists.php.net to get a copy of this message | ||
---- Philip Thompson <philthathril@gmail.com> wrote:
> Hi all.
>
> Let me start out by saying, I have STFW and read through the list
> archives. Now that that's out of the way.
>
> To speed up our application, we want to implement using SESSIONs in
> some locations. Beforehand, on every page, we would run approximately
> 30-40 queries just to get the page setup - user information and other
> stuff. Now while we can't take away all of the setup queries, we would
> like to reduce the startup number.
>
> Ok, so I've implemented this in several places where information
> basically does not change from page to page. Jumping to the point/
> question... when does it become more inefficient to store lots of
> information in SESSION variables than to run several more queries?
> Note, we are actually storing sessions in the database - so a read/
> write is required on each page load - it's not file sessions.
>
> Now I know this can depend on the complexity of the queries and how
> much data is actually stored inside the sessions... but initial
> thoughts? To give you a number, the strlen of the _SESSION array is
> 325463 - which is equivalent to the number of bytes (I think).
>
> Thanks,
> ~Philip
We carry a sh!tload of information in our session, without slowing anything down. In fact, it takes
the servers longer to run a full query then to use the session information.
But we use the $_SESSION information. Our first query sets everything up in the session and we take
on from there, and use stuff from the $_SESSION to actually make the rest of the pages faster.
30-40 queries just to set up a page? That's an abomination that shouldn't see the light
of day.
Anything slower then 2 seconds without any interaction back to the users will be short-lived....
Wolf