Unix Technical Forum

MYSQL FUNCTIONS

This is a discussion on MYSQL FUNCTIONS within the MySQL General forum forums, part of the MySQL category; --> Hi All, While i was going through mysql reference manual. I saw that "A query cannot be cached if ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-10-2008, 04:55 PM
Krishna Chandra Prajapati
 
Posts: n/a
Default MYSQL FUNCTIONS

Hi All,

While i was going through mysql reference manual. I saw that

"A query cannot be cached if it contains any of the functions shown below"
BENCHMARK()
CONNECTION_ID() CONVERT_TZ()
CURDATE()
CURRENT_DATE() CURRENT_TIME()
CURRENT_TIMESTAMP()
CURTIME() DATABASE()
ENCRYPT() with one parameter
FOUND_ROWS() GET_LOCK()
LAST_INSERT_ID()
LOAD_FILE() MASTER_POS_WAIT()
NOW()
RAND() RELEASE_LOCK()

UNIX_TIMESTAMP() with no paramet-
SLEEP()
SYSDATE() USER()

On my production server, the following query is being used.
select * from student where regis_date=now();
Then what should i do so that the query get cached.

Thanks,
Prajapati

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-10-2008, 04:55 PM
Velen
 
Posts: n/a
Default Select Statement

Hi,

I need to write up a select statement something like:

Select a.supcode,a.code,b.desc,sum(c.qty),c.dept where a.supcode=b.supcode
and a.code=c.code and a.code=b.code and c.dept between $tring1 and $tring2.
group by supcode

This is fine but the problem is that there is duplicate supcode in a.

When running this query I often have c values which does not relate to
supcode.

Anyone can help?

Thanks

Velen


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-10-2008, 04:55 PM
Sebastian Mendel
 
Posts: n/a
Default Re: MYSQL FUNCTIONS

Krishna Chandra Prajapati schrieb:
> Hi All,
>
> While i was going through mysql reference manual. I saw that
>
> "A query cannot be cached if it contains any of the functions shown below"
> BENCHMARK()
> CONNECTION_ID() CONVERT_TZ()
> CURDATE()
> CURRENT_DATE() CURRENT_TIME()
> CURRENT_TIMESTAMP()
> CURTIME() DATABASE()
> ENCRYPT() with one parameter
> FOUND_ROWS() GET_LOCK()
> LAST_INSERT_ID()
> LOAD_FILE() MASTER_POS_WAIT()
> NOW()
> RAND() RELEASE_LOCK()
>
> UNIX_TIMESTAMP() with no paramet-
> SLEEP()
> SYSDATE() USER()
>
> On my production server, the following query is being used.
> select * from student where regis_date=now();
> Then what should i do so that the query get cached.


this would be like a time service would record once the current time, and
than always just send this recorded time ... wired, not?

--
Sebastian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-10-2008, 04:55 PM
Sebastian Mendel
 
Posts: n/a
Default Re: Select Statement

Velen schrieb:
> Hi,
>
> I need to write up a select statement something like:
>
> Select a.supcode,a.code,b.desc,sum(c.qty),c.dept where
> a.supcode=b.supcode and a.code=c.code and a.code=b.code and c.dept
> between $tring1 and $tring2. group by supcode
>
> This is fine but the problem is that there is duplicate supcode in a.
>
> When running this query I often have c values which does not relate to
> supcode.


yes, because c is JOINED by `code` and not by `subcode` with a "and
a.code=c.code"


--
Sebastian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-10-2008, 04:55 PM
Tim McDaniel
 
Posts: n/a
Default Re: MYSQL FUNCTIONS

On Mon, 10 Mar 2008, Krishna Chandra Prajapati <prajapatikc@gmail.com> wrote:
> While i was going through mysql reference manual. I saw that
>
> "A query cannot be cached if it contains any of the functions shown
> below"

....
> NOW()
> On my production server, the following query is being used.
> select * from student where regis_date=now();
> Then what should i do so that the query get cached.


<http://www.mysqlperformanceblog.com/2006/07/27/mysql-query-cache/> is
a paper that explains a bit about MySQL caching. It starts

First let me clarify what MySQL Query Cache is - I've seen number
of people being confused, thinking MySQL Query Cache is the same
as Oracle Query Cache - meaning cache where execution plans are
cached. MySQL Query Cache is not. It does not cache the plan but
full result sets.

That appears to be an expansion of the official text at
<http://dev.mysql.com/doc/refman/5.0/en/query-cache.html>, which is

The query cache stores the text of a SELECT statement together
with the corresponding result that was sent to the client.

(6.0's page has the same sentence.)

That leads me to think that the only way to cache the proposed query
would be to stop time. Otherwise, the result of running NOW() will
change from run to run, causing a different result set.

--
Tim McDaniel, tmcd@panix.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-17-2008, 06:13 AM
Sebastian Mendel
 
Posts: n/a
Default Re: Select Statement

Velen schrieb:
> Hi,
>
> I need to write up a select statement something like:
>
> Select a.supcode,a.code,b.desc,sum(c.qty),c.dept where
> a.supcode=b.supcode and a.code=c.code and a.code=b.code and c.dept
> between $tring1 and $tring2. group by supcode
>
> This is fine but the problem is that there is duplicate supcode in a.
>
> When running this query I often have c values which does not relate to
> supcode.


yes, because c is JOINED by `code` and not by `subcode` with a "and
a.code=c.code"


--
Sebastian

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:21 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com