2013-06-26 18:24:41 |
Matthias Brantner |
description |
The "castable as" expression has a big performance bottleneck because its implementation uses cast as followed by catching a potential exception. Constructing the exception (including the parameter substitution for the error message) takes a lot of time and it's not needed. |
The "castable as" expression has a big performance bottleneck because its implementation uses cast as followed by catching a potential exception. Constructing the exception (including the parameter substitution for the error message) takes a lot of time and it's not needed.
A query to reproduce this is as follows:
jsoniq version "1.0";
for $value in
(
"true", "false", ((1 to 1000) ! ($$ cast as string))
)
return
if ($value castable as boolean)
then $value cast as boolean
else if ($value castable as double)
then $value cast as double
else if ($value castable as decimal)
then $value cast as decimal
else if ($value castable as integer)
then $value cast as integer
else $value
The attached screenshot shows the relevant part of a callgrind profile. |
|