DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • A Data-Driven Approach to Application Modernization
  • What Is JHipster?
  • JavaFX Goes Mobile
  • 4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment
  1. DZone
  2. Data Engineering
  3. Databases
  4. Taste of SQL for In-Memory Cache Queries

Taste of SQL for In-Memory Cache Queries

Dmitriy Setrakyan user avatar by
Dmitriy Setrakyan
·
Jan. 31, 11 · Interview
Like (0)
Save
Tweet
Share
7.85K Views

Join the DZone community and get the full member experience.

Join For Free

I plan to blog in more detail about support of native SQL in GridGain data grid in a few days, but here is just a taste on how complex of an SQL statement you can execute against GridGain distributed in-memory cache. Note that you are not querying a database - you are querying objects cached in memory.

The query below utilizes H2 database SQL over JDBC syntax to query a collection of QueueItems at specified positions of a dynamic priority-based queue stored in distributed GridGain cache. As we know, querying an element at a certain position of a result set is not trivial in any SQL, and nested 'select' statements with 'rownum' field usually need to be used. On top of that we need to pass a collection of item positions to a query, which is also a fairly advanced feature.

String sql = 
"select * from (" +
"select *, rownum as r from (" +
"select * from QueueItem where qid=? " +
"order by priority desc, seq asc" +
")" +
") where r in (select * from table(x int=?))"

GridCacheQuery itemsQry = cache.createQuery(SQL, QueueItem.class, sql);

// Specify positions of queue items we want to get.
Collection<Integer> positions = Collections.asList(10, 12, 14);

// Query items at specified positions from queue with ID 123.
GridCacheQueryFuture fut = itemsQry.queryArguments(123, positions).execute();

System.out.println("Queried queue items at specified positions: " + fut.get());

Pretty powerful in my view especially when you also get smart routing, pagination, custom transformers, reducers, visit-only support, text queries, and a lot more...

More information on GridGain queries can be found here or here.

From http://gridgain.blogspot.com/2011/01/taste-of-sql-for-in-memory-cache.html

Database sql Cache (computing)

Opinions expressed by DZone contributors are their own.

Trending

  • A Data-Driven Approach to Application Modernization
  • What Is JHipster?
  • JavaFX Goes Mobile
  • 4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: