diff --git a/docs/events/optimizing.md b/docs/events/optimizing.md
index f532e8da06..aa292d2534 100644
--- a/docs/events/optimizing.md
+++ b/docs/events/optimizing.md
@@ -40,7 +40,7 @@ builder.Services.AddMarten(opts =>
opts.Events.UseOptimizedProjectionRebuilds = true;
});
```
-snippet source | anchor
+snippet source | anchor
The archived stream option is further described in the section on [Hot/Cold Storage Partitioning](/events/archiving.html#hot-cold-storage-partitioning).
@@ -48,9 +48,11 @@ The archived stream option is further described in the section on [Hot/Cold Stor
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`)
diff --git a/docs/events/projections/rebuilding.md b/docs/events/projections/rebuilding.md
index 4451505fca..1d4ecce9b2 100644
--- a/docs/events/projections/rebuilding.md
+++ b/docs/events/projections/rebuilding.md
@@ -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:
-
-
+
+
```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 ++]
});
```
-snippet source | anchor
+snippet source | anchor
In this mode, Marten will rebuild single stream projection documents stream by stream in the reverse order that the
diff --git a/src/EventSourcingTests/Examples/Optimizations.cs b/src/EventSourcingTests/Examples/Optimizations.cs
index 3d0cd5df59..48b9ebc30b 100644
--- a/src/EventSourcingTests/Examples/Optimizations.cs
+++ b/src/EventSourcingTests/Examples/Optimizations.cs
@@ -50,7 +50,6 @@ 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
@@ -58,6 +57,20 @@ public static async Task use_optimizations()
});
#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
}
}