All Products
Search
Document Center

Tablestore:How do I query the total number of rows in a table?

Last Updated:Jan 15, 2024

You can query the total number of rows in a table by calling the GetRange operation, using search indexes, or using SQL queries.

  • Call the GetRange operation

    Call the GetRange operation to calculate the number of rows in a table. Low-concurrency levels and poor performance may result in latencies when you call this operation.

  • Use search indexes

    Important

    You must create search indexes before you adopt this method. For more information, see Create search indexes.

    • Use the match all query feature of search indexes to return the total number of rows in a table within milliseconds. For more information, see Match all query.

    • Use the aggregation feature of search indexes to return the total number of rows in a table within milliseconds. For more information, see Aggregation.

  • Use SQL queries

    Important

    To use SQL queries, you must create a mapping table. For more information, see Create mapping tables for tables.

    Execute the following SQL statement to query the total number of rows in a table: Replace the <TABLE_NAME> parameter with the actual name of the mapping table.

    SELECT COUNT(*) FROM `<TABLE_NAME>`