Skip to content

Align empty sub query and empty append handling across stores - #920

Merged
DavidBadura merged 1 commit into
4.0.xfrom
fix-empty-sub-query-and-append
Oct 3, 2026
Merged

DavidBadura merged 1 commit into
4.0.xfrom
fix-empty-sub-query-and-append

Conversation

@DavidBadura

Copy link
Copy Markdown
Member

The TaggableDoctrineDbalStore silently skipped empty sub queries, while the InMemoryStore and SubQuery::match() treat them as "match all". So new Query(new SubQuery(), new SubQuery(['a'])) returned only the a events on the database but every event in memory, even though the docs say both stores behave the same. The dbal store now returns all events in that case, and an empty onlyLastEvent sub query resolves to the last event of the store. This also applies to append conditions, which go through the same query building.

append([]) on the dbal store produced invalid sql (FROM () AS data). Both stores now treat an empty append as a no-op, like StoreEventAppender already does. Note that this also skips the append condition check in the InMemoryStore, which previously could throw AppendConditionNotMet for an empty batch.

The dbal store skipped empty sub queries, while the in memory store and
SubQuery::match() treat them as "match all". A query like
`new Query(new SubQuery(), new SubQuery(['a']))` returned only the events
tagged `a` on the database and every event in memory. The dbal store now
returns all events in that case and resolves an empty only-last-event sub
query to the last event of the store, the same as the in memory store.

Appending no messages produced invalid sql on the dbal store. Both stores now
treat it as a no-op, like StoreEventAppender already does.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Hello 👋

here is the most recent benchmark result:

SplitStreamBench
================

+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                         | time (kde mode)                                     | memory                                     |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                 | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000Events () | 2.696ms (±0.00%)   | 3.012ms (±0.00%)   | -10.51%   | 35.774mb        | 36.295mb   | -1.43%      |
| benchSave10000Events () | 476.492ms (±0.00%) | 486.062ms (±0.00%) | -1.97%    | 35.909mb        | 35.909mb   | 0.00%       |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SimpleSetupTaggableStoreBench
=============================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.083ms (±0.00%)   | 1.131ms (±0.00%)   | -4.27%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchLoad10000Events ()                | 73.124ms (±0.00%)  | 74.607ms (±0.00%)  | -1.99%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchSave1Event ()                     | 1.678ms (±0.00%)   | 1.638ms (±0.00%)   | +2.45%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchSave10000Events ()                | 315.662ms (±0.00%) | 312.328ms (±0.00%) | +1.07%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchSave10000Aggregates ()            | 10.343s (±0.00%)   | 10.193s (±0.00%)   | +1.48%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 7.146s (±0.00%)    | 7.166s (±0.00%)    | -0.28%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchAppend1Event ()                   | 1.694ms (±0.00%)   | 1.670ms (±0.00%)   | +1.44%    | 36.312mb        | 36.312mb   | 0.00%       |
| benchAppend100Events ()                | 8.538ms (±0.00%)   | 8.516ms (±0.00%)   | +0.26%    | 36.312mb        | 36.312mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBench
=======================

+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                               | memory                                     |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>  | Tag: base       | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 3.485s (±0.00%) | 3.505s (±0.00%) | -0.58%    | 48.301mb        | 48.301mb   | 0.00%       |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+

NoopSubscriptionEngineBench
===========================

+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                                     | memory                                     |
+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 110.413ms (±0.00%) | 110.035ms (±0.00%) | +0.34%    | 48.301mb        | 48.301mb   | 0.00%       |
+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SimpleSetupStreamStoreBench
===========================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.302ms (±0.00%)   | 1.299ms (±0.00%)   | +0.20%    | 35.146mb        | 35.146mb   | 0.00%       |
| benchLoad10000Events ()                | 73.073ms (±0.00%)  | 74.412ms (±0.00%)  | -1.80%    | 35.146mb        | 35.146mb   | 0.00%       |
| benchSave1Event ()                     | 1.660ms (±0.00%)   | 1.670ms (±0.00%)   | -0.59%    | 35.146mb        | 35.146mb   | 0.00%       |
| benchSave10000Events ()                | 290.889ms (±0.00%) | 292.230ms (±0.00%) | -0.46%    | 35.146mb        | 35.146mb   | 0.00%       |
| benchSave10000Aggregates ()            | 10.330s (±0.00%)   | 10.189s (±0.00%)   | +1.38%    | 35.146mb        | 35.146mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 7.069s (±0.00%)    | 7.145s (±0.00%)    | -1.06%    | 35.147mb        | 35.147mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBatchBench
============================

+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                                     | memory                                     |
+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 115.929ms (±0.00%) | 115.832ms (±0.00%) | +0.08%    | 35.726mb        | 35.726mb   | 0.00%       |
+---------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

PersonalDataBench
=================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 866.600μs (±0.00%) | 864.100μs (±0.00%) | +0.29%    | 37.008mb        | 37.008mb   | 0.00%       |
| benchLoad10000Events ()                | 223.263ms (±0.00%) | 225.439ms (±0.00%) | -0.97%    | 37.008mb        | 37.008mb   | 0.00%       |
| benchSave1Event ()                     | 2.335ms (±0.00%)   | 2.597ms (±0.00%)   | -10.11%   | 37.008mb        | 37.008mb   | 0.00%       |
| benchSave10000Events ()                | 480.839ms (±0.00%) | 484.184ms (±0.00%) | -0.69%    | 37.063mb        | 37.063mb   | 0.00%       |
| benchSave10000Aggregates ()            | 15.650s (±0.00%)   | 15.725s (±0.00%)   | -0.48%    | 37.008mb        | 37.008mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 12.458s (±0.00%)   | 12.399s (±0.00%)   | +0.48%    | 37.008mb        | 37.008mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SnapshotsBench
==============

+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                   | memory                                     |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchLoad10000EventsMissingSnapshot () | 74.343ms (±0.00%) | 72.348ms (±0.00%) | +2.76%    | 35.151mb        | 35.151mb   | 0.00%       |
| benchLoad10000Events ()                | 1.106ms (±0.00%)  | 1.087ms (±0.00%)  | +1.77%    | 35.151mb        | 35.151mb   | 0.00%       |
+----------------------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

CommandToQueryBench
===================

+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
|                | time (kde mode)                                 | memory                                     |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
| subject        | Tag: <current>   | Tag: base        | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+
| benchCreate () | 3.874ms (±0.00%) | 4.004ms (±0.00%) | -3.25%    | 5.057mb         | 5.057mb    | 0.00%       |
| benchUpdate () | 5.164ms (±0.00%) | 5.486ms (±0.00%) | -5.87%    | 5.067mb         | 5.067mb    | 0.00%       |
| benchBoth ()   | 8.706ms (±0.00%) | 9.039ms (±0.00%) | -3.69%    | 5.389mb         | 5.389mb    | 0.00%       |
+----------------+------------------+------------------+-----------+-----------------+------------+-------------+

This comment gets update everytime a new commit comes in!

@DavidBadura DavidBadura added this to the 4.0.0 milestone Oct 3, 2026
@DavidBadura DavidBadura added the bug Something isn't working label Oct 3, 2026
@DavidBadura
DavidBadura merged commit 208c8d8 into 4.0.x Oct 3, 2026
38 of 39 checks passed
@DavidBadura
DavidBadura deleted the fix-empty-sub-query-and-append branch October 3, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants