Performance difference between PreparedStatements with BoundStatements vs Accessors with MappingManager

142 views
Skip to first unread message

Malav Shah

unread,
Dec 14, 2016, 10:07:42 PM12/14/16
to DataStax Java Driver for Apache Cassandra User Mailing List
I have done plenty of online research to find the performance impact on Cassandra when using PreparedStatements with BoundStatements vs Accessors with MappingManager. But here I am still looking for the answer. 

So far I understand that Accessors and MappingManager use session and PreparedStatements internally (correct me if I am wrong). Although, I am uncertain whether Accessors with MappingManager creates an overhead or is there any significant performance notes one over the other.

Any information regarding the question would be very helpful. 

Thanks,
Malav


Andrew Tolbert

unread,
Dec 14, 2016, 10:15:06 PM12/14/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi Malav,


So far I understand that Accessors and MappingManager use session and PreparedStatements internally (correct me if I am wrong).

You are correct.


Although, I am uncertain whether Accessors with MappingManager creates an overhead or is there any significant performance notes one over the other.

I would not expect anything significantly impacting performance.  Any overhead would probably be in the initialization of creating the proxy objects from the annotated interfaces and that is a one time activity.  With that done, I would expect similar performance.

Thanks,
Andy

Malav Shah

unread,
Dec 14, 2016, 10:29:00 PM12/14/16
to DataStax Java Driver for Apache Cassandra User Mailing List
That is a great explanation. Thanks!

However, It leads me to a statement which may require your confirmation. PreparedStatements are prepared at beginning and cluster would be aware of any future request and same applies for Accessors methods, correct?

For instance, 
PreparedStatement with query string "SELECT * FROM users WHERE user_id = ?;"  and calling it multiple times will be same as calling an Accessor method with same query string annotated multiple times.

Much appreciated!

Thanks,
Malav

Andrew Tolbert

unread,
Dec 14, 2016, 10:35:20 PM12/14/16
to DataStax Java Driver for Apache Cassandra User Mailing List
However, It leads me to a statement which may require your confirmation. PreparedStatements are prepared at beginning and cluster would be aware of any future request and same applies for Accessors methods, correct?

Exactly, the relevent statements would be prepared once (although they could be reprepared later as needed, i.e. if nodes go down & then up).  Whenever you call a method on an accessor, it creates a BoundStatement from the existing PreparedStatement instance that was created when you called createAccessor.

Thanks,
Andy

 

Malav Shah

unread,
Dec 14, 2016, 10:42:13 PM12/14/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Thanks a lot, Andy! 

This is very helpful.

Best,
Malav
Reply all
Reply to author
Forward
0 new messages