—> Compact your database <—

I discovered the necessity of the compact command (arcpy.Compact_management) while creating a geodatabase. In this particular process there is a lot of selecting, saving as new feature classes, unioning, and finally dissolving and deleting unused temp feature classes. By the end I had what I wanted and all the unnecessary data had been removed, however my relatively small geodatabase (4 feature data sets and less than a hundred features total) was s l o w. As in click to browse in ArcCatalog and go get some tea while you wait slow. I immediately thought that it was something related to the numerous gyrations the data had taken to get to the final state. But how to repair? A bit of searching led me to compact and compress. Compress was not the right way to go. While it may have improved things, it made the entire geodatabase read-only. Not what I was after. Compact, on the other hand, seems specifically designed to alleviate this problem. The help for this command states “If data entry, deletion, or general editing is frequently performed on a database, the database should be regularly compacted to ensure optimal performance”. I imagine it to be like an untidy deck of cards that you are picking up and tapping until all the edges line up. After trying it out I saw marked improvement! The geodatabase responded instantly to browsing and adding into a map. So I’ve included that as the last step in my script. A very simple command I may find myself using more often.





 print arcpy.GetMessages(2)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s