Request a demo
Chat
Contact

For Faster Hazelcast Queries

December 27, 2013

Here some tips on improving Hazelcast query performance:

1- Add indexes for queried fields. For queries with ranges (gt, lt, between) you can use ordered index.

IMap imap = Hazelcast.getMap("employees");
// ordered, since we have ranged queries for this field
imap.addIndex("age", true); 
// not ordered, because boolean field cannot have range
imap.addIndex("active", false);

2- Set optimizeQuery = true, in map config. By enabling this flag, Hazelcast will cache a deserialized (object) form, and use it when necessary. Disadvantage of this approach is memory overhead of cached object.

MapConfig mapConfig = config.getMapConfig(“mapName”);  
mapConfig.setOptimizeQueries(true);

3- Object “in memory format”: By default Hazelcast stores objects in their serialized form. This is an optimization: an extra serialization step is skipped for remote operations. But if the majority of a map’s operations is query; then you can consider changing in-memory-format to object. With object format, queries will be run on directly objects, getting rid of de-serialization. Disadvantage of this approach: The remote get operations from this map will have a serialization step.

MapConfig mapConfig = config.getMapConfig(“mapName”);  
mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);

Note: If you use 3rd approach (in-memory-format=OBJECT) then no need for optimizeQuery setting (2nd one) because objects will be already stored in deserialized.

About the Author

About the Author

Enes Akar

Enes Akar

Co-founder & CTO, Hazelcast Cloud

Enes was one of the early developers of Hazelcast. He joined the company in 2011 with a passion for making distributed computing incredible simple. From 2012 to 2017, he headed the engineering team as VP of Engineering. Since 2017, he has led the development of Hazelcast Cloud, which is enterprise-grade Hazelcast software as a fully managed service in the cloud. Prior to joining Hazelcast, Enes worked in software development and software engineering at telecommunications companies, including Alcatel-Lucent and Ericsson. He holds a Bachelor of Science in Computer Engineering and an MBA from Bogazici University, Istanbul.

Latest Blogs

How to Secure Your Hazelcast Cloud Deployments

Auto-Scaling Clusters with Hazelcast Cloud

Announcing Hazelcast Cloud GA

Announcing Hazelcast Cloud GA

View all blogs by the author
Subscribe

Subscribe to the blog

Follow us on: