question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linq Count consumes more RUs than listing results from a predicate

See original GitHub issue

Describe the bug When using Linq Count function, it consumes more RUs than a listing function.

image

To Reproduce Just invoke the Count function and compare the RUs against the same query just using a Where clause. You will see that Count consumes more RUs than just listing all the items that matches the criteria.

Expected behavior Linq Count should consume at least the same RUs than the listing

Actual behavior Linq Count consumes more RUs than a listing method

Environment summary SDK Version: 3.31 OS Version: Windows 10

Additional context It seems that the bug is because of this: https://learn.microsoft.com/en-us/azure/cosmos-db/index-overview#index-utilization-for-scalar-aggregate-functions

When I execute the same query with SQL in the Data explorer tool I got different RUs consumption when doing this: SELECT COUNT(c.orgId) FROM c where c.partitionKey= 300741 and c.otherProperty = '921c273b-b653-4cfc-87b2-0bdefa35b6a4'

SELECT COUNT(1) FROM c where c.partitionKey= 300741 and c.otherProperty = '921c273b-b653-4cfc-87b2-0bdefa35b6a4' (consumes more RUs)

I think that the same is happening with other aggregates.

These are the diagnostics from each case (listing vs count). Both of them use the same predicate

Listing { "Summary": { "DirectCalls": { "(200, 0)": 1 }, "RegionsContacted": 1, "GatewayCalls": { "(200, 0)": 3, "(304, 0)": 1 } }, "name": "Typed FeedIterator ReadNextAsync", "id": "a0176700-6939-4a13-b112-e49ee337fd97", "start time": "12:06:29:244", "duration in milliseconds": 1463.8179, "data": { "Client Configuration": { "Client Created Time Utc": "2022-10-26T12:06:15.4508444Z", "MachineId": "vmId:c765492b-d4c9-40b9-a24e-37283ab7f813", "VM Region": "westus", "NumberOfClientsCreated": 1, "NumberOfActiveClients": 1, "ConnectionMode": "Direct", "User Agent": "cosmos-netstandard-sdk/3.29.0|1|X64|Microsoft Windows 10.0.19044|.NET 6.0.7|N|F 00000001|", "ConnectionConfig": { "gw": "(cps:50, urto:10, p:False, httpf: False)", "rntbd": "(cto: 5, icto: -1, mrpc: 30, mcpe: 65535, erd: True, pr: ReuseUnicastPort)", "other": "(ed:False, be:True)" }, "ConsistencyConfig": "(consistency: NotSet, prgns:[], apprgn: )", "ProcessorCount": 4 }, "Query Correlated ActivityId": "789d41ca-0c18-4b2f-9745-7679690c2c7b" }, "children": [ { "name": "Create Query Pipeline", "id": "eb716e79-2d03-46b9-b5f9-27bb55cbeb4d", "start time": "12:06:29:281", "duration in milliseconds": 648.8994, "children": [ { "name": "Get Container Properties", "id": "e67b6cef-a1c4-4a7a-ae79-a1fd109c7cb6", "start time": "12:06:29:286", "duration in milliseconds": 88.0047, "children": [ { "name": "Get Collection Cache", "id": "5b2dd098-ad22-4eaf-9d67-3d0f2ec82352", "start time": "12:06:29:286", "duration in milliseconds": 0.001 }, { "name": "Read Collection", "id": "a0a57a69-c6cd-4186-9b7a-94b88b6b213a", "start time": "12:06:29:287", "duration in milliseconds": 85.7554, "data": { "Client Side Request Stats": { "Id": "AggregatedClientSideRequestStatistics", "ContactedReplicas": [], "RegionsContacted": [], "FailedReplicas": [], "AddressResolutionStatistics": [], "StoreResponseStatistics": [], "HttpResponseStats": [ { "StartTimeUTC": "2022-10-26T12:06:29.2873661Z", "DurationInMs": 85.1029, "RequestUri": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/dbs/CreativeManagement/colls/Creative", "ResourceType": "Collection", "HttpMethod": "GET", "ActivityId": "a00b6b07-d1ab-4e6b-8403-954ea8a616c8", "StatusCode": "OK" } ] } } } ] }, { "name": "Service Interop Query Plan", "id": "78cf86d1-d19f-4478-b9b5-1abac6ee5abe", "start time": "12:06:29:613", "duration in milliseconds": 104.1274 }, { "name": "Get Partition Key Ranges", "id": "a480270f-c623-4bd7-86a7-17535f2e0456", "start time": "12:06:29:738", "duration in milliseconds": 158.3074, "children": [ { "name": "Try Get Overlapping Ranges", "id": "e014c31d-9e7d-4f33-bda9-93a24466d47d", "start time": "12:06:29:751", "duration in milliseconds": 141.159, "data": { "PKRangeCache Info(2022-10-26T12:06:29.8851088Z)": { "Previous Continuation Token": null, "Continuation Token": "\"45\"" } }, "children": [ { "name": "Read PartitionKeyRange Change Feed", "id": "0ebd6cc8-840e-4368-a040-db0f0e4b3504", "start time": "12:06:29:751", "duration in milliseconds": 67.3504, "data": { "Client Side Request Stats": { "Id": "AggregatedClientSideRequestStatistics", "ContactedReplicas": [], "RegionsContacted": [], "FailedReplicas": [], "AddressResolutionStatistics": [], "StoreResponseStatistics": [], "HttpResponseStats": [ { "StartTimeUTC": "2022-10-26T12:06:29.7517593Z", "DurationInMs": 67.0803, "RequestUri": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/dbs/k6BrAA==/colls/k6BrAN5WfmQ=/pkranges", "ResourceType": "PartitionKeyRange", "HttpMethod": "GET", "ActivityId": "de5206e2-306b-4a0e-8073-d53e944c7071", "StatusCode": "OK" } ] } } }, { "name": "Read PartitionKeyRange Change Feed", "id": "b4243d03-08fb-4961-a84a-6ef671f4413d", "start time": "12:06:29:819", "duration in milliseconds": 65.8393, "data": { "Client Side Request Stats": { "Id": "AggregatedClientSideRequestStatistics", "ContactedReplicas": [], "RegionsContacted": [], "FailedReplicas": [], "AddressResolutionStatistics": [], "StoreResponseStatistics": [], "HttpResponseStats": [ { "StartTimeUTC": "2022-10-26T12:06:29.8192566Z", "DurationInMs": 65.6472, "RequestUri": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/dbs/k6BrAA==/colls/k6BrAN5WfmQ=/pkranges", "ResourceType": "PartitionKeyRange", "HttpMethod": "GET", "ActivityId": "bb90da48-79dc-4ff5-9118-d44c44be9209", "StatusCode": "NotModified", "ReasonPhrase": "Not Modified" } ] } } } ] } ] } ] }, { "name": "MoveNextAsync", "id": "a9b1530d-f718-43cb-bb3d-36373b54d850", "start time": "12:06:29:956", "duration in milliseconds": 732.3981, "children": [ { "name": "Prefetching", "id": "11fbe8fd-1e0a-4529-bc74-9e9690637d20", "start time": "12:06:29:975", "duration in milliseconds": 0.0541 }, { "name": "[,FF) move next", "id": "19ea0ff6-6568-41f5-942b-ca78699bf6c1", "start time": "12:06:29:983", "duration in milliseconds": 701.9077, "children": [ { "name": "Prefetch", "id": "d6f32371-a0ab-4e3c-9fda-e22177743a77", "start time": "12:06:29:990", "duration in milliseconds": 692.9626, "children": [ { "name": "[,FF) move next", "id": "cd6c8529-e9ff-4f4e-aa09-b1765b7706c7", "start time": "12:06:29:990", "duration in milliseconds": 691.4818, "data": { "Query Metrics": "Retrieved Document Count : 0 \r\nRetrieved Document Size : 0 bytes \r\nOutput Document Count : 0 \r\nOutput Document Size : 49 bytes \r\nIndex Utilization : 0.00 % \r\nTotal Query Execution Time : 0.44 milliseconds\r\n Query Preparation Time : 0.16 milliseconds\r\n Index Lookup Time : 0.14 milliseconds\r\n Document Load Time : 0.00 milliseconds\r\n Runtime Execution Times : 0.00 milliseconds\r\n Document Write Time : 0.00 milliseconds\r\n\r\nIndex Utilization Information\r\n Utilized Single Indexes\r\n Potential Single Indexes\r\n Utilized Composite Indexes\r\n Potential Composite Indexes\r\n" }, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler", "id": "2392acd9-90e0-42cb-ab11-c82c17c79140", "start time": "12:06:29:999", "duration in milliseconds": 580.642, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler", "id": "99468ccb-c73d-4d3f-992d-5902f6d9ed32", "start time": "12:06:30:003", "duration in milliseconds": 577.2423, "data": { "System Info": { "systemHistory": [ { "dateUtc": "2022-10-26T12:06:15.8467221Z", "cpu": 2.736, "memory": 6197376, "threadInfo": { "isThreadStarving": "no info", "availableThreads": 32765, "minThreads": 4, "maxThreads": 32767 }, "numberOfOpenTcpConnection": 0 }, { "dateUtc": "2022-10-26T12:06:26.0353481Z", "cpu": 36.196, "memory": 6184624, "threadInfo": { "isThreadStarving": "False", "threadWaitIntervalInMs": 12.8105, "availableThreads": 32765, "minThreads": 4, "maxThreads": 32767 }, "numberOfOpenTcpConnection": 1 } ] } }, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.RetryHandler", "id": "b5985aa8-37d6-43ca-9055-b9b551df2002", "start time": "12:06:30:003", "duration in milliseconds": 577.2104, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.RouterHandler", "id": "87b76c23-7893-4318-9555-f3f9feb3f1ad", "start time": "12:06:30:003", "duration in milliseconds": 577.1246, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.TransportHandler", "id": "69dce7ac-8834-4cd7-a53c-7c387cf1c26f", "start time": "12:06:30:003", "duration in milliseconds": 577.1137, "children": [ { "name": "Microsoft.Azure.Documents.ServerStoreModel Transport Request", "id": "46446c23-1dc0-4c19-b08d-1e8550c33e58", "start time": "12:06:30:003", "duration in milliseconds": 577.0337, "data": { "Client Side Request Stats": { "Id": "AggregatedClientSideRequestStatistics", "ContactedReplicas": [ { "Count": 1, "Uri": "rntbd://cdb-ms-prod-eastus2-be32.documents.azure.com:14033/apps/dd27c7fe-adac-4112-8c0e-d60a0756e094/services/0d29a44a-d788-4c8a-860d-a7a0d8181010/partitions/49436a70-094e-4c49-a176-1ea65ca321ac/replicas/133080948162629968p/" } ], "RegionsContacted": [ "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/" ], "FailedReplicas": [], "AddressResolutionStatistics": [ { "StartTimeUTC": "2022-10-26T12:06:30.0415808Z", "EndTimeUTC": "2022-10-26T12:06:30.1087655Z", "TargetEndpoint": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com//addresses/?$resolveFor=dbs%2fk6BrAA%3d%3d%2fcolls%2fk6BrAN5WfmQ%3d%2fdocs&$filter=protocol eq rntbd&$partitionKeyRangeIds=0" } ], "StoreResponseStatistics": [ { "ResponseTimeUTC": "2022-10-26T12:06:30.5669916Z", "ResourceType": "Document", "OperationType": "Query", "LocationEndpoint": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/", "StoreResult": { "ActivityId": "589b28e6-6e09-450f-aea7-ec274878a977", "StatusCode": "Ok", "SubStatusCode": "Unknown", "LSN": 36, "PartitionKeyRangeId": "0", "GlobalCommittedLSN": 36, "ItemLSN": -1, "UsingLocalLSN": true, "QuorumAckedLSN": 36, "SessionToken": "0#36#7=-1", "CurrentWriteQuorum": 3, "CurrentReplicaSetSize": 4, "NumberOfReadRegions": 1, "IsValid": true, "StorePhysicalAddress": "rntbd://cdb-ms-prod-eastus2-be32.documents.azure.com:14033/apps/dd27c7fe-adac-4112-8c0e-d60a0756e094/services/0d29a44a-d788-4c8a-860d-a7a0d8181010/partitions/49436a70-094e-4c49-a176-1ea65ca321ac/replicas/133080948162629968p/", "RequestCharge": 2.89, "RetryAfterInMs": null, "BELatencyInMs": "0.866", "transportRequestTimeline": { "requestTimeline": [ { "event": "Created", "startTimeUtc": "2022-10-26T12:06:30.1511306Z", "durationInMs": 0.0381 }, { "event": "ChannelAcquisitionStarted", "startTimeUtc": "2022-10-26T12:06:30.1511687Z", "durationInMs": 336.3407 }, { "event": "Pipelined", "startTimeUtc": "2022-10-26T12:06:30.4875094Z", "durationInMs": 9.109 }, { "event": "Transit Time", "startTimeUtc": "2022-10-26T12:06:30.4966184Z", "durationInMs": 60.5555 }, { "event": "Received", "startTimeUtc": "2022-10-26T12:06:30.5571739Z", "durationInMs": 1.7869 }, { "event": "Completed", "startTimeUtc": "2022-10-26T12:06:30.5589608Z", "durationInMs": 0 } ], "serviceEndpointStats": { "inflightRequests": 1, "openConnections": 1 }, "connectionStats": { "waitforConnectionInit": "True", "callsPendingReceive": 0, "lastSendAttempt": "2022-10-26T12:06:30.4277964Z", "lastSend": "2022-10-26T12:06:30.4279022Z", "lastReceive": "2022-10-26T12:06:30.4867216Z" }, "requestSizeInBytes": 599, "requestBodySizeInBytes": 142, "responseMetadataSizeInBytes": 935, "responseBodySizeInBytes": 49 }, "TransportException": null } } ], "HttpResponseStats": [ { "StartTimeUTC": "2022-10-26T12:06:30.0416179Z", "DurationInMs": 66.8717, "RequestUri": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com//addresses/?$resolveFor=dbs%2fk6BrAA%3d%3d%2fcolls%2fk6BrAN5WfmQ%3d%2fdocs&$filter=protocol eq rntbd&$partitionKeyRangeIds=0", "ResourceType": "Document", "HttpMethod": "GET", "ActivityId": "589b28e6-6e09-450f-aea7-ec274878a977", "StatusCode": "OK" } ] } } } ] } ] } ] } ] } ] }, { "name": "Get Cosmos Element Response", "id": "f6fde339-d0af-4a7c-b46e-902f61322c1f", "start time": "12:06:30:588", "duration in milliseconds": 90.1951 } ] } ] } ] } ] }, { "name": "Query Response Serialization", "id": "a924e4a3-d75b-4d07-b4cf-ab9049e15dff", "start time": "12:06:30:699", "duration in milliseconds": 8.4512 } ] }

Count { "Summary": { "DirectCalls": { "(200, 0)": 1 }, "RegionsContacted": 1 }, "name": "Aggregate LINQ Operation", "id": "8aa45255-5885-433e-9495-358d8d136037", "start time": "12:12:41:134", "duration in milliseconds": 610.7035, "data": { "Query Correlated ActivityId": "682b13c7-8907-4b5c-8039-6ce8d1e1bf7c" }, "children": [ { "name": "Create Query Pipeline", "id": "4d955850-d300-4a44-9658-217e8b178120", "start time": "12:12:41:140", "duration in milliseconds": 21.183, "children": [ { "name": "Get Container Properties", "id": "4260925e-930a-4671-97df-07c0e19179f1", "start time": "12:12:41:140", "duration in milliseconds": 0.0195, "children": [ { "name": "Get Collection Cache", "id": "a2be07a3-1def-41d2-8724-3aae670837ef", "start time": "12:12:41:140", "duration in milliseconds": 0.0008 } ] }, { "name": "Service Interop Query Plan", "id": "39ccce2a-2a61-421a-a479-4d70603d2955", "start time": "12:12:41:140", "duration in milliseconds": 2.1466 }, { "name": "Get Partition Key Ranges", "id": "c49e8317-75c8-4d37-a6c0-c06ca1008a00", "start time": "12:12:41:142", "duration in milliseconds": 0.1914, "children": [ { "name": "Try Get Overlapping Ranges", "id": "bc6aeb95-2066-4101-b3a7-c0f3e92c73d6", "start time": "12:12:41:143", "duration in milliseconds": 0.0737 } ] } ] }, { "name": "MoveNextAsync", "id": "919a2c4f-610e-4504-a773-fd7498a024c8", "start time": "12:12:41:175", "duration in milliseconds": 499.4397, "children": [ { "name": "Prefetching", "id": "0074140d-9414-491d-9f4e-a9fe70af3268", "start time": "12:12:41:176", "duration in milliseconds": 0.0038 }, { "name": "[,FF) move next", "id": "83c64c20-f8a4-41cd-bf56-34424371a4e7", "start time": "12:12:41:176", "duration in milliseconds": 498.458, "children": [ { "name": "[,FF) move next", "id": "bd88c00a-c3fa-417c-9cf8-7c6ec19a394f", "start time": "12:12:41:180", "duration in milliseconds": 492.2235, "data": { "Query Metrics": "Retrieved Document Count : 0 \r\nRetrieved Document Size : 0 bytes \r\nOutput Document Count : 1 \r\nOutput Document Size : 61 bytes \r\nIndex Utilization : 100.00 % \r\nTotal Query Execution Time : 0.46 milliseconds\r\n Query Preparation Time : 0.18 milliseconds\r\n Index Lookup Time : 0.15 milliseconds\r\n Document Load Time : 0.00 milliseconds\r\n Runtime Execution Times : 0.00 milliseconds\r\n Document Write Time : 0.00 milliseconds\r\n\r\nIndex Utilization Information\r\n Utilized Single Indexes\r\n Potential Single Indexes\r\n Utilized Composite Indexes\r\n Potential Composite Indexes\r\n" }, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler", "id": "1802ace5-d3fa-4b29-844e-ba1a8372a87b", "start time": "12:12:41:180", "duration in milliseconds": 491.7476, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler", "id": "e601bf60-cbfb-404b-b01e-46abe81fb477", "start time": "12:12:41:180", "duration in milliseconds": 491.6764, "data": { "System Info": { "systemHistory": [ { "dateUtc": "2022-10-26T12:06:15.8467221Z", "cpu": 2.736, "memory": 6197376, "threadInfo": { "isThreadStarving": "no info", "availableThreads": 32765, "minThreads": 4, "maxThreads": 32767 }, "numberOfOpenTcpConnection": 0 }, { "dateUtc": "2022-10-26T12:06:26.0353481Z", "cpu": 36.196, "memory": 6184624, "threadInfo": { "isThreadStarving": "False", "threadWaitIntervalInMs": 12.8105, "availableThreads": 32765, "minThreads": 4, "maxThreads": 32767 }, "numberOfOpenTcpConnection": 1 }, { "dateUtc": "2022-10-26T12:12:38.8530710Z", "cpu": 22.091, "memory": 5899564, "threadInfo": { "isThreadStarving": "False", "threadWaitIntervalInMs": 0.0331, "availableThreads": 32761, "minThreads": 4, "maxThreads": 32767 }, "numberOfOpenTcpConnection": 2 } ] } }, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.RetryHandler", "id": "b1c1f26c-bbce-45c4-93e9-34ceb65f488a", "start time": "12:12:41:180", "duration in milliseconds": 491.6481, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.RouterHandler", "id": "0e4a6885-6a8e-43fb-bdcc-d340608cbe04", "start time": "12:12:41:180", "duration in milliseconds": 491.6138, "children": [ { "name": "Microsoft.Azure.Cosmos.Handlers.TransportHandler", "id": "fcfd4e02-b008-4730-87f3-c421f0d5c0c9", "start time": "12:12:41:180", "duration in milliseconds": 491.6049, "children": [ { "name": "Microsoft.Azure.Documents.ServerStoreModel Transport Request", "id": "58cebe99-8f29-4fb6-8a2f-2853d86abd7c", "start time": "12:12:41:180", "duration in milliseconds": 491.5033, "data": { "Client Side Request Stats": { "Id": "AggregatedClientSideRequestStatistics", "ContactedReplicas": [ { "Count": 1, "Uri": "rntbd://cdb-ms-prod-eastus2-be32.documents.azure.com:14307/apps/dd27c7fe-adac-4112-8c0e-d60a0756e094/services/0d29a44a-d788-4c8a-860d-a7a0d8181010/partitions/49436a70-094e-4c49-a176-1ea65ca321ac/replicas/133080948102471798s/" } ], "RegionsContacted": [ "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/" ], "FailedReplicas": [], "AddressResolutionStatistics": [], "StoreResponseStatistics": [ { "ResponseTimeUTC": "2022-10-26T12:12:41.6586065Z", "ResourceType": "Document", "OperationType": "Query", "RequestSessionToken": "0:0#36#7=-1", "LocationEndpoint": "https://cosmos-creativemgt-feature-001-eastus2.documents.azure.com/", "StoreResult": { "ActivityId": "f157a3c9-ace8-4202-9dd6-87ac5757e142", "StatusCode": "Ok", "SubStatusCode": "Unknown", "LSN": 36, "PartitionKeyRangeId": "0", "GlobalCommittedLSN": 35, "ItemLSN": -1, "UsingLocalLSN": true, "QuorumAckedLSN": -1, "SessionToken": "0#36#7=-1", "CurrentWriteQuorum": -1, "CurrentReplicaSetSize": -1, "NumberOfReadRegions": 1, "IsValid": true, "StorePhysicalAddress": "rntbd://cdb-ms-prod-eastus2-be32.documents.azure.com:14307/apps/dd27c7fe-adac-4112-8c0e-d60a0756e094/services/0d29a44a-d788-4c8a-860d-a7a0d8181010/partitions/49436a70-094e-4c49-a176-1ea65ca321ac/replicas/133080948102471798s/", "RequestCharge": 3.09, "RetryAfterInMs": null, "BELatencyInMs": "0.809", "transportRequestTimeline": { "requestTimeline": [ { "event": "Created", "startTimeUtc": "2022-10-26T12:12:41.1813995Z", "durationInMs": 0.0217 }, { "event": "ChannelAcquisitionStarted", "startTimeUtc": "2022-10-26T12:12:41.1814212Z", "durationInMs": 413.2362 }, { "event": "Pipelined", "startTimeUtc": "2022-10-26T12:12:41.5946574Z", "durationInMs": 2.2193 }, { "event": "Transit Time", "startTimeUtc": "2022-10-26T12:12:41.5968767Z", "durationInMs": 60.2185 }, { "event": "Received", "startTimeUtc": "2022-10-26T12:12:41.6570952Z", "durationInMs": 1.4703 }, { "event": "Completed", "startTimeUtc": "2022-10-26T12:12:41.6585655Z", "durationInMs": 0 } ], "serviceEndpointStats": { "inflightRequests": 1, "openConnections": 1 }, "connectionStats": { "waitforConnectionInit": "True", "callsPendingReceive": 0, "lastSendAttempt": "2022-10-26T12:12:41.5343003Z", "lastSend": "2022-10-26T12:12:41.5343772Z", "lastReceive": "2022-10-26T12:12:41.5935887Z" }, "requestSizeInBytes": 616, "requestBodySizeInBytes": 143, "responseMetadataSizeInBytes": 900, "responseBodySizeInBytes": 61 }, "TransportException": null } } ] } } } ] } ] } ] } ] } ] }, { "name": "Get Cosmos Element Response", "id": "4e486539-ad3e-4f1f-84ac-2e06b9cd3f96", "start time": "12:12:41:672", "duration in milliseconds": 0.2666 } ] } ] } ] }, { "name": "MoveNextAsync", "id": "e2e5ec05-c1dd-4ea2-b38b-86ff4d293b43", "start time": "12:12:41:732", "duration in milliseconds": 0.0092 }, { "name": "Query Response Serialization", "id": "40db45ba-4698-44da-a649-a5713f568374", "start time": "12:12:41:739", "duration in milliseconds": 5.4759 } ] }

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:23 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, Feb 23, 2023

@adityasa Can we please track any documentation update required based on this thread?

1reaction
rtellez91commented, Feb 23, 2023

Thanks @vzubariev, for a moment I thought I was doing something wrong. So it seems that we have no option to efficiently do a count using Linq. I think at least this should be in the documentation or somewhere so is not easy to spot that during development.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling LINQ "Count" queries as IDocumentQuery
Even though I understand that the result type of Count() isn't IQueryable, is there a way to handle "count" queries as document queries?...
Read more >
Is Using LINQ in C# Bad for Performance? | by James Vickers
The LINQ implementation using Whereand then Count with no arguments has a similar slope plus a small overhead penalty compared to for/foreach ( ......
Read more >
Enumerable.Count Method (System.Linq)
Use the LongCount method when you expect and want to allow the result to be greater than MaxValue. In Visual Basic query expression...
Read more >
Linq groupby selectmany. After some googling, it seems that I
I want to use LINQ to group the results by shortcode (and keep all the results) ... SelectMany then flattens the list, after...
Read more >
Linq string contains. … You can try use this article, wher
List <String> listOfStrings = something; I would just do: var query = someCollection. ... If statusIds is an array then you can do:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found