Skip to content

Do insert_many and graph_batch beat plain SQL and Cypher loads? #356

Open

Description

@tae898

Problem

The bindings follow a DSL-first rule: SQL and Cypher through db.query and db.command, with wrappers only where they pay. I want measured evidence of whether insert_many and graph_batch beat plain SQL or Cypher loads, and by how much.

It is one row of the bindings study list. It was held on stale pins and re-pins after the 26.12.1 wheels exist.

Priority: P3 (tier 1 of the re-pin order).

Acceptance

  • The study is re-pinned to the 26.12.1 wheels and dry-run
  • It runs and is scored
  • The wrapper speedup, or its absence, is stated in the docs and decides whether the wrapper stays

Results and the scorer output go in this issue as comments. Numbers are generated by script from the result files, never typed.

(Edited 2026-11-23: the study now measures on the 26.12.1 wheels, see #315.)

Activity

  1. added
    python
    performance
    on Nov 10, 2026
  2. added this to the 26.12.1 milestone on Nov 10, 2026
  3. modified the milestones: 26.12.1, 27.1.1 on Nov 21, 2026
  4. added
    enhancement
    on Dec 2, 2026
  5. tae898 commented on Dec 5, 2026

    @tae898
    CollaboratorAuthor

    I am writing the rules of this measurement down before its first run.

    Question. Do insert_many and graph_batch beat the plain SQL and Cypher statements a user could write instead, on arcadedb (native) and on arcadedb-jvm at 26.12.1.dev2? By how much? The answer decides whether the Python docs keep recommending the two wrappers as the bulk-load path, and whether they stay under the bindings' rule "SQL and Cypher first, wrap only where it pays".

    Arm documents graph
    A (reference) insert_many, the wheel's default commit_every graph_batch with create_vertices and new_edges on the returned RIDs
    B INSERT INTO T CONTENT :rows, 10,000 rows as one list parameter per transaction CREATE VERTEX V CONTENT :rows in chunks of 10,000, then one CREATE EDGE E FROM (SELECT ...) TO (SELECT ...) per edge
    C one INSERT INTO T SET ... per row, a transaction per 10,000 rows openCypher UNWIND ... CREATE for vertices, UNWIND ... MATCH ... CREATE for edges, 10,000 per statement and transaction
    D openCypher UNWIND $rows ... CREATE, 10,000 per statement and transaction (T is a vertex type here, so its bytes are not comparable) none
    E INSERT INTO T CONTENT [...] with the chunk as a JSON text literal none
    Z A again, the A/A control A again

    Each run is one fresh process. Schema and the UNIQUE index on id are created before the clock starts. The documents have 7 properties (integers, a double, strings, a boolean, a list of 3 strings), 1,000,000 of them. The graph has 200,000 vertices and 500,000 edges chosen by key with a fixed seed (self loops and repeats allowed). The gating figure is total_s, the whole timed load including the row generation, which is the same for every arm. Each wheel is scored on its own and the two wheels are never compared with each other.

    Verdict. Per wheel, shape and statement arm S, the ratio S / A of total_s: the median of the per-round ratios with a 95% bootstrap interval (10,000 resamples, seed 1). Above 1.00 the statement form is slower than the wrapper.

    arm verdict condition
    EARNS the lower end of the interval is above 1.05 (the wrapper is faster)
    REDUNDANT the upper end is below 1.03 (the statement is as fast or faster)
    CLOSE neither

    The verdict of a wheel and shape is REDUNDANT if any statement arm is REDUNDANT, EARNS if every statement arm EARNS, and CLOSE otherwise. All arm rows stay in the results, so a reader can drop arm E (my addition, a plain statement) and see whether a verdict changes. The speedup I would quote in the docs is 1 / ratio with the interval inverted: the wrapper over the per-row loop for documents (arm C), and over the per-edge SQL form for the graph (arm B). I will recommend a statement form over the wrapper for a wheel and shape only if the lower end of every statement arm I name is at most 1.03, and I will not call it a speed claim. A result whose interval lies in [0.97, 1.03] is called equal, and nothing else is. Peak memory, file size, lookup time and generation time are reported and decide nothing.

    Pins, validity, throttle rule, repetitions, and limits

    Pins.

    What Pin
    native wheel, linux x86_64 sha256 2913537be9f3cef65a43ea8ff29d0f998dd115e8fb870b1d9c323b989ac2d6d9
    JVM wheel, linux x86_64 sha256 5fbbdf30d2b8e0ee69aefa9c0881bd62a2858c9904588fd44d58eb9f2d498dd8
    bindings commit 4b8a5b18ea7b54deac8fc7874248f691973133aa
    engine 26.12.1.dev2, one engine version and build commit in every run
    Python 3.12, numpy 2.5.4, JPype1 1.7.1 (JVM arm only)
    heap the same explicit maximum of 3 GB on both wheels in every run
    host my laptop (Core Ultra X9 388H, Linux), two pinned E cores, turbo on, powersave governor, editor, browser, and agent sessions held on other cores. The figures are relative only
    kit the checksum file of the scripts has sha256 a1195eee68a6160c7f78beb9ff50b08e7caaee90e070a1e2d3e5653b34a0cd26

    The final 26.12.1 wheels are not on PyPI yet, so this runs on the newest ones, 26.12.1.dev2. I will repeat it on the final wheels as a new run.

    Validity, checked before any verdict. A unit (one wheel and one shape) is INVALID when a run did not use the wheel of its arm, a wheel version, commit, engine version, or engine build commit differs from the pins or between runs, the runs did not all get the same maximum heap, or the throttle counters cannot be read. A run counts only when the backend is the wheel's, the stored counts are right (graph: 200,000 vertices and 500,000 edges), 2,000 random stored records plus ids 0, 7, and the last equal the generator in every property, for 200 of them the out('E') and in('E') neighbour lists equal the edge list (graph), EXPLAIN of id = 7 uses the index, and a duplicate id is refused. A figure is INVALID when the A/A control (Z / A of total_s) has fewer than 10 clean pairs or an interval that excludes 1.00, or the A/A median of peak memory is outside [0.95, 1.05]. It is WEAK when an arm has fewer than 10 clean pairs or an interval wider than 0.10 times its median. INVALID and WEAK figures report no result. A run that fails is left out and listed; a unit stops after a failed run in its first round, or after 3 failed runs in a row.

    Throttle and interference rule. A run starts when the package is at most 70 C (after the first run of a round also at most 2 C above that run's start), after at most 180 s of waiting. A pair is dropped when the two runs' throttled share of the timed window differs by more than 1 percentage point, when their start temperatures differ by more than 5 C, or when my interference sampler marked either run (more than half a core of other work on a group of cores, other benchmark work, a camera, or a suspend).

    Repetitions and stopping. In a round, each unit runs its arms back to back, one process each, the order rotated and reversed from round to round. Rounds 0 to 12 (round 0 is dropped), then 2 more for a unit that has a WEAK or INVALID gating figure, at most up to round 24. No round starts that is not expected to end 15 minutes before the 11-hour time limit of a run. A study that is not complete then goes on in the next run, at most 2 runs, and nothing is read between the runs. No round is added because a result looks close.

    Rehearsal. All four units and every arm run 2 rounds at one fiftieth of the size first. It checks the setup and is never read as a result. A unit whose rehearsal fails a check is not run.

    Reruns and changes. A read verdict is final, including CLOSE. After WEAK or INVALID, one unchanged rerun replaces only the figures that reported nothing. A change of arms, sizes, thresholds, or pins after a timed run is a new study with a new comment first.

    Limits.

    • One laptop, relative figures only.
    • One row shape per wheel, one thread, one UNIQUE index created before the load, default engine settings, 10,000 rows per chunk for the statement arms.
    • insert_many and graph_batch run with each wheel's own defaults, which differ between the wheels, so the two wheels are never compared with each other.
    • The graph wrapper arm resolves keys in Python through the returned RIDs, so it does no lookups; that structural advantage is part of what is measured.
    • Not measured: vector columns (the wrapper has a float32 path that no statement can use), other row counts, other index setups, concurrent writers.
  6. tae898 commented on Dec 5, 2026

    @tae898
    CollaboratorAuthor

    The first full run of this study could not be read: the strict rule dropped almost every pair because the other compare lane was busy (details in tae898/humem-ops#767). Before any rerun, this is the rule that will apply. It changes only how load from an accepted sibling compare lane is treated.

    Amended OTHER-BENCH rule for the paired scorer (humem-ops#767, decided 2026-12-05)

    The strict rule of 2026-10-26 dropped a pair when benchmark-class load ran on cores outside the arm's own cores. One case is amended: load that is pinned inside the cores of another accepted compare lane of the same host is no longer a reason to drop a pair. Nothing else about the rule changes.

    1. What counts as a sibling lane. A lane of class compare in the host profile (worker.toml, [lanes]) while accepted_compare_lanes is 2 or more. On the laptop that is compare1 (cores 6,7) and compare2 (cores 10,11). A process counts as inside a lane when its whole Cpus_allowed_list lies inside that lane's cores. A process that is not pinned inside a lane (an agent, a build, a solo or bulk job, a desktop program, an unpinned process) is not a sibling.
    2. What the sampler records. Per 5 s sample, other_bench_sibling_cores (CPU of sibling-lane load, in cores), other_bench_sibling_lanes (lane to cores) and other_bench_sibling_roots. The load also stays inside other_bench_cores, so a scorer without this rule reads the sample as before. A sample without these fields is read exactly as under the strict rule.
    3. What the scorer drops. A pair is dropped when other_bench_cores - other_bench_sibling_cores is above 0.5 cores in the window of either arm (window and threshold unchanged). The drop names only the roots that are not on a sibling lane. Load on any other cores still drops the pair, also when sibling load is present at the same time.
    4. What the scorer prints. SIBLING-LANE: k round(s) overlapped an accepted compare lane, kept [rounds] (a round counts when any sample in its window has sibling load). No pair is dropped for it and the verdict is not forced weak. COLLISION, NOISY, THROTTLE, TEMP and their output are unchanged.
    5. What decides whether the neighbour mattered. The A/A control (Z against A) of each unit, scored with the same rules, so the same neighbour is present in it. A unit whose A/A control is outside its band stays INVALID, as before, and is not read. The per-row noise stays in the output.
    6. Kits. A kit's ab.py stays frozen. A kit is changed only by regenerating its ab.py from the new source and refreshing its SHA256SUMS, which makes it a new kit. Results already produced with the strict rule are not rescored.
  7. tae898 commented on Dec 5, 2026

    @tae898
    CollaboratorAuthor

    I am writing the rules of this measurement down before its first run.

    Question. Do insert_many and graph_batch beat the plain SQL and Cypher statements a user could write instead, on arcadedb (native) and on arcadedb-jvm at 26.12.1.dev2? By how much? The answer decides whether the Python docs keep recommending the two wrappers as the bulk-load path, and whether they stay under the bindings' rule "SQL and Cypher first, wrap only where it pays".

    Arm documents graph
    A (reference) insert_many, the wheel's default commit_every graph_batch with create_vertices and new_edges on the returned RIDs
    B INSERT INTO T CONTENT :rows, 10,000 rows as one list parameter per transaction CREATE VERTEX V CONTENT :rows in chunks of 10,000, then one CREATE EDGE E FROM (SELECT ...) TO (SELECT ...) per edge
    C one INSERT INTO T SET ... per row, a transaction per 10,000 rows openCypher UNWIND ... CREATE for vertices, UNWIND ... MATCH ... CREATE for edges, 10,000 per statement and transaction
    D openCypher UNWIND $rows ... CREATE, 10,000 per statement and transaction (T is a vertex type here, so its bytes are not comparable) none
    E INSERT INTO T CONTENT [...] with the chunk as a JSON text literal none
    Z A again, the A/A control A again

    Each run is one fresh process. Schema and the UNIQUE index on id are created before the clock starts. The documents have 7 properties (integers, a double, strings, a boolean, a list of 3 strings), 1,000,000 of them. The graph has 200,000 vertices and 500,000 edges chosen by key with a fixed seed (self loops and repeats allowed). The gating figure is total_s, the whole timed load including the row generation, which is the same for every arm. Each wheel is scored on its own and the two wheels are never compared with each other.

    Verdict. Per wheel, shape and statement arm S, the ratio S / A of total_s: the median of the per-round ratios with a 95% bootstrap interval (10,000 resamples, seed 1). Above 1.00 the statement form is slower than the wrapper.

    arm verdict condition
    EARNS the lower end of the interval is above 1.05 (the wrapper is faster)
    REDUNDANT the upper end is below 1.03 (the statement is as fast or faster)
    CLOSE neither

    The verdict of a wheel and shape is REDUNDANT if any statement arm is REDUNDANT, EARNS if every statement arm EARNS, and CLOSE otherwise. All arm rows stay in the results, so a reader can drop arm E (my addition, a plain statement) and see whether a verdict changes. The speedup I would quote in the docs is 1 / ratio with the interval inverted: the wrapper over the per-row loop for documents (arm C), and over the per-edge SQL form for the graph (arm B). I will recommend a statement form over the wrapper for a wheel and shape only if the lower end of every statement arm I name is at most 1.03, and I will not call it a speed claim. A result whose interval lies in [0.97, 1.03] is called equal, and nothing else is. Peak memory, file size, lookup time and generation time are reported and decide nothing.

    Pins, validity, throttle rule, repetitions, and limits

    Pins.

    What Pin
    native wheel, linux x86_64 sha256 2913537be9f3cef65a43ea8ff29d0f998dd115e8fb870b1d9c323b989ac2d6d9
    JVM wheel, linux x86_64 sha256 5fbbdf30d2b8e0ee69aefa9c0881bd62a2858c9904588fd44d58eb9f2d498dd8
    bindings commit 4b8a5b18ea7b54deac8fc7874248f691973133aa
    engine 26.12.1.dev2, one engine version and build commit in every run
    Python 3.12, numpy 2.5.4, JPype1 1.7.1 (JVM arm only)
    heap the same explicit maximum of 3 GB on both wheels in every run
    host my laptop (Core Ultra X9 388H, Linux), two pinned E cores, turbo on, powersave governor, editor, browser, and agent sessions held on other cores. The figures are relative only
    kit the checksum file of the scripts has sha256 dda1d67225e3bf422b268a0cf1593595580f01b9cd602306048df8d8406be8c0

    The final 26.12.1 wheels are not on PyPI yet, so this runs on the newest ones, 26.12.1.dev2. I will repeat it on the final wheels as a new run.

    Validity, checked before any verdict. A unit (one wheel and one shape) is INVALID when a run did not use the wheel of its arm, a wheel version, commit, engine version, or engine build commit differs from the pins or between runs, the runs did not all get the same maximum heap, or the throttle counters cannot be read. A run counts only when the backend is the wheel's, the stored counts are right (graph: 200,000 vertices and 500,000 edges), 2,000 random stored records plus ids 0, 7, and the last equal the generator in every property, for 200 of them the out('E') and in('E') neighbour lists equal the edge list (graph), EXPLAIN of id = 7 uses the index, and a duplicate id is refused. A figure is INVALID when the A/A control (Z / A of total_s) has fewer than 10 clean pairs or an interval that excludes 1.00, or the A/A median of peak memory is outside [0.95, 1.05]. It is WEAK when an arm has fewer than 10 clean pairs or an interval wider than 0.10 times its median. INVALID and WEAK figures report no result. A run that fails is left out and listed; a unit stops after a failed run in its first round, or after 3 failed runs in a row.

    Throttle and interference rule. A run starts when the package is at most 70 C (after the first run of a round also at most 2 C above that run's start), after at most 180 s of waiting. A pair is dropped when the two runs' throttled share of the timed window differs by more than 1 percentage point, when their start temperatures differ by more than 5 C, or when my interference sampler marked either run (more than half a core of other work on a group of cores, other benchmark work, a camera, or a suspend).

    Repetitions and stopping. In a round, each unit runs its arms back to back, one process each, the order rotated and reversed from round to round. Rounds 0 to 12 (round 0 is dropped), then 2 more for a unit that has a WEAK or INVALID gating figure, at most up to round 24. No round starts that is not expected to end 15 minutes before the 11-hour time limit of a run. A study that is not complete then goes on in the next run, at most 2 runs, and nothing is read between the runs. No round is added because a result looks close.

    Rehearsal. All four units and every arm run 2 rounds at one fiftieth of the size first. It checks the setup and is never read as a result. A unit whose rehearsal fails a check is not run.

    Reruns and changes. A read verdict is final, including CLOSE. After WEAK or INVALID, one unchanged rerun replaces only the figures that reported nothing. A change of arms, sizes, thresholds, or pins after a timed run is a new study with a new comment first.

    Amended interference rule (humem-ops#767, 2026-12-05). The first full run of this study (kit a1195eee68a6160c7f78beb9ff50b08e7caaee90e070a1e2d3e5653b34a0cd26) could not be read: the strict rule above dropped a pair for any other benchmark load, so the load of the other compare lane on the same laptop (cores 6 and 7 beside my cores 10 and 11) removed almost every pair. The rerun uses the same arms, sizes, thresholds, and pins. Only one case of the interference rule changes: load pinned wholly inside the cores of another accepted compare lane no longer drops a pair, and the scorer prints which rounds had it. Load on any other cores still drops the pair. The A/A control of each unit runs beside the same neighbour and still decides whether the figure is read. The kit with the new scorer has the checksum dda1d67225e3bf422b268a0cf1593595580f01b9cd602306048df8d8406be8c0. The rehearsal of the old kit is void, so the rehearsal is run again on the new kit, and the first run's outputs are kept and not rescored.

    Limits.

    • One laptop, relative figures only.
    • One row shape per wheel, one thread, one UNIQUE index created before the load, default engine settings, 10,000 rows per chunk for the statement arms.
    • insert_many and graph_batch run with each wheel's own defaults, which differ between the wheels, so the two wheels are never compared with each other.
    • The graph wrapper arm resolves keys in Python through the returned RIDs, so it does no lookups; that structural advantage is part of what is measured.
    • Not measured: vector columns (the wrapper has a float32 path that no statement can use), other row counts, other index setups, concurrent writers.
  8. tae898 commented on Dec 6, 2026

    @tae898
    CollaboratorAuthor

    A limit of this study that I found while checking its wheel pins. The 26.12.1.dev2 wheels were uploaded to PyPI on 2026-11-07 from bindings commit 4b8a5b1, and main is 225 commits ahead of it (checked on 2026-12-06). So they lack the glue changes merged after that date, for example #320 (the exact float of to_json_list on the JVM wheel) and #391 and #392 (typed columns on the JVM wheel). The figures of this study are for that code, and the repeat on the final 26.12.1 wheels stays necessary.

  9. tae898 commented on Dec 6, 2026

    @tae898
    CollaboratorAuthor

    What this means for this study (follow-up to my limit comment above): This one matters most here: insert_many and graph_batch on the JVM wheel are exactly the calls #392 and #391 changed, so the JVM figures of the wrappers are for the JSON text route and not for the route 26.12.1 will have.

    State: the first full run could not be read (see my comment on the amended rule above), so there is no readable result yet. smoke2 and then main-r2-n1 are queued on compare2, behind the running vector-wheels study. Next: once the final 26.12.1 wheels are on PyPI (there is only 26.12.1.dev2 so far), I will re-pin the same kit with its own fill.py pypi 26.12.1 and rerun what matters. The dev2 figures stay here as the pre-release baseline, and the result on the final wheels comes as its own comment.

    (Edited: removed the paragraph that repeated my limit comment above.)

  10. added
    jvm
    native
    on Dec 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementjvmnativeperformancepython

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions