Google App Engine: how to speed up a database query for a short string property?

I have a pretty simple database query:

Query q = new Query("person"); q.addFilter("name", Query.FilterOperator.EQUAL, req.getParameter("n")); PreparedQuery pq = datastore.prepare(q); for (Entity result : pq.asList(FetchOptions.Builder.withDefaults())) { // ... } 

Thus, he simply searches for all records for a given name. The name is not unique and contains a maximum of 16 characters. As far as I know, an index for short lines (<500 characters) is automatically generated.

The table has about 100,000 entries. A database query takes more than 8 seconds to retrieve all (about 10) objects.

The question is how to speed it up?

+4
source share
1 answer

Performance dev appserver is not a measure of performance. In particular, dev appserver does not use indexes. At all. Each request simply scans each entity of this type.

Therefore, do not insert so much data into the application dev server. Use it to test basic functions, then deploy and paste your 1,000,000 objects into a production application server, instead of which indexes are actually generated and used.

+5
source

All Articles