• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
speed & reliability
#4
Hi, sltfn

If possible, can I see the code for your update routine? Are you using cdb_update or cdb_batchUpdate? I recommend using the batch APIs whenever possible instead of using a loop for each record.

I created a test stack with a create button and an update button. The create button created 10,000 records using cdb_batchCreate and the update button updated those 10,000 records using cdb_batchUpdate. There were no failures for either. The create took 6.118 seconds and the update took 8.978 seconds. I've included my code for reference. Let me know if you have any questions.


This is the create button script:

on mouseUp
local tInputA, tTableID, tCounter, tOutputA, tRepetitions
local tStart, tEnd

put cdb_tableID("testTable") into tTableID
put 10000 into tRepetitions
put 0 into tCounter
repeat tRepetitions
add 1 to tCounter
put "test" & tCounter into tInputA[tTableID][tCounter]["firstName"]
put "name" & tCounter into tInputA[tTableID][tCounter]["lastName"]
put "test" & tCounter & "@mail.com" into tInputA[tTableID][tCounter]["email"]
put random(100) into tInputA[tTableID][tCounter]["age"]
put item random(2) of "M,F" into tInputA[tTableID][tCounter]["sex"]
end repeat

put the milliseconds into tStart
put cdb_batchCreate(tInputA, "cloud") into tOutputA
put the milliseconds into tEnd

put tEnd - tStart && "milliseconds"

put tOutputA[tTableID] into tOutputA
if the number of lines of the keys of tOutputA is not tRepetitions then
answer "There were" && tRepetitions - the number of lines of the keys of tOutputA && "failures."
else
answer "There were no failures."
end if
end mouseUp



This is the update button script:

on mouseUp
local tInputA, tTableID, tOutputA, tResultsA, tFailures
local tStart, tEnd

put cdb_tableID("testTable") into tTableID
put cdb_read(tTableID, "*", "cloud") into tOutputA

repeat for each key xRecordID in tOutputA
put tOutputA[xRecordID]["age"] + 1 into tInputA[tTableID][xRecordID]["age"]
end repeat

put the milliseconds into tStart
cdb_batchUpdate tInputA, "cloud"
put the milliseconds into tEnd

put cdb_read(tTableID, "*", "cloud") into tResultsA

put 0 into tFailures
repeat for each key xRecordID in tOutputA
if tResultsA[xRecordID]["age"] is not tOutputA[xRecordID]["age"] + 1 then add 1 to tFailures
end repeat

answer "There were" && tFailures && "failures."
put tEnd - tStart && "milliseconds"
end mouseUp
  Reply


Messages In This Thread
speed & reliability - by sltfn - 07-23-2019, 08:23 PM
RE: speed & reliability - by simon.schvartzman - 07-23-2019, 09:52 PM
RE: speed & reliability - by sltfn - 07-23-2019, 09:57 PM
RE: speed & reliability - by efrain.c - 07-24-2019, 01:05 AM
RE: speed & reliability - by clarencemartin - 07-24-2019, 03:41 AM
RE: speed & reliability - by sltfn - 07-25-2019, 05:39 PM
RE: speed & reliability - by mark_talluto - 07-25-2019, 09:35 PM
RE: speed & reliability - by sltfn - 08-13-2019, 12:17 AM
RE: speed & reliability - by mark_talluto - 07-25-2019, 09:38 PM
RE: speed & reliability - by mark_talluto - 07-26-2019, 11:56 PM
RE: speed & reliability - by simon.schvartzman - 07-28-2019, 09:38 PM
RE: speed & reliability - by efrain.c - 08-14-2019, 04:29 PM
RE: speed & reliability - by sltfn - 08-15-2019, 09:35 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)