Collapse All Expand All Code: All Code: Multiple Code: C# Code: Visual Basic Code: Visual C++

C#
Visual Basic
Visual C++

Berkeley DB .NET API Documentation
HashDatabase..::.Compact Method (CompactConfig, Transaction)
HashDatabase Class See Also Send Feedback

Compact the database, and optionally return unused database pages to the underlying filesystem.

Namespace: BerkeleyDB
Assembly: libdb_dotnet60 (in libdb_dotnet60.dll) Version: 6.0.20.0

# Syntax

C#
    public CompactData Compact(
    	CompactConfig cdata,
    	Transaction txn
    )

Visual Basic (Declaration)
    Public Function Compact ( _
    	cdata As CompactConfig, _
    	txn As Transaction _
    ) As CompactData

Visual C++
    public:
    CompactData^ Compact(
    	CompactConfig^ cdata,
    	Transaction^ txn
    )

#### Parameters

cdata
  Type: BerkeleyDB..::.CompactConfig
  Compact configuration parameters

txn
  Type: BerkeleyDB..::.Transaction
  If the operation is part of an application-specified transaction, txn is a Transaction object returned from BeginTransaction()()(); if the operation is part of a Berkeley DB Concurrent Data Store group, txn is a handle returned from BeginCDSGroup()()(); otherwise null.

#### Return Value

Compact operation statistics, where End holds the integer value representing which bucket the compaction stopped in.

# Remarks

If txn is non-null, then the operation is performed using that transaction. In this event, large sections of the tree may be locked during the course of the transaction.

If txn is null, but the operation occurs in a transactional database, the operation will be implicitly transaction protected using multiple transactions. These transactions will be periodically committed to avoid locking large sections of the tree. Any deadlocks encountered cause the compaction operation to be retried from the point of the last transaction commit.

# See Also

HashDatabase Class
Compact Overload
BerkeleyDB Namespace