seniorCosmos DB

Architecting Polyglot Persistence: When to use Cosmos DB SQL API vs Gremlin Graph

Updated Apr 28, 2026

Short answer

Use SQL API for high-scale document storage with known access patterns; use Gremlin for traversing complex, multi-hop relationships.

Deep explanation

While both run on the same underlying Cosmos DB engine, the data modeling differs. SQL API is optimized for document-centric workloads where queries typically filter on properties. Gremlin (Graph) is optimized for 'traversal'—queries like 'Who are the friends of my friends who like Sushi?'. In Graph, the relationship (Edge) is a first-class citizen. Architecturally, you might use SQL API for the core user data and project specific relationships into a Gremlin container for social or recommendation features.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Cosmos DB interview questions

View all →