问题
It is mentioned in most of the articles that if we are using Cosmos Db and newly creating our app we should go with Cosmos db sql api . Mongo api and cassandra api can be used when u already have your app integrated with actual mongo and cassandra and we want to migrate quickly to cosmosdb and not change the ecosystem.
But when we create a new cluster of cosmosdb in azure it ask for api type. That means internally there must be some storage differences and internal engine processing differences apart from just the api(query) interfaces.
I would like to understand what are those differences based on which we should decide the different apis to choose.
回答1:
Yes, there are differences in how Azure stores the data. Apart from the storage, Different APIs support native wire protocol used to communicate.
From azure guides:
Azure Cosmos DB is Microsoft's globally distributed, multi-model database service. Where multi-model means Azure Cosmos DB supports multiple APIs and multiple data models, different APIs use different data formats for storage and wire protocol. For example, SQL uses JSON, MongoDB uses BSON, Table uses EDM, Cassandra uses CQL, Gremlin uses JSON format.
Azure Cosmos DB SQL API accounts support querying items using sql as a JSON query language.
Azure Cosmos DB MongoDB API is compatible with version 3.6 of the MongoDB wire protocol.
Azure Cosmos DB Cassandra API is compatible with CQL version v4. However, there are limitations to the CQL commands.
Please refer https://docs.microsoft.com/en-us/azure/cosmos-db/cassandra-support for more details.
回答2:
The storage infrastructure backend is the same. There are some difference to accommodate the different API's but that is an implementation detail meant to ensure compatibility and fidelity with each of the supported API's.
If you have an existing MongoDB or Cassandra database and would like to migrate to a fully managed experience, then choose one of those. Or if you're deep on MongoDB or Cassandra and don't want to learn Cosmos DB's API then sure, choose one of those.
All the other API's are built on top of Cosmos DB's Core (SQL) API and the SDK's for that API are produced by that team. Any new features on Cosmos DB, for instance Change Streams, is built upon features already in the core service so of course, new features come to the Core API first and then to the other API's later.
Hope that helps.
来源:https://stackoverflow.com/questions/62345105/what-are-storage-differences-between-cosmosdb-sql-api-and-cosmosdb-cassandra-api