Datastore Statistics in legacy bundled services Stay organized with collections Save and categorize content based on your preferences.
Note:Developers building new applications arestrongly encouraged to use theNDB Client Library, which has several benefitscompared to this client library, such as automatic entity caching via the MemcacheAPI. If you are currently using the older DB Client Library, read theDB to NDB Migration Guide
Datastore maintains statistics about the data stored for anapplication, such as how many entities there are of a given kind, or how muchspace is used by property values of a given type. You can view these statisticsin the Google Cloud console, in theDashboard page.
You can also access these values programmatically within the application byquerying for specially named entities using the Datastore API.Each statistic is accessible as an entity whose kind name begins and ends withtwo underscores. For example, each app has exactly one entity of the kind__Stat_Total__ that represents statistics about all of the entities inDatastore in total. Each statistic entity has the followingproperties:
count, the number of items considered by the statistic (a long integer)bytes, the total size of the items for this statistic (a long integer)timestamp, the time of the most recent update to the statistic (a date-timevalue)
Some statistic kinds also have additional properties, listed below.
A Python application can use model classes provided by the packagegoogle.appengine.ext.db.stats to access statistic entities.
fromgoogle.appengine.ext.dbimportstatsglobal_stat=stats.GlobalStat.all().get()print'Total bytes stored:%d'%global_stat.bytesprint'Total entities stored:%d'%global_stat.countWhen the statistics system creates new statistic entities, it does not deletethe old ones right away. The best way to get a consistent view of thestatistics is to query for theGlobalStatentity with the most recenttimestamp, then use that timestamp value as a filter when fetching otherstatistic entities.
The statistic entities are included in the calculated statistic values.Statistic entities take up space relative to the number of unique kinds andproperty names used by the application.
The statistics system will also create statistics specific to eachnamespaceNote that if an application does not use Datastore namespacesthen namespace specific statistics will not be created. Namespace specific statsare found in the namespace that they're specific to. The kind names fornamespace specific stats are prefixed with__Stat_Ns_ and have the samecorresponding suffix as application wide statistics kinds.
Applications with thousands of namespaces, kinds, or property names require avery large number of statistics entities. To keep the overhead of storing andupdating the statistics reasonable, Datastore progressivelydrops statistics entities, in the following order:
- per-namespace, per-kind, and per-property statistics:
__Stat_Ns_PropertyName_Kind__,__Stat_Ns_PropertyType_PropertyName_Kind__ - per-kind and per-property statistics:
__Stat_PropertyName_Kind__,__Stat_PropertyType_PropertyName_Kind__ - per-namespace and per-kind statistics:
__Stat_Ns_Kind__,__Stat_Ns_Kind_IsRootEntity__,__Stat_Ns_Kind_NotRootEntity__,__Stat_Ns_PropertyType_Kind__ - per-kind statistics:
__Stat_Kind__,__Stat_Kind_IsRootEntity__,__Stat_Kind_NotRootEntity__,__Stat_PropertyType_Kind__ - per-namespace statistics:
__Stat_Namespace__,__Stat_Ns_Kind_CompositeIndex__,__Stat_Ns_PropertyType__,__Stat_Ns_Total__
The summary statistics entities (__Stat_Kind_CompositeIndex__,__Stat_PropertyType__,__Stat_Total__) are never dropped.
The complete list of available statistics is as follows:
| Statistic | Stat Entity Kind | Description |
|---|---|---|
| all entities | __Stat_Total__Python class: GlobalStatNamespace specific entry: __Stat_Ns_Total__Python class: NamespaceGlobalStat | All entities. Additional properties: • entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in built-in index entries measured in bytes.• builtin_index_count: the count of built-in index entries.• composite_index_bytes: The storage in composite index entries measured in bytes.• composite_index_count: The count of composite index entries. |
| all entities in a namespace | __Stat_Namespace__Python class: NamespaceStatNote that __Stat_Namespace__ entities are created for each namespace encountered and are only found in the empty string namespace. | All entities in a namespace. • subject_namespace, the namespace represented (a string)• entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in built-in index entries measured in bytes.• builtin_index_count: the count of built-in index entries.• composite_index_bytes: The storage in composite index entries measured in bytes.• composite_index_count: The count of composite index entries. |
| all entries in application defined indexes | __Stat_Kind_CompositeIndex__Namespace specific entry: __Stat_Ns_Kind_CompositeIndex__Python class: KindStat | Entries in the composite index table; one stat entity for each kind of entity stored. Additional properties: • index_id, the index id.• kind_name, the name of the kind represented (a string) |
| entities of a kind | __Stat_Kind__Python class: KindStatNamespace specific entry: __Stat_Ns_Kind__Python class: NamespaceKindStat | Entities of a kind; one stat entity for each kind of entity stored. Additional properties: • kind_name, the name of the kind represented (a string)• entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in built-in index entries measured in bytes.• builtin_index_count: the count of built-in index entries.• composite_index_bytes: The storage in composite index entries measured in bytes.• composite_index_count: The count of composite index entries. |
| root entities of a kind | __Stat_Kind_IsRootEntity__Python class: KindRootEntityStatNamespace specific entry: __Stat_Ns_Kind_IsRootEntity__Python class: NamespaceKindRootEntityStat | Entities of a kind that are entity group root entities (have no ancestor parent); one stat entity for each kind of entity stored. Additional properties: • kind_name, the name of the kind represented (a string)• entity_bytes: The storage in the entities table measured in bytes. |
| non-root entities of a kind | __Stat_Kind_NotRootEntity__Python class: KindNotRootEntityStatNamespace specific entry: __Stat_Ns_Kind_NotRootEntity__Python class: NamespaceKindNotRootEntityStat | Entities of a kind that are not entity group root entities (have an ancestor parent); one stat entity for each kind of entity stored. Additional properties: • kind_name, the name of the kind represented (a string)• entity_bytes: The storage in the entities table measured in bytes. |
| properties of a type | __Stat_PropertyType__Python class: PropertyTypeStatNamespace specific entry: __Stat_Ns_PropertyType__Python class: NamespacePropertyTypeStat | Properties of a value type across all entities; one stat entity per value type. Additional properties: • property_type, the name of the value type (a string)• entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in built-in index entries measured in bytes.• builtin_index_count: the count of built-in index entries. |
| properties of a type per kind | __Stat_PropertyType_Kind__Python class: KindPropertyTypeStatNamespace specific entry: __Stat_Ns_PropertyType_Kind__Python class: NamespaceKindPropertyTypeStat | Properties of a value type across entities of a given kind; one stat entity per combination of property type and kind. Additional properties: • property_type, the name of the value type (a string)• kind_name, the name of the kind represented (a string)• entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in the built-in index measured in bytes.• builtin_index_count: the count of built-in index entries. |
| properties with a name | __Stat_PropertyName_Kind__Python class: KindPropertyNameStatNamespace specific entry: __Stat_Ns_PropertyName_Kind__Python class: NamespaceKindPropertyNameStat | Properties with a given name across entities of a given kind; one stat entity per combination of unique property name and kind. Additional properties: • property_name, the name of the property (a string)• kind_name, the name of the kind represented (a string)• entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in built-in index entries measured in bytes.• builtin_index_count: the count of built-in index entries. |
| properties of a type and with a name | __Stat_PropertyType_PropertyName_Kind__Python class: KindPropertyNamePropertyTypeStatNamespace specific entry: __Stat_Ns_PropertyType_PropertyName_Kind__Python class: NamespaceKindPropertyNamePropertyTypeStat | Properties with a given name and of a given value type across entities of a given kind; one stat entity per combination of property name, value type and kind that exists in Datastore. Additional properties: • property_type, the name of the value type (a string)• property_name, the name of the property (a string)• kind_name, the name of the kind represented (a string)• entity_bytes: The storage in the entities table measured in bytes.• builtin_index_bytes: The storage in built-in index entries measured in bytes.• builtin_index_count: the count of built-in index entries. |
Some statistics refer to Datastore property value types byname, as strings. These names are as follows:
"Blob""BlobKey""Boolean""Category""Date/Time""Email""Float""GeoPt""IM""Integer""Key""Link""NULL""PhoneNumber""PostalAddress""Rating""ShortBlob""String""Text""User"
__Stat_Namespace__ entities contain the same information found in__Stat_Ns_Total__ records.__Stat_Namespace__ entities are stored in theempty namespace and contain asubject_namespace field describing the namespaceto which they belong.__Stat_Ns_Total__ records are stored in the namespace towhich they refer, and thus do not contain asubject_namespace field. Hence, aquery on kind__Stat_Namespace__ (from the empty string namespace) ordereddescending bybytes will list the namespaces that consume the largest storagefirst. Because queries across namespaces are not possible, any query for__Stat_Ns_Total__ entities will only ever produce at most a single record.Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.