Enterprise Applications with the Geodatabase
This looks to be code heavy and for people who know geodb
each connection creates an ArcSDE and DB<S process
ArcGIS maintains a workspace/connection pool to save resources.
Using application server – descreases client load but increases server load
Direct Connection – no service so you decrease server load by increasing load on client
You can connect using a propertySet or a connection file. The benefit to a connection file is that you don’t have to hard code your connection parameters into your source.
Personal ArcSDE geodatabases – code example showing how to create them on the fly and attach and detach.
Schema caching – cached snapshot of the GDB schema tables
Requires that you have a static schema model but the benefit is improved performance by reducing roundtrips
IWorkspaceFactorySchemaCache is the interface where it all happens.
Use it when you have large and static data models or if the application opens and uses many classes (such as feature classes). These should opened at the start of the application and reference maintained throughout the lifetime of the application.
Enable schame cache before tables are opened – you can also enable at the factory level. After this all opens will be optomized.
Cache needs to be “fresh”
In in dynamic environemnt schema changes will not be available until refresh but there is an API to see if it is stale.
!!You must disable the cache before releasing the workspace object.
3 class of cursors- search for querying, update for positional update, and insert for bulk inserts
1 QueryDefCursor – not bound to a class are used for defined queries
GOOD FOR COMPLEX SCENARIOS
Recycling a cursor
every call to next row resuses the same memory chunk so it is quicker but can not be used when you need to keep a reference to a row on the call to nextRow. So don’t pass that reference around since the data inside changes with each call to nextRow. IF an set of rows is needed for a function cal then use non-recycling
QUERYING AND JOINING DATA
spatial caching – client side caching of feature values for a given spatial extent (MapCache in ArcMAP) – can speed up queries – ISpatialCacheManager2 – use it when you have many spatial queries within a common extent. Make sure to make you extent the complete area you are going to work within. This will also chew memory depending on how many featurea are in the area.
Need to have all feature classes open before filling the cache. You can ask the cache manager if it is filled).
At 9.2 query filter allows for group by or order by in the PostFixClause. Very nice.
SpatialFilter will use caches
VIEW, TABLE JOINS AND COMPLEX QUERIES
Persisted views. You can open views as tables (read only) using the opentable on workspace
can only have one spatial column supported data types in returned fields (no custom types).
On the fly joins
QuerDefs (IQueryDef) – must be in the same datasource, represented as a cursor, can’t be added to ArcMAP. Only grab the fields that you need to make this go faster and consume less memory
Tables must be within same datasource, matches all candidates, uses QueryDef Object, can be used with non-spatial.
Create a new TableQueryName, set the queryDef and Primary Key, Cast to IDatasetName setting workspace and Name, open the name object as a table. Can also use the ST_Geomtery functions in the where clase for the queryDef.
Tables can in differentsources, mathches on first candidate on 1:M and one other caveat that I missed. Create a new in memory RelationshipClassFactory, add the tables,the fields, and join, open the RelQueryTable
EDITING AND TRANSACTIONS
Transaction models –
non-versioned which utilizes DB transaction, scope is controlled through startEditing and StopEditing calls
Versioned – long transactions
Read consistency and isolation per verison
transaction is defined by scope of the edit sessions
Changes are only viewable by the editor until the edit session is explicitly saved, but does have undo and redo. Transaction scope controlled through Start and StopOperation
Outside of an edit session (updating)
ITransaction interface can get access to all this fun stuffthere is also ItransactionsOptions interface can be used to set AutoCommitInterval (default is 1000), 0 == no automatic commits. Careful with a bulk inserts since if you don’t commit you chew RDBMS resources. DBMS rules apply – DDL may commit DML – change the schema and you are going to force a commit
StartMultiUserEditing turns off autocommit (set to 0) this is how you say I want to edit using version or non-versioned featureclassess. Editing errors need to be handled around API committing the transaction (abort the edit session or not).
!!BEST to abort if you get an error
Don’t mix use of Itransaction and IMultiUserWorkspaceEdit
Scope is StartEditOperation and StopEditOperation to allow for interaction between versioned and non-versioned operation. Same general notes as above. Things get a bit tricker when you are editing versioned and nonversioned data in the same session since undo means different things and you need to think carefully here.
!!Transactions are person “connection” not per Version. Since connections use the same DB connection a call to commit will commit all workspaces using that connection
Non-versioned edit session – you need to see the slide it is really helpful. Pay attention to the different operations that start and stop transactions.
Archives – add a new version called a historical version which is a read only version. Queries can go against the archive table which may be faster than querying default. There is an IHistoricalWorkspace which can be queried by date
Difference cursors – a cursor of object difference between versions – IVersionTable.Differences returns a IDfferenceCursor. Works with Historical or transactional versions. The Difference type must be specified. Within a transaction you can ask for all the feautures that were modified.
DeleteNoChange difference case does not return an IROW object but instead returns the OID so you can go get the older version from IVersion2.getCommonAncestor. Historical versions do not support all difference – inserts, updates, and deletes – again DeleteNoChange does not return the IRow
IVersionEvents and IVersionEvents2 use for executing specific code blocks when events fire – reconcile, post, version redefine, archive updates events
CODE INSTRUMENTATION AND TRACING
need it to time certain operations or check how efficient the application works with enterprise (database) – number of calls and the performance of individual operations.
symptons – repeated calls to the database, slow running operation
use – ArcSDE Client intercept and trace logs and DBMS Trace files
for custom application timers around an edit or data data fetching
USE SDETRACE and SDEINTERCEPT – intercept is probably better. Using it on the client – SEE the SLIDE.
If you have a spatial cache you should see no calls to SDE once you start querying.
This session was the hawesome! All the tips and trick I would not have gotten from the doc. But are going to be invaluable when working on apps. And it also went from soup to nuts with schemas and versioning to how to trace to look for performance problems.