[TYPO3-core] RFC: Bug #13508: Use exec_TRUNCATETABLEquery() instead of DELETE FROM throughout the core

Ernesto Baschny [cron IT] ernst at cron-it.de
Fri Feb 12 10:41:52 CET 2010


Hi,

my opinion on that matter, too. First, I have to agree with Dmitry:

Christian Kuhn schrieb am 11.02.2010 15:01:

> Thinking about it and reading answers in this thread I still think
> separation to different API methods is the better way in this special case:
> 
> - Truncate is supported by all major databases.
> - As pointed out by others, truncate and delete react pretty differently
> (auto_increments, triggers).

You might consider those "pretty different"; but I consider those two
issues very minor and only relevant for very special circumstances. 99%
of the times (in TYPO3 working at least) you don't have triggers and you
don't care about the auto_increment after a table-delete. Speed on the
other hand is always relevant.

> - Truncate should be pretty well known to developers, they are able to
> distinct it from delete.

Truncate is not "pretty well known", where do you have this information
from? You and other"power-developers" that are into the inner workings
of MySQL might be, but the most basic PHP developer is not aware of that.

Most developers want to concentrate on their "domain" and as Dmitry
said, the API should choose the fastest possible implementation.

> - The option "hide magic in delete method" with no way to change it's
> behavior from outside might lead to more trouble in the future.
> - The option "add magic to delete method but make it configurable with
> an option" practically leads to the same solution as a new public
> TRUNCATE method, except that a new method is more direct and
> transparent, and another option for DELETE just adds more things you
> have to remember / learn if you use the method. In both cases you have
> to think about which db call you actually need.

I would do it the other way around as suggested by Steffen (2):

Add $allowTruncate parameter to DELETE which is TRUE by default. This
way every DELETE automatically gets faster (TRUNCATE) and if some
extension really NEEDS the triggers or the auto-increment counter, it
can disable it.

Cheers,
Ernesto


More information about the TYPO3-team-core mailing list