Apache Ignite: Сache API vs SQL

Viewed 53

What should I use cache.put(key, value) or cache.query("INSERT INTO Table ")?

2 Answers

In case you properly configured queryable fields for your cache you can use both ways to insert data into the cache:

  1. Key-Value API as shown here.
  2. SqlFieldsQuery as described here.

Also, in case you would like to upload a large amount of data you can use Data Streamer, which automatically buffer the data and group it into batches for better performance.

Any. Or both.

One of the powers of Ignite is that it's truly multi-model - the same data is accessible via different interfaces. If you migrate a legacy app from an RDBMS, you'll use SQL. If you have something simple and don't care about the schema or queries, you'll use key-value.

In my experience, non-trivial systems based on Apache Ignite tend to use different kinds of access simultaneously. A perfectly normal example of an app:

  • Use key-value to insert the data from an upstream source
  • Use SQL to read and write data in batch processing and analytics
  • Use Compute with both SQL and key-value inside of the tasks to do colocated processing and fast analytics
Related