Select to view content in your preferred language

Geopackage table, update size of table?

193
1
10-25-2024 02:10 PM
Labels (2)
SP2501
by
Emerging Contributor

When working with Geopackage featuretables, I am noticing that the file sizes are not updating after I remove features. The changes are being updated, but the size of the file remains the same.

Example (Removes everything for testing)

try
{
// Define query to select all features
QueryParameters queryParams = new QueryParameters
{
WhereClause = "1=1" // Select all features
};

// Query all features in the table
FeatureQueryResult features = featureTable.QueryFeaturesAsync(queryParams).Result;


// Collect all ObjectIds to delete features in bulk
List<Feature> objectIds = new List<Feature>();
foreach (Feature feature in features)
{
objectIds.Add(feature);
}

// Delete features in bulk
featureTable.DeleteFeaturesAsync(objectIds).Wait();


}
catch (Exception ex)
{
Console.WriteLine($"Error clearing features: {ex.Message}");
}


// Close the GeoPackage
newGeoPackage.Close();

 

Thanks for looking!

0 Kudos
1 Reply
dotMorten_esri
Esri Notable Contributor

This is pretty typical database behavior. In this case the underlying database is a sqlite database, and it would need a vacuum operation. See: https://sqlite.org/lang_vacuum.html

The SDK doesn't provide vacuum out of the box, but any sqlite API or tool should be able to do this for you.

If the geodatabase is sync enabled, it still needs to track deleted features, so this can be synchronized with the server later.

0 Kudos