Skip to content

datastore: get stats / total / count? #413

Description

@raitucarp

how to get stats / total / count information in dataset?

Activity

  1. stephenplusplus commented on Apr 21, 2015

    @stephenplusplus
    Contributor

    @pcostell - are you able to help @raitucarp?

  2. pcostell commented on Apr 21, 2015

    @pcostell
    Contributor

    Datastore has statistics which are generated on a daily basis. The Datastore documentation has information about all the different statistics about your dataset.

    For example to programmatically get your total number of entities and their total size:

    query = dataset.createQuery(['__Stat_Total__'])
    dataset.runQuery(query, function(err, entities, endCursor) {
      if (err) {
        return;
      }
      console.log('Number of entities:', entities[0].data.count)
      console.log('Total entity size:', entities[0].data.entity_size)
    });
    

    You can also see this information in a UI by visiting:

    https://console.developers.google.com/project/<YOUR-PROJECT-ID>/datastore/stats
    
  3. dhermes commented on Apr 21, 2015

    @dhermes
    Contributor

    @pcostell Do you think it'd be worth adding some syntactic sugar around this and offering as a feature?

  4. pcostell commented on Apr 21, 2015

    @pcostell
    Contributor

    I'm not totally sure, but my guess would be that this is not the sort of thing that is useful to most developers from an API perspective. My guess is that in general an application doesn't need to know about it, so it would only be useful if the developer wanted to have a different API than that provided by the Cloud Console.

  5. malditogeek commented on Mar 7, 2017

    @malditogeek

    @pcostell sorry for asking in the super old issue but do you know if the Datastore Emulator supports this stats queries?

  6. kunalvjti commented on May 8, 2017

    @kunalvjti

    Seems like the stats are not generated on a daily basis. Both the API and the UI dashboard mentioned by @pcostell above throw the stale info. My dashboard says 'Last updated 2 days ago — May 5, 2017 at 12:42:27 AM UTC-7'. It also mentions 'Statistics are generated every 24–48 hours. In addition to the kinds used for your entities, statistics also include system kinds, such as those related to metadata. System kinds are not visible in your kinds menu. Note that statistics may not be available for very large datasets.'
    What is a very large dataset ? I have loaded approx ~52k entities in Datastore and want to verify the actual count without waiting until the stats get regenerated again. How can i achieve this ?

  7. dgonzalez commented on Dec 10, 2017

    @dgonzalez

    Well... this is super useful for developers. For example pagination... It is good to know how many pages you want to display.

  8. added a commit that references this issue on Aug 22, 2022
  9. added a commit that references this issue on Oct 5, 2022
  10. 28 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions