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!
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.