CacheMetadata
This property determines whether or not to cache the table metadata to a file store.
Data Type
bool
Default Value
false
Remarks
As you execute queries with this property set, table metadata in the DB2 catalog is cached to the file store specified by CacheLocation if set or the user's home directory otherwise. A table's metadata is retrieved only once, when the table is queried for the first time.
When to Use CacheMetadata
The provider automatically persists metadata in memory for up to an hour when you first discover the metadata for a table or view and therefore, CacheMetadata is generally not required. CacheMetadata becomes useful when metadata operations are expensive, such as when you are working with large amounts of metadata or when you have many short-lived connections.
When Not to Use CacheMetadata
- When you are working with volatile metadata: The first time you query a table, the provider caches its metadata. This cache is not dynamically updated to reflect updates to the table schema, so you must delete and rebuild the metadata cache to pick up new, changed, or deleted columns. Therefore, it is best to rely on the in-memory caching for cases where metadata changes often.
- When you are caching to a database: CacheMetadata can only be used with CacheLocation. If you are caching to another database with the CacheProvider and CacheConnection properties, use AutoCache to cache implicitly.