A quick note: here’s how to write a line of text into logging on the PHP runtime:
syslog(LOG_INFO, "Log Text: " . $variable_to_log);
The first argument can be replaced with standard PHP logging levels, such as LOG_WARNING.
A reminder: App Engine ignores calls to openlog() and closelog() . While you can still call these functions (for instance if you have legacy code), they will not affect logging.
In SQL, the COUNT statement is available for counting the number of rows returned by a SELECT query. Here’s an example:
SELECT COUNT(*) FROM foods WHERE name="apple";
Unfortunately, the App Engine datastore offers no equivalent to the COUNT statement. To count the number of entities, an application has two options:
- Count the entities in a separate counter as they’re added to the datastore. For superior performance, the counter can be sharded and temporarily stored in memcache.
- Query for entities and count the number of entities returned. To help speed up this query, a keys-only request can be configured. However, this option can be slow and expensive.