cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher McKenzie" <cmcken...@iizuu.com>
Subject Performance of get
Date Tue, 27 Oct 2009 18:20:21 GMT

Hi,

I'm kind of new to cassandra.  In my application, testing for existence is quite usual.  For
instance, someone gives me say, a URL, and if it doesn't exist, I am ok with that.  This will
be the usual case.  Existence may only happen like 20% of the time.

I was thinking this would be fine, until I saw that the thrift API *throws and exception*
if a key doesn't exist.

Checking for existence, a normal control flow operation, requires using a try/catch method,
which are not intended for normal control flow. Many languages discard the stack when exceptions
are thrown and then do non-local jumps.  Other languages will throw the exception to the operating
system (a 'first chance' exception for instance) to be caught by a debugger if attached. 
Other languages actually execute an interrupt on the processor which is a horrible design
principle for normal program flow: http://en.wikipedia.org/wiki/Interrupt.

My experience with PHP has shown that interrupts come at a cost of about 200 times that of
a type check.  C++ if I recall, on x86/linux was at least an order of magnitude as well. 
In Java, it's a bit cheaper, but there are still faster ways of doing it.

Could Get possibly return a reserved value instead?

Thanks.

~chris.

Mime
View raw message