Re: PDO based Abstraction Layer for MySQL with Caching [message #180809 is a reply to message #180807] |
Tue, 19 March 2013 23:49 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 19/03/13 22:56, CPHR wrote:
> I am curious if anyone here can recommend a good abstraction layer
> for MySQL preferably PDO based. Something that has good caching
> that's automatic, for example I run the query and it will check to
> see if it has a cached result before attempting to do the query. I
> have been using EZ SQL but the caching leaves a lot to be desired and
> it uses the old mysql_* functions of PHP which are going to be
> depreciated.
>
mysql caches its results anyway.
ITYM deprecated. Not depreciated :-)
There is no need to have an abstraction layer to do that.
One might suggest that you investigate how to improve mysql caching -
give it more memory for example.
In my /etc/mysql/my.cnf are these lines
query_cache_limit = 1M
query_cache_size = 16M
Those are highly adjustable. On a big system I would up the size to a GB
or more, and the limit to 256MB. If that system is being worked hard
with similar selects ..
See:
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_ query_cache_limit
In addition judicious indexing can massively improve (some) slow queries.
This is all done at Mysql level: the PHP mysql libraries are only shims
to allow PHP to call into the daemon.
old or new, they do the same basic calls and ALL the time is in the
mysqld daemon on anything beyond a short select into a small table.
When I was working on a complex join, the uncached select was over 4
seconds, the cached was 30ms. With indexes added (occasional insert
update, MANY reads via select) the uncached was down to 250ms..
The actual query result wasn't large on that so it always cached OK
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|