-1

(Note: This is a self-answering question)

I noticed orderBy folder,title is very slow, what should I do ?

$ time curl 'https://content.googleapis.com/drive/v2/files?maxResults=10&orderBy=folder%2Ctitle&q=%27root%27%20in%20parents%20and%20trashed%3Dfalse&key=XXX' --compressed -H 'Authorization: Bearer XXX' -H 'X-Origin: https://explorer.apis.google.com'  -H 'If-None-Match: "XXX"'

It requires almost ~11 seconds to complete:

real    0m11.356s
user    0m0.008s
sys     0m0.016s

You can test in API Explorer. The query is:

  • maxResults: 10
  • ordeBy: folder,title
  • q: 'root' in parents and trashed=false
林果皞
  • 7,539
  • 3
  • 55
  • 70
  • @DaImTo This is obviously google API v2 problem, since change the orderBy from `folder,title` to `title,folder` when q is empty will cut down the time from 12 to 1 second. – 林果皞 Nov 27 '17 at 11:19
  • If you have some stats you may want to post this on the issue forum https://issuetracker.google.com/issues?q=componentid:191650%2B. I suspect this is going to be hard to prove as it could just be an issue with your connection, or the amount of data or a number of other factors. Note: I don't think there is any development being done on v2 anymore. So i don't think there is really anything you can do about it. – Linda Lawton - DaImTo Nov 27 '17 at 11:49
  • 1
    @DaImTo I filed a bug report at https://issuetracker.google.com/issues/69785597 – 林果皞 Nov 27 '17 at 13:48
  • I feel very disappointed to self-answering to help the community(It did solved my problem) while what I get is downvote. Keep in mind accept self-answering answer will not earn any reputation. – 林果皞 Nov 28 '17 at 07:44

1 Answers1

-2

(Note: I'm self-answering my question)

API v3 is working, consider to migrate from v2 if possible. It will cut down to <1 second (the field title in v2 is called name in v3, and maxResults in v2 is called pageSize in v3):

$ time curl 'https://content.googleapis.com/drive/v3/files?orderBy=folder%2Cname&pageSize=10&q=%27root%27%20in%20parents%20and%20trashed%3Dfalse&key=XXX' --compressed  -H 'Authorization: Bearer XXX' -H 'X-Requested-With: XMLHttpRequest' -H 'X-Origin: https://explorer.apis.google.com'
...
real    0m0.674s
user    0m0.024s
sys     0m0.004s

In v3, you also need specify fields, e.g. (click "Show standard parameters" to expand the field form in "Try-it API explorer"):

files(kind,id,name,size,mimeType,thumbnailLink)

More: Migrate to Google Drive API v3 from Google Drive API v2

林果皞
  • 7,539
  • 3
  • 55
  • 70
  • @DaImTo This suggest migrate to v3 to solve the problem. Did you ever try the request before downvote ? – 林果皞 Nov 27 '17 at 11:20
  • The original question is about Google Drive v2 suggesting v3, isn't going to solve the problem with v2. IMO this doesn't really answer the question. Maybe add it as a coment on the original question – Linda Lawton - DaImTo Nov 27 '17 at 11:50
  • @UrbanEsc I'm self-answering my question. I found the answer before I created this question, since no solution yet in the internet. – 林果皞 Nov 27 '17 at 12:49
  • @DaImTo Migrate to v3 to solve v2 problem is a valid solution even though not the best, but as a developer you have no choice to wait for Google to fix it before publish my app, not to say they may never bother to fix old API. I have a hard time in Youtube API and I knew their styles. – 林果皞 Nov 27 '17 at 12:56
  • I hope you guy understood, 11 seconds delay is unacceptable in user perspective. I must fix it, but should I have to wait forever from Google ? This answer is a workaround to remind you v3 is working, consider to migrate if possible. – 林果皞 Nov 27 '17 at 13:02