Update index instead of deleting and adding
Hi,
I was wondering if there is any way to update an existing MapIndex instead of deleting it and adding it. I'm currently facing the issue that the index table has an Integer Id with a limited max value.
I'm keeping track of certain crypto coins and storing them in the database. Using a websocket I'm receiving the latest prices continually of a specific coin which I will then save to the database. Currently my ID of the index table increments rather quickly, as I'm updating the Document record frequently.
What I fear is that I will reach the limitations of the int ID quickly this way.
TLDR: Is there any way to let an IndexProvider update an existing MapIndex record, instead of deleting + adding.
namespace Core.Indexes
{
public class CandleIndex : MapIndex
{
public string Symbol { get; set; }
public TimeInterval Interval { get; set; }
public DateTime StartDate { get; set; }
}
public class CandleIndexProvider : IndexProvider<Candle>
{
public override void Describe(DescribeContext<Candle> context)
{
context.For<CandleIndex>()
.Map(candle =>
{
return new CandleIndex
{
Symbol = candle.Symbol,
Interval = candle.Interval,
StartDate = candle.StartDate
};
});
}
}
}
The ID distance between yesterday's price candle index and today:

EDIT Using SQL Server
I would suggest if it becomes a problem to reset the identity value
For sql server (you don't specify your database) https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkident-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15
I don't think that solves the problem Dean as I'm not deleting my records and therefore I think this section in the remarks is relevant:
"If the table is not empty, setting the identity value to a number less than the maximum value in the identity column can result in one of the following conditions:
-If a PRIMARY KEY or UNIQUE constraint exists on the identity column, error message 2627 will be generated on later insert operations into the table because the generated identity value will conflict with existing values.
-If a PRIMARY KEY or UNIQUE constraint does not exist, later insert operations will result in duplicate identity values."