Skip to content

Commit b853415

Browse files
pavelmashpavel.mash
authored andcommitted
- for /updates with count <=15 use 'case .. when .. then' pattern, for count > 15 - 'unnest' pattern (TechEmpower#8031)
- using binary parameter binding format for Int4/Int8 parameter types - should be faster than textual Co-authored-by: pavel.mash <[email protected]>
1 parent e1fb6ea commit b853415

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

frameworks/Pascal/mormot/setup_and_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ echo "Download statics from $URL ..."
3535
wget -qO- "$URL" | tar -xz -C ./libs/mORMot/static
3636

3737
# uncomment for fixed commit URL
38-
URL=https://github.com/synopse/mORMot2/tarball/46f5360a668ccf7a7c4d538fb319b449da8a232f
38+
URL=https://github.com/synopse/mORMot2/tarball/c57d48846f050f4f68856758d28cf76450addaf2
3939
#URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
4040
echo "Download and unpacking mORMot sources from $URL ..."
4141
wget -qO- "$URL" | tar -xz -C ./libs/mORMot --strip-components=1

frameworks/Pascal/mormot/src/raw.pas

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function TRawAsyncServer.cached_queries(ctxt: THttpServerRequest): cardinal;
295295
var
296296
i: PtrInt;
297297
res: TOrmWorlds;
298-
cache: POrmCacheEntry;
298+
cache: POrmCacheTable;
299299
begin
300300
cache := fStore.Orm.Cache.Table(TOrmCachedWorld);
301301
SetLength(res, GetQueriesParamValue(ctxt, 'COUNT='));
@@ -479,14 +479,16 @@ function TRawAsyncServer.rawupdates(ctxt: THttpServerRequest): cardinal;
479479
cnt := getQueriesParamValue(ctxt);
480480
if not getRawRandomWorlds(cnt, res) then
481481
exit;
482-
if cnt > 20 then
482+
// generate new randoms
483+
for i := 0 to cnt - 1 do
484+
res[i].randomNumber := ComputeRandomWorld;
485+
if cnt > 15 then
483486
begin
487+
// fill parameters arrays for update with nested select (PostgreSQL only)
484488
setLength(ids{%H-}, cnt);
485489
setLength(nums{%H-}, cnt);
486-
// generate new randoms, fill parameters arrays for update
487490
for i := 0 to cnt - 1 do
488491
begin
489-
res[i].randomNumber := ComputeRandomWorld;
490492
ids[i] := res[i].id;
491493
nums[i] := res[i].randomNumber;
492494
end;
@@ -496,10 +498,10 @@ function TRawAsyncServer.rawupdates(ctxt: THttpServerRequest): cardinal;
496498
end
497499
else
498500
begin
501+
// fill parameters for update up to 15 items as CASE .. WHEN .. THEN ..
499502
stmt := conn.NewStatementPrepared(ComputeUpdateSql(cnt), false, true);
500503
for i := 0 to cnt - 1 do
501504
begin
502-
res[i].randomNumber := ComputeRandomWorld;
503505
stmt.Bind(i * 2 + 1, res[i].id);
504506
stmt.Bind(i * 2 + 2, res[i].randomNumber);
505507
stmt.Bind(cnt * 2 + i + 1, res[i].id);

0 commit comments

Comments
 (0)