Disable cache for raw SQL query

Author Message

Scott Foster

Wednesday 16 February 2011 9:42:44 am

I'm trying to run a raw sql query and have it not be cached. When I run the following

$db = eZDB::instance( );
$query = 'select * from table';
$data = $db->arrayQuery( $query ); 
print_r ( $data );

It returns the results the first time, but not the second, third, etc time. I'm assuming ez publish caches those results somewhere. Is there anyway to disable cache just for a particular query?

André R.

Thursday 17 February 2011 10:17:32 am

My guess is that the code above is inside a template operator or similar which is called inside a template that is cached in view cache or cache-block.

You can disable both using site.ini settings for development, but for prod you should never disable cache unless you have a very low traffic site and you don't care about its performance, and green house gases.. :)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 00:46:44
Script start
Timing: Jan 18 2025 00:46:44
Module start 'layout'
Timing: Jan 18 2025 00:46:44
Module start 'content'
Timing: Jan 18 2025 00:46:46
Module end 'content'
Timing: Jan 18 2025 00:46:46
Script end

Main resources:

Total runtime1.3306 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9141152.6250
Module start 'layout' 0.00540.0036 740.539139.4531
Module start 'content' 0.00901.3204 779.9922523.5000
Module end 'content' 1.32930.0012 1,303.49228.3203
Script end 1.3306  1,311.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2339160.0002
Check MTime0.00130.0970160.0001
Mysql Total
Database connection0.00120.091810.0012
Mysqli_queries1.291497.0584540.0239
Looping result0.00040.0308520.0000
Template Total1.301597.820.6508
Template load0.00190.143120.0010
Template processing1.299697.673720.6498
Template load and register function0.00020.013410.0002
states
state_id_array0.00120.090310.0012
state_identifier_array0.00130.097920.0007
Override
Cache load0.00160.1188100.0002
Sytem overhead
Fetch class attribute can translate value0.00060.042720.0003
Fetch class attribute name0.00170.128930.0006
XML
Image XML parsing0.00060.048220.0003
class_abstraction
Instantiating content class attribute0.00000.000930.0000
General
dbfile0.00080.0628170.0000
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs