I'm using Google Cloud Function with google-cloud/datastore modules. My data is structured as 1 kind with 4 string properties, only 1000 entities, indexed on all properties. My query is:
if (/^[a-z0-9]+$/i.test(name)) {
name = name.toLowerCase();
query = datastore.createQuery('IPPhone').filter('email', '>=', name).filter('email', '<', name + '\uffff');
} else if (name.includes('<')) {
query = datastore.createQuery('IPPhone').filter('department', '>=', name).filter('department', '<', name + '\uffff');
isDepartment = true;
} else {
name = fixName(name);
query = datastore.createQuery('IPPhone').filter('name', '=', name);
}
When I query from Google Cloud Function the query time is 14-17 second. However, doing the same thing on my local machine, the query time is much shorter around 800 - 1000 ms. I'm from Hanoi, Vietnam but the only option I can choose for Cloud Function is us-central1.