Skip to content

Other functions

View as Markdown
BENCHMARK(count, expression)

Evaluates expression count times and returns the elapsed time in seconds. Use it to compare the cost of expressions and functions. count must be a positive integer; if it is NULL, the result is NULL. A subquery in expression may be evaluated only once and reused. Return type: DOUBLE.

SELECT BENCHMARK(100000, SHA1('coradb')); -- for example 0.022481736
SLEEP(seconds)

Pauses the statement for the given number of seconds, then returns 0. seconds is a DOUBLE, so fractions such as 0.5 are allowed. Use it to simulate slow work when testing timeouts or locking. Return type: INT.

SELECT SLEEP(3); -- returns 0 after three seconds
SYS_GUID()

Returns a random 32-character hexadecimal string, different on every call. Use it as a globally unique identifier. Return type: VARCHAR.

SELECT SYS_GUID();
938210043A7B4455927A8697FB2571FF