Path: redb/redb.Export/Providers/IParallelImportProvider.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Export/Providers/IParallelImportProvider.cs ---- namespace redb.Export.Providers; /// /// What a provider needs to offer for an import that writes over several connections at once. /// /// The ordinary import is one connection and one transaction: it either lands whole or leaves the /// database as it was. The parallel import trades that guarantee for speed. Rows go in over N /// connections that commit on their own, and the secondary indexes of the large tables are dropped /// before the load and built again after it, because maintaining them row by row is what makes a /// large import slow. A parallel import that stops half-way leaves a partly loaded database; the /// definitions of the dropped indexes are kept in the database itself so that the next run, or the /// operator, can put them back. /// public interface IParallelImportProvider { /// /// Opens one more connection to the same database, set up for loading: no transaction, and /// foreign key checks off for the whole session, since parents and children arrive in any order. /// Task OpenWorkerAsync(CancellationToken ct = default); /// /// Drops the secondary indexes of the large tables and returns the statements that create them /// again. The statements are stored in the database first, so a run that dies after this call /// loses no index definition; a later call returns the stored ones together with whatever it /// drops itself. Indexes that back a constraint (primary keys, UNIQUE) are left in place. /// Task> DropLoadIndexesAsync(CancellationToken ct = default); /// Creates one index from the statement returned. Task CreateIndexAsync(DroppedIndex index, CancellationToken ct = default); /// Removes the stored definitions once every index is back. Task ForgetDroppedIndexesAsync(CancellationToken ct = default); /// /// Switches off foreign key checks and triggers for the load where that is a setting of the /// database and not of a session. A provider whose workers do it for themselves in /// has nothing to do here. /// Task RelaxConstraintsForLoadAsync(CancellationToken ct = default); /// /// Undoes once the rows and the indexes are in, and /// has the database check the loaded rows against the foreign keys again. /// Task RestoreConstraintsAfterLoadAsync(CancellationToken ct = default); /// /// False when two index builds on the same table must not run side by side; the indexes of a /// table are then built one after another, and only different tables in parallel. /// bool BuildsIndexesOfOneTableConcurrently { get; } } /// An index dropped for the duration of a load, with the statement that creates it again. /// Index name. /// Table it belongs to. /// Complete CREATE INDEX statement. public sealed record DroppedIndex(string Name, string Table, string Definition);