-
-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom indexes on events tables #2556
base: master
Are you sure you want to change the base?
Add support for custom indexes on events tables #2556
Conversation
Personally, I wouldn't like to provide the custom indexes enabled out of the box; I'd prefer to offer explicit toggles for the specific usage scenarios that we think are valid. Cases like stream type or archived are good, but custom indexes can be Pandora's box for cases where people will try to index their event data and think that we enabled it, as we are generally okay with that. Allowing such extended customisation creates many potential permutations on the support side. Having that said as: "you can use your custom SQL to index events table outside of Marten's auto-script", in that case, sounds fair enough to me. So TLDR, I'm not against expanding our indexing capabilities, but I'd like to learn more about the exact usage scenarios and then enable them explicitly instead of the freehand way. @jeremydmiller, thoughts? |
@elexisvenator I'm going to agree with @oskardudycz. Syntax wise though, if you want to fine tune the indexes, I'd rather we get closer to the document type syntax like: /// <summary>
/// Creates a computed index on this data member within the JSON data storage
/// </summary>
/// <param name="expression"></param>
/// <param name="configure"></param>
/// <returns></returns>
public DocumentMappingExpression<T> Index(Expression<Func<T, object>> expression,
Action<ComputedIndex>? configure = null)
{
_builder.Alter = m => m.Index(expression, configure);
return this;
} But in this case we'd use What indexes would you place on the streams table? That I think I'd rather have a bit more constrained. I'll volunteer to get this across the finish line if you want since you've already done a lot here. The tests would still be useful. |
The specific use cases that I would like to support are:
From a marten ecosystem perspective, i feel that the optional indexes you can add to documents should also be applicable to the events table, such as to the metadata and archived/soft deleted fields. Happy to go into detail here or separately about what sort of maintenance/restreaming queries are going on in our system and why. |
6f60ad6
to
0a7a351
Compare
Adds 2 new methods to
IEventStoreOptions
:AddIndexToStreamsTable(IndexDefinition index)
AddIndexToEventsTable(IndexDefinition index)
These do exactly what they say on the tin - the passed in index definition is added to the respective table. Adding custom indexes can be useful for doing maintenance queries, such as scanning for archived streams, looking for events by type, etc.
A test has been added to prove index generation works. Documentation with examples has also been added.