[TYPO3-dev] mysql/mysqli and prepared statements

ries van Twisk typo3 at rvt.dds.nl
Sun Oct 7 14:23:12 CEST 2007


On Oct 7, 2007, at 3:22 AM, Martin Kutschker wrote:

> ries van Twisk schrieb:
>> Hey Martin,
>>
>> I have reading somewhere that when using
>> MySQL with prepared statements that the query cache
>> get's by-passed.
>
> But the query cache is for exact the same statements. Prepared queries
> are for nearly the same queries, where you cache the query plan,  
> not the
> result.

If a server is under load with XX hits per second,
then the exact same prepared statements and queries get executed
for each users loading data from the server (let's say homepage).

This is where a query cache will benefit.

Ries

>
> So you shouldn't use prepared queirs everywhere but only in loops  
> like this:
>
> foreach ($someArray as $id) {
>    prepare("SELECT foobar FROM table WHERE uid=$id");
> }
>
>> Note: since we use the unix timestamp the MySQL
>> query cache for SQL's we execute is valid for one
>> second anyways. Wasn't there a patch underway for this?
>
> I don't get what you're hinting at.
>
> Masi
>










More information about the TYPO3-dev mailing list