ChrisCross
ChrisCross

Reputation: 3

Apache Ignite: Сache API vs SQL

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

Upvotes: 0

Views: 392

Answers (2)

Stanislav Lukyanov
Stanislav Lukyanov

Reputation: 2157

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

Upvotes: 2

Igor Belyakov
Igor Belyakov

Reputation: 885

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.

Upvotes: 2

Related Questions