Re: SESSIONS vs. MySQL

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

 



On Fri, 2008-09-19 at 12:47 -0500, Philip Thompson wrote:
> >
> > Why do you have so many queries?   Perhaps we can attack this issue
> > from another angle.
> 
> I've narrowed it down to 10 initial queries...
> 
> 1. Grab system config data (that's used in lots of places)

Why not use some form of cache system that writes the config data to a
file containing PHP code. Then this can be included at run-time and
benefit from compile cachee accelerators like eAccelerator and APC?

> 2. Grab session data (for SESSION array)

Fine.

> 3. Grab page id

Grab the page ID? Don't you already have it if you're on the page?

> 4. Grab user privs

This should be cached. Cache can be updated when you detect that user
information has changed (do this when verifying user session).

> 5. Grab user session (for application)

How is this different than the session data?

> 6. Begin transaction
> 7. Lock user session row
> 8. Update user session
> 9. Commit transaction

Are you performing a transaction with locking for a single table row
update? Seems wasteful. I'm sure the above could just consist of the
update.

> 10. Add page tracking (an insert-only table that keeps track of pages
> you visit)

Fair enough.

> Note that these are the 10 queries that happen after the initial  
> SESSION load. I supposed I could reduce this by 1 or 2 queries - I  
> could store the page id/information in the session. Now with that  
> said, the queries are negligible (in elapsed time) and required.
> 
> However, I'm always open up to suggestions/improvements.... =D

I agree, these queries are probably quite negligible. If your page is
taking a long time to load there's probably lower hanging fruit for
optmization attempts. The problem is determining what they are. Another
thing to improve database queries btw, if you're not already doing it...
is to use the direct socket connection if you are on the same server as
the database.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
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