Surgical Coder
Surgical Coder

Reputation: 1084

Windows Azure Tables - Row Count?

We have a few tables that sit in Azure Storage Tables (NOT Azure SQL Tables), and I cant find an easy way to give me a count of the number of rows in a table.

I have tried calling .CreateQuery.Count(), but that simply returns:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code>InvalidInput</code>
  <message xml:lang="en-US">One of the request inputs is not valid.
RequestId:c74f8b4c-4277-42f6-bb5d-0db187358e43
Time:2011-12-21T10:34:12.5379616Z</message>
</error>

Upvotes: 9

Views: 16209

Answers (3)

Alex Cube
Alex Cube

Reputation: 442

There is a tool which can get table size or entities count for you. Azure Storage Manager

  1. Select a storage table in left tree pane
  2. Click 'Property' button
  3. Click 'Calc' button on the table properties dialog
  4. Wait a few moment, till 'Calc' button becomes available again.

Upvotes: 0

Puhek
Puhek

Reputation: 475

If you really want to count all rows you'll need to make paging requests. Every page returns a maximum of 1000 rows. After loading all in-memory, you can do a simple Linq Count().

You can count only pages and last page row number. This will save you lots of memory.

But beware, every page request with max rows returned equals one transaction. Performance wise, you'll actualy load whole table in memory which can be "uh-oh".

Link to sample code: http://scottdensmore.typepad.com/code/Continuation.zip

Upvotes: 8

astaykov
astaykov

Reputation: 30893

This is because there is no Count operation for the Table Service: http://msdn.microsoft.com/en-us/library/windowsazure/dd179423.aspx You might be able (but I am not 100% sure) to get the count of record if you specify at least a partition key, or more criterias.

Upvotes: 9

Related Questions