Skip to content

Commit

Permalink
Minor doc tweak to highlight new flag
Browse files Browse the repository at this point in the history
* Minor doc tweak to highlight new flag

* Further tweaks

---------

Co-authored-by: JT <[email protected]>
  • Loading branch information
Hawxy and Hawxy authored Oct 10, 2024
1 parent 2cbadc4 commit 31bc7bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
6 changes: 4 additions & 2 deletions docs/events/optimizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ builder.Services.AddMarten(opts =>
opts.Events.UseOptimizedProjectionRebuilds = true;
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Examples/Optimizations.cs#L31-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_turn_on_optimizations_for_event_sourcing' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Examples/Optimizations.cs#L31-L59' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_turn_on_optimizations_for_event_sourcing' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The archived stream option is further described in the section on [Hot/Cold Storage Partitioning](/events/archiving.html#hot-cold-storage-partitioning).

See the ["Rich" vs "Quick" Appends](/events/appending.html#rich-vs-quick-appends) section for more information about the
applicability and drawbacks of the "Quick" event appending.

Lastly, see [Optimizing FetchForWriting with Inline Aggregates](/scenarios/command_handler_workflow.html#optimizing-fetchforwriting-with-inline-aggregates) for more information
See [Optimizing FetchForWriting with Inline Aggregates](/scenarios/command_handler_workflow.html#optimizing-fetchforwriting-with-inline-aggregates) for more information
about the `UseIdentityMapForInlineAggregates` option.

Lastly, check out [Optimized Projection Rebuilds](/events/projections/rebuilding.html#optimized-projection-rebuilds) for information about `UseOptimizedProjectionRebuilds`

## Caching for Asynchronous Projections

You may be able to wring out more throughput for aggregated projections (`SingleStreamProjection`, `MultiStreamProjection`, `CustomProjection`)
Expand Down
30 changes: 7 additions & 23 deletions docs/events/projections/rebuilding.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,20 @@ to upgrade their database without the explicit opt in configuration.

Marten can optimize the projection rebuilds of single stream projections by opting into this flag in your configuration:

<!-- snippet: sample_turn_on_optimizations_for_event_sourcing -->
<a id='snippet-sample_turn_on_optimizations_for_event_sourcing'></a>
<!-- snippet: sample_turn_on_optimizations_for_rebuilding -->
<a id='snippet-sample_turn_on_optimizations_for_rebuilding'></a>
```cs
var builder = Host.CreateApplicationBuilder();
builder.Services.AddMarten(opts =>
{
opts.Connection("some connection string");

// Turn on the PostgreSQL table partitioning for
// hot/cold storage on archived events
opts.Events.UseArchivedStreamPartitioning = true;

// Use the *much* faster workflow for appending events
// at the cost of *some* loss of metadata usage for
// inline projections
opts.Events.AppendMode = EventAppendMode.Quick;

// Little more involved, but this can reduce the number
// of database queries necessary to process inline projections
// during command handling with some significant
// caveats
opts.Events.UseIdentityMapForInlineAggregates = true;

// Opts into a mode where Marten is able to rebuild single
// stream projections faster by building one stream at a time
// Does require new table migrations for Marten 7 users though
opts.Events.UseOptimizedProjectionRebuilds = true;
// Opts into a mode where Marten is able to rebuild single // [!code ++]
// stream projections faster by building one stream at a time // [!code ++]
// Does require new table migrations for Marten 7 users though // [!code ++]
opts.Events.UseOptimizedProjectionRebuilds = true; // [!code ++]
});
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Examples/Optimizations.cs#L31-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_turn_on_optimizations_for_event_sourcing' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Examples/Optimizations.cs#L61-L73' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_turn_on_optimizations_for_rebuilding' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

In this mode, Marten will rebuild single stream projection documents stream by stream in the reverse order that the
Expand Down
15 changes: 14 additions & 1 deletion src/EventSourcingTests/Examples/Optimizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,27 @@ public static async Task use_optimizations()
// caveats
opts.Events.UseIdentityMapForInlineAggregates = true;
// Opts into a mode where Marten is able to rebuild single
// stream projections faster by building one stream at a time
// Does require new table migrations for Marten 7 users though
opts.Events.UseOptimizedProjectionRebuilds = true;
});

#endregion

#region sample_turn_on_optimizations_for_rebuilding

builder.Services.AddMarten(opts =>
{
opts.Connection("some connection string");
// Opts into a mode where Marten is able to rebuild single // [!code ++]
// stream projections faster by building one stream at a time // [!code ++]
// Does require new table migrations for Marten 7 users though // [!code ++]
opts.Events.UseOptimizedProjectionRebuilds = true; // [!code ++]
});

#endregion
}

}

0 comments on commit 31bc7bd

Please sign in to comment.