cosmos Point Read

huangapple go评论68阅读模式
英文:

cosmos Point Read

问题

My cosmos db query

SELECT *
FROM c
WHERE c.id = "1437156155"
AND c.npi = 1437156155

npi is partition key

It is consuming 2.83 RUS

how to perform Point read so that it consume 1RU

sample document

{
    "npi": 1518966761,
    "Entity_Type_Code": "NA",
    "Employer Identification Number (EIN)": "NA",
    "Provider Last Name (Legal Name)": "NA",
    "Provider_First_Name": "NA",
    "Last Update Date": "NA",
    "NPI_Deactivation_Reason_Code": "NA",
    "NPI_Deactivation_Date": "03/20/2006",
    "NPI_Reactivation_Date": "NA",
    "Healthcare_Provider_Taxonomy_Group_1": "NA",
    "id": "1518966761"
}

I have to achieve this in python

index policy

{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [
        {
            "path": "/*"
        }
    ],
    "excludedPaths": [
        {
            "path": "/\"_etag\"/?"
        }
    ]
}

Anything need to perform in index policy? I found below link it has example for dotnet, i am looking for python

https://devblogs.microsoft.com/cosmosdb/point-reads-versus-queries/

英文:

My cosmos db query

SELECT *
FROM c
WHERE c.id = "1437156155"
AND c.npi = 1437156155

npi is partition key

It is consuming 2.83 RUS

how to perform Point read so that it consume 1RU

sample document

    {
        "npi": 1518966761,
        "Entity_Type_Code": "NA",
        "Employer Identification Number (EIN)": "NA",
        "Provider Last Name (Legal Name)": "NA",
        "Provider_First_Name": "NA",
        "Last Update Date": "NA",
        "NPI_Deactivation_Reason_Code": "NA",
        "NPI_Deactivation_Date": "03/20/2006",
        "NPI_Reactivation_Date": "NA",
        "Healthcare_Provider_Taxonomy_Group_1": "NA",
        "id": "1518966761"
    }

I have to achieve this in python

index policy

    {
        "indexingMode": "consistent",
        "automatic": true,
        "includedPaths": [
            {
                "path": "/*"
            }
        ],
        "excludedPaths": [
            {
                "path": "/\"_etag\"/?"
            }
        ]
    }

Anything need to perform in index policy? I found below link it has example for dotnet, i am looking for python

https://devblogs.microsoft.com/cosmosdb/point-reads-versus-queries/

答案1

得分: 2

response = container.read_item(item="1437156155", partition_key="1437156155")
英文:

Reference: https://learn.microsoft.com/azure/cosmos-db/nosql/samples-python

response = container.read_item(item="1437156155", partition_key="1437156155")

答案2

得分: 1

"Looks like you are looking at the RUs consumed on the Data Explorer, Point operations need to be executed through the SDKs themselves, a query that filters by id and partition key is still considered a query.

Read using Python SDK as Matias mentioned above,

英文:

Looks like you are looking at the RUs consumed on the Data Explorer, Point operations need to be executed through the SDKs themselves, a query that filters by id and partition key is still considered a query.

Read using Python SDK as Matias mentioned above,

huangapple
  • 本文由 发表于 2023年4月13日 23:36:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007316.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定