Skip to main content

Posts

Showing posts from July, 2009

Abstract class vs Interface 1-0

There is a lot of talk on interfaces vs abstract classes and while I was working on a C# ADO.net application (with Ingres on the backend, of course) I was intrigued by the difference between the IDbconnection interface and Dbconnection abstract class. What is the difference ? The IDbConnection interface was introduced in ADO.net 1.0 to enforce common behaviour for the providers' connection objects i.e. a standardized way of how to open a connection, how to close it etc. Of course there were a number of other interfaces introduced such as IDbCommand which at the end of the day allowed programming in a database-agnostic way. So far so good, common behaviour is what an interface is primarily used for. In ado.net 2.0 the DbConnection abstract-must inherit base class was introduced which implements IDbConnection; a first immediate advantage is that you get the implementation that was required by the interface's contract for free as it is implemented by the class. But anoth

Auto generated sequences, the silver bullet for concurrency ?

Ingres incorporated automatic generated sequences, a feature that was built into other dbms products, into version 9 onwards. So are automatic generated sequences just for convenience or are they really useful? They have many advantages which are speed, especially when caching is enabled, scalability, and elimination of concurrency issues associated with unique key generation. But the drawback is that they can introduce gaps in the sequence in a variety of ways : since auto generated sequences are an object that lives in the server, on server failure it is lost. The same is true in case of caching since it can age out of the shared pool. Gaps can also be introduced programmatically e.g. by means of a rollback: user A is getting a number from the sequence let's say number 8 and commits user A is getting the next number from the sequence, number 9 user B is getting the next number from the sequence, number 10 user A rolls back and user B commits thus a gap was effective