473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

sql qurey_cache

Hi when I read the documentation about how the query it's doesn't clear
my mind about how it can optimize db quering.

When I include a SQL_CACHE clause in a query, does the datas are stored
in memory or not ?

If for exemple I've a series of queries :

SELECT [fields] FROM [db] WHERE [statement= value1]
SELECT [fields] FROM [db] WHERE [statement= value2]
SELECT [fields] FROM [db] WHERE [statement= value3]
SELECT [fields] FROM [db] WHERE [statement= value4]

the only things who change are the statement, any optimisation is
possible by adding "SELECT SQL_CACHE" ?

In the documentation I read :
" Queries are compared before parsing, so the following two queries are
regarded as different by the query cache:"

In my example does caching by adding SQL_CACHE are done for each queries ?

thx for your response
Jul 23 '05 #1
4 1257
Alexandre Jaquet wrote:
When I include a SQL_CACHE clause in a query, does the datas are stored
in memory or not ?
Sometimes.

If I understand the documentation correctly, you must set the system
variable query_cache_size. This is the amount of memory mysql allocates
for the query cache. It is zero (0) by default, which effectively
disables query caches. You should set this variable.
the only things who change are the statement, any optimisation is
possible by adding "SELECT SQL_CACHE" ?
It depends on the expression used in the statement, and also it depends
on whether the table is updated between the times when you execute your
cached queries.
In the documentation I read :
" Queries are compared before parsing, so the following two queries are
regarded as different by the query cache:"


There are other conditions that cause the cached query to be discarded.
For example, any INSERT, UPDATE, or DELETE to a table causes its
cached queries to be invalidated and the queries' results are removed
from the cache.

There are also several types of query expressions that prevent a query
from being cached. Read the documentation for details.

Regards,
Bill K.
Jul 23 '05 #2
Bill Karwin <bi**@karwin.com> wrote in news:d0*********@enews1.newsguy.com:

Regards,


please don't ever disappear from this newsgroup! i'm sure i will have a
question for you some day, and your responses to others have always been
incredible!!!
Jul 23 '05 #3
Good Man wrote:
please don't ever disappear from this newsgroup! i'm sure i will have a
question for you some day, and your responses to others have always been
incredible!!!


Thanks!! I like doing it. Answering people's questions leads me to
research areas of MySQL that I don't normally use. It's a great way to
learn. One of these days I should be ready to take their certification
exams.

Regards,
Bill K.
Jul 23 '05 #4
"Alexandre Jaquet" wrote:
Hi when I read the documentation about how the query it's
doesn't clear
my mind about how it can optimize db quering.

When I include a SQL_CACHE clause in a query, does the datas
are stored
in memory or not ?

If for exemple I've a series of queries :

SELECT [fields] FROM [db] WHERE [statement= value1]
SELECT [fields] FROM [db] WHERE [statement= value2]
SELECT [fields] FROM [db] WHERE [statement= value3]
SELECT [fields] FROM [db] WHERE [statement= value4]

the only things who change are the statement, any optimisation
is
possible by adding "SELECT SQL_CACHE" ?

In the documentation I read :
" Queries are compared before parsing, so the following two
queries are
regarded as different by the query cache:"

In my example does caching by adding SQL_CACHE are done for
each queries ?

thx for your response


Besides other responses, you may want to think of this:

Let’s say you have have done a name/address lookup via mysql and it is
cached. Now if the table is updated for whatever reason, the cache is
busted (e.g. a new user added).

In such cases, you may want to look at a non-db related cache. I used
cacheLite. Works pretty nice, for things that I know don’t change
regardless of the tables chaning.

--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/mySQL-sql-qu...ict202517.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=741486
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.