on 2019 Jan 06 1:37 PM
replace function,on over 64000 bytes length string , takes 35 ms at ver 9.0.2 same procedure same function, less then 64000 bytes, takes 1.2 sec at ver 17
if command out the replace function line, there are no differences.
any suggestions?
Request clarification before answering.
When benchmarking how long SQL takes to run, be careful not to include unrelated overhead costs like how long ISQL takes to process SQL statements.
In this case, 10 UPDATE statements using REPLACE took 250 milliseconds, or 25 milliseconds per REPLACE plus UPDATE.
The benchmark SQL was put inside a BEGIN block to exclude ISQL overhead.
Conclusion: The long string may be expensive to handle, but it may not be the fault of REPLACE... maybe it is the two concatenation "+" operations, both of which require the entire string to be copied.
CREATE TABLE t ( pkey INTEGER NOT NULL DEFAULT AUTOINCREMENT PRIMARY KEY, data LONG VARCHAR NOT NULL ); INSERT t ( data ) VALUES ( 'oSL8qNuMEKAfGO266USE ... Vlad's string ... AIAgwL7TQhETRXgSShUf' ); COMMIT; CHECKPOINT; BEGIN DECLARE @started TIMESTAMP; SET @started = CURRENT TIMESTAMP; UPDATE t SET data = REPLACE ( data, ' ', '[' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '[', '/' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '/', '*' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '*', '&' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '&', '^' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '^', '!' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '!', '+' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '+', '=' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '=', '~' ) WHERE pkey = 1; UPDATE t SET data = REPLACE ( data, '~', ' ' ) WHERE pkey = 1; SELECT DATEDIFF ( MILLISECOND, @started, CURRENT TIMESTAMP ) AS elapsed_msec; END; elapsed_msec -------------------- 250
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
30 | |
10 | |
8 | |
8 | |
7 | |
7 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.