Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

/proc/kallsyms format, sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas

Links

XODOX
Impressum

#1: PHP Mysql query caching - how to stop it

Posted on 2008-01-09 17:49:58 by michalkuls

I have recently recognized a problem, described it in a post a few
hours ago, but have revised my opinion on the problem. Now it looks as
follows:
The portal runs on apache/php/mysql. Php generates a query, and the
result returned is from a cache, not from the actual mysql db. The
data I receive is not up-to-date - to changes I make during this
time.
I have tried using mysql_unbuffered_query, but doesn't help.
I have finally come to the solution. At the end of list of fields
following SELECT statement, I entered rand() function which causes
that every query is different from the previous...
Looks like this: SELECT field1,field2,...,rand() FROM ...

But this solution is ugly and very unproffesional.
Do you have any better idea?
How to stop php/apache from buffering/caching mysql query results?

Thanks for any hints
Michal

Report this message

#2: Re: PHP Mysql query caching - how to stop it

Posted on 2008-01-09 20:28:34 by nc

On Jan 9, 8:49 am, michalk...@o2.pl wrote:
>
> The portal runs on apache/php/mysql. Php generates a query, and the
> result returned is from a cache, not from the actual mysql db. The
> data I receive is not up-to-date - to changes I make during this
> time.
> I have tried using mysql_unbuffered_query, but doesn't help.
> I have finally come to the solution. At the end of list of fields
> following SELECT statement, I entered rand() function which causes
> that every query is different from the previous...
> Looks like this: SELECT field1,field2,...,rand() FROM ...
>
> But this solution is ugly and very unproffesional.
> Do you have any better idea?
> How to stop php/apache from buffering/caching mysql query results?

Query caching is a MySQL-level setting; PHP and Apache have nothing to
do with it.

You have two options. One is to stop query caching entirely by
setting query_cache_type = 0 or query_cache_type = OFF in MySQL's
configuration file:

http://dev.mysql.com/doc/refman/4.1/en/server-system-variabl es.html#option_mysqld_query_cache_type

If you have no access to MySQL's configuration file, you can add a
SQL_NO_CACHE clause to your queries to request that MySQL run the
query rather than return a cached result:

SELECT SQL_NO_CACHE * FROM myTable;

See MySQL documentation:

http://dev.mysql.com/doc/refman/4.1/en/select.html

Cheers,
NC

Report this message

#3: Re: PHP Mysql query caching - how to stop it

Posted on 2008-01-10 10:38:39 by michalkuls

On 9 Sty, 20:28, NC <n...@iname.com> wrote:
> On Jan 9, 8:49 am, michalk...@o2.pl wrote:
>
>
>
> > The portal runs on apache/php/mysql. Php generates a query, and the
> > result returned is from a cache, not from the actual mysql db. The
> > data I receive is not up-to-date - to changes I make during this
> > time.
> > I have tried using mysql_unbuffered_query, but doesn't help.
> > I have finally come to the solution. At the end of list of fields
> > following SELECT statement, I entered rand() function which causes
> > that every query is different from the previous...
> > Looks like this: SELECT field1,field2,...,rand() FROM ...
>
> > But this solution is ugly and very unproffesional.
> > Do you have any better idea?
> > How to stop php/apache from buffering/caching mysql query results?
>
> Query caching is a MySQL-level setting; PHP and Apache have nothing to
> do with it.
>
> You have two options. =A0One is to stop query caching entirely by
> setting query_cache_type =3D 0 or query_cache_type =3D OFF in MySQL's
> configuration file:
>
> http://dev.mysql.com/doc/refman/4.1/en/server-system-variabl es.html#o...
>
> If you have no access to MySQL's configuration file, you can add a
> SQL_NO_CACHE clause to your queries to request that MySQL run the
> query rather than return a cached result:
>
> SELECT SQL_NO_CACHE * FROM myTable;
>
> See MySQL documentation:
>
> http://dev.mysql.com/doc/refman/4.1/en/select.html
>
> Cheers,
> NC

Thanks, this helps!
Michal

Report this message