Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API call performance #9

Open
paulirish opened this issue Jan 24, 2017 · 2 comments
Open

API call performance #9

paulirish opened this issue Jan 24, 2017 · 2 comments

Comments

@paulirish
Copy link
Contributor

Testing with my personal and corporate google accounts I have pretty decent latency on these drive requests.

I inspected the background page, and found the API request, "Copy as cURL" and am now running it with time and tweaking some parameters to see if i can get it faster.

On a simple query I am seeing minimum API call take 1.6s seconds, and maxing at 5.2s. Average/median is about 3ish seconds.

I tried a few things but they dont appear to be improving perf much

  1. migrating to drive API v3.
  2. corpus = default in api v2
  3. lastViewedByMeDate within the last three years

with all these applied it looks like:

function onInputChanged(text, suggest) {
    var url = 'https://www.googleapis.com/drive/v3/files';
    var date = new Date();
    date.setFullYear(date.getFullYear() - 3);
    
    var params = new URLSearchParams();
    params.append('pageSize', 5);
  
    var queries = [
      // text matches
      `fullText contains "${text}"`,
      // only google docs (docs, sheets, slides)
      `mimeType contains "google-apps"`,
      // viewed in last 3 years
      `lastViewedByMeDate > "${date.toISOString()}"`
    ];
    // text matches, and it's a google doc
    params.append('q', queries.join(' and '));
    

but like i said, the perf isn't significantly better.

The best solution is probably the same local caching approach that we ultimately did here: https://github.com/aksenol/drive-quick-search/pull/3/files

@beaufortfrancois
Copy link
Owner

The thing that prevented me to do the same solution as drive-quick-search is that search is less powerful. Using fullText contains is much more reliable than using a simple item.description.toLowerCase().indexOf(lowerCaseQuery)

@paulirish
Copy link
Contributor Author

paulirish commented Jan 25, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants