|
Example MultiProcs: First of all, let me give you a typical example: Update a set of records into a big table Orders according to a set of given orderIDs. You may know use one of the following ways:
Way 1 is maybe the simplest but slowest, because you can only update one record per call and database engine has to parse the statement repeatedly. If a string data contains the character '`', you may get a problem. Way 2 is better but also slow, and has such a problem that database engine has to generate a big rowset and fetch many unwanted records over an expensive network. If an OLEDB provider doesn't support IRowsetUpdate, it may further slows down processing. Way 3 turns out to be the best if you code correctly, because fetching records are avoided and database engine processes it using less resource in comparison with rowset. If an OLEDB provider supports interface ICommandPrepare, it eliminates parsing a parameterized statement and enhances performance somewhat. At best, if an OLEDB provider supports DBPROP_MULTIPLEPARAMSETS, it can send multiple sets of data per call so that data traffic over network can be reduced down to the lowest level. The good news is that most of relational database OLEDB providers support the interface ICommandPrepare and the property DBPROP_MULTIPLEPARAMSETS. Full use of them is usually the best way to load and update (and delete) bulk records into a data source. OleDBPro provides the powerful template class CBatchParam<T>, which uses the way 3 to load, update and delete records into and from a data source with any valid parameterized statement or stored procedure. Even if your OLEDB provder doesn't support the above interface and property, it is still able to execute it for you at the fastest speed. Here is the list about this example.
If you use MS SQL Server, you can use its specific interface, IRowsetFastLoad, to insert batch records into a table at the fastest speed, For details, see example FastLoad. However, it can't be used to update records or delete records. |