Skip to content

First query in application takes a long time #2727

Closed

Description

@EJB3927

The first query I perform in my application always takes approximately 10 seconds or more, but subsequent queries will take a normal length of time.

Environment details

Application is running on CloudFunctions, where the issue also exists.

Local environment details:

  • OS: macOS Sierra
  • Node.js version: 7.10.0
  • npm version: 4.2.0
  • google-cloud/datastore version: 1.1.0

Steps to reproduce

        const taskKey = datastore.key(['Token', token]);
        const query = datastore.createQuery('Token').filter('__key__', '=', taskKey);
        var data = datastore.runQuery(query).then((results) => {
            if (results[0].length > 0) return results[0][0];
            else return null;
        }).catch(err => {
            return err;
        });

Activity

  1. added
    api: datastore
    on Nov 6, 2017
  2. stephenplusplus commented on Nov 6, 2017

    @stephenplusplus
    Contributor

    Hey @EJB3927, thanks for reporting. The first API call generally takes more time, due to the authentication step of fetching a token. Are you providing a JSON key file for auth when you instantiate the datastore client, or are you letting Cloud Functions automatically auth?

    Also, what amount of time is normal for that query?

  3. EJB3927 commented on Nov 6, 2017

    @EJB3927
    Author

    We're letting authentication be performed automatically via the GOOGLE_APPLICATION_CREDENTIALS environment variable, even in my local environment. A normal query takes somewhere on the order of a couple dozen milliseconds.

  4. stephenplusplus commented on Nov 6, 2017

    @stephenplusplus
    Contributor

    Unfortunately, this seems to be a common issue: #2374 (comment)

    I'm going to re-open that issue and try to get some input from the relevant teams.

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

Metadata

Metadata

Labels

api: datastore

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions