tags:

views:

26

answers:

1

Hi,

Does anybody know what the performance of using substring in MySQL is like? I have some insert and update calls where I have to truncate all the fields (up to around 15) using substring statements. These will get call pretty regularly so I'm a little worried about performance.

+2  A: 

Intensive string handling in SQL generally performs relatively poorly (it's not what SQL was designed for).

But you should first profile to make sure you actually have a bottleneck.

[If you were using MS SQL Server, then any complex string handling (like regular expression matching) should probably use a CLR stored procedure.]

Mitch Wheat
He's on MySQL...
Martin Smith
@Martin Smith: Cheers! updated.
Mitch Wheat
@Mitch - I took the liberty of removing a couple of superfluous `T`'s left behind!
Martin Smith
yeah sorry I was pretty implicit with it being in my tag only
stevebot
@Martin Smith: TSQL is a standard, isn't it? but if it's not thanks! :)
Mitch Wheat
do you have a reference or an explanation for why SQL performs poorly at intensive string handling?
stevebot
@stevebot: it's from experience. But you can quickly write some small tests to verify...
Mitch Wheat