This topic provides a high-level introduction to VMware Tanzu GemFire querying, query language features, and describes building a query string.

Tanzu GemFire provides a SQL-like querying language that allows you to access data stored in Tanzu GemFire regions. Because Tanzu GemFire regions are key-value stores where values can range from simple byte arrays to complex nested objects, Tanzu GemFire uses a query syntax based on Object Query Language (OQL) to query region data. OQL and SQL have many syntactical similarities, but also have significant differences. For example, OQL does not offer all of the capabilities of SQL like aggregates, but OQL does allow you to execute queries on complex object graphs, query object attributes, and invoke object methods.

The syntax of a typical Tanzu GemFire OQL query is as follows:

[IMPORT package]
SELECT [DISTINCT] projectionList
FROM collection1, [collection2, ...]
[WHERE clause]
[ORDER BY order_criteria [desc]]

A simple Tanzu GemFire OQL query resembles the following:

SELECT DISTINCT * FROM /exampleRegion WHERE status = 'active'

An important characteristic of Tanzu GemFire querying to note is that, by default, Tanzu GemFire queries on the values of a region and not on keys. To obtain keys from a region, you must use the keySet path expression on the queried region. For example, /exampleRegion.keySet.

For more information about Tanzu GemFire querying, see the Tanzu GemFire Querying FAQ and Examples.

Advantages of OQL

The following list describes some of the advantages of using an OQL-based querying language:

  • You can query on any arbitrary object.
  • You can navigate object collections.
  • You can invoke methods and access the behavior of objects.
  • Data mapping is supported.
  • You are not required to declare types. Since you do not need type definitions, you can work across multiple languages.
  • You are not constrained by a schema.
check-circle-line exclamation-circle-line close-line
Scroll to top icon