The performance regression in create_documents_batch_small compared to create_document_small is due to direct writes to storage during entity creations, property updates, and child additions, completely bypassing the EmbeddedTransaction's _operations queue. Every add_child directly updates and re-serializes the entire children array of a container synchronously, causing quadratic time complexity for batch inserts in a single container.
Add an internal accessor for current_transaction so that entities can queue operations:
internal EmbeddedTransaction? current_transaction { get { return _current_transaction; } }
apply_operation for OperationType.SET_PROPERTY to properly apply property updates, OR refactor property updates to queue a full property save (OperationType.SAVE_PROPERTIES).Document modifies _properties in-memory and multiple set_entity_property calls would each record a property, it is optimal to let EmbeddedTransaction merge property updates.commit(), merge operations or ensure that save_properties is called only once per document.OperationType.CREATE_ENTITY to handle them. (Currently CREATE_ENTITY metadata storage might require expressions for categories).create_container, create_document, create_category, create_catalogue, create_index, and delete_child to check if _engine is in a transaction.record_create_entity and record_add_child instead of writing to storage directly.save_properties to check for an active transaction.delete() to use record_delete_entity and record_remove_child when inside a transaction.implexus-perf benchmark specifically for Document to verify that create_documents_batch_small decreases from ~58ms down to effectively ~1-2ms per batch (since the DB write is deferred and batched).