[TYPO3-dev] Questions about exec_PREPAREquery

Stefan Frömken firma at sfroemken.de
Thu Jun 9 22:14:33 CEST 2011


I can also confirm, that Prepare-Statements are useless if you have only 
one or two queries. Prepare-Statements are only usefull when you have a 
mass of nearly the same queries one after the other.

Am 07.06.2011 09:13, schrieb Mathias Schreiber [wmdb]:
> Am 06.06.11 20:55, schrieb Stefan Frömken:
>> I'm wondering that TYPO3-Statements are faster than the old way
>> allthough TYPO3-Statements are using the same functions like the old
>> way. And it has to load an additional class.
>>
>> I don't understand this?!?! Why is it faster?
>
> Let me take you into the insides of a database.
> You say "give me row 14 of table pages".
> MySQL will then parse that query and check it for errors.
> After that it will be recoded into binary data (if using a remote host)
> and sent to the DB server.
>
> Now imagine a typical TYPO3 scenario with hundreds of queries that look
> almost the same.
> MySQL will parse the query once (!), check it for syntax errors once (!)
> and recode it to binary once (!).
>
> Additionally there was some talk about query-caching prep-statements as
> well, but I never really checked if it became part of the mySQL code.
>
> On the other hand, there is one downside (like always in life :)):
> Say you have a remote DB host that is either very far away from your
> webserver or under heavy load or whatever slows the machine down.
> Using prep-statements always include 2 messages to the server rather
> than one.
> If you have long trip times (> 40ms) to your mysql host, prep-statements
> might work out worse than normal statements.
>
> THis is why I did not opt for "prep-statements all throughout the TYPO3
> core" because under certain consitions it makes things worse :/
> Unfourtunately, in 99% of all use-cases, they are better in every respect.
>
> Hope this clears things up a bit.
> cheers
> Mathias
>





More information about the TYPO3-dev mailing list