I keep seeing this message in the logs, mainly everytime the query is made.
Query SELECT username AS col6,gender AS col1,last_name AS col2,email AS col3,first_name AS col4,something_uuid AS col5,group_email AS col7,deleted AS col8,puars AS col9 FROM something_data WHERE username=?; is not prepared on /XX.YY.91.205:9042, preparing before retrying executing. Seeing this message a few times is fine, but seeing it a lot may be source of performance problems.
The query is made using a mapper.get("username") ---> com.datastax.driver.mapping.Mapper
That's how I initialize the mapper in the constructor. After that I don't use the mappingManager anymore.
this.mapper = mappingManager.mapper(MyPojo.class);
Any clues why?
It looks like that you aren't keeping the instance of the MappingManager
for a long time, but recreate it every time you fetch the data. It's a big mistake - MappingManager
should have the same life time as Cluster
and Session
objects.
The mapping manager is responsible for extracting the field annotations from your class, generating queries, preparing them & then executing. The prepared queries are cached inside mapping manager, so when it destroyed, the cache is lost, and when you trying to perform get
again, the process is repeated, leading to significant overhead - query need to be prepared again, and this is significant network overhead, so actually your queries are slower than if you used non-prepared queries.
Just move MappingManager
instance to some static block, so it could be reused for all your mapper operations.