Take a look at this post.

http://groups.google.com/group/objectify-appengine/browse_thread/thread/cc8148ca57ea440c

I had the same problem, and the answer is to use cursors and set a
deadline for yourself that fits within the time you are seeing will
work before the DataStore deadline is reached.  In my case, I had to
limit the use of a cursor to less than 1 minute.  Then start another
query using the cursor and go again.  Rinse and repeat until you are
done.

I hope this helps.

scott

On Jan 13, 8:28 am, "M.W. Aruna Withanage" <[email protected]>
wrote:
> Dear Ian,
> Thank you for your reply.
> I added the line query.setRange(0,10);,but  the same exception is still
> thrown.
> This is my code with the setRange method.
>
> Query query = pm.newQuery(IMCData.class,"this.fldReportDate >= date1
> && this.fldReportDate < date2");
> query.declareParameters("java.util.Date date1,java.util.Date date2");
> query.setRange(0,10);
> try{
>
>                        List<IMCData> names =
> (List<IMCData>)query.execute(d1,d2);
>                        for (IMCData bd : names) {
>
>  resultCustomerNamesMap.put(bd.getFldCustomerName(),
> bd.getFldCustCode());
>
>                            }
>
>                        }
> catch(Exception e){
>
>                        System.out.println("exception in the query
> execution");
>                        e.printStackTrace();
>
>                        }
>
> Please someone help me.
>
> Thanks
> Aruna
>
> On 13 January 2012 10:18, Ian Marshall <[email protected]> wrote:
>
>
>
>
>
>
>
> > With your added line
>
> >  query.setRange(0, 10);
>
> > do you get exactly the same exception?
>
> > I would expect your added line to work if used correctly. What is your
> > code with that line added? Once solved, you might want to use JDO
> > query cursors to step through your potential result set query by
> > query.
>
> > You might also want to look at the JDO object life-cycle. I myself
> > fetch results from a query and then read from the resultant list of
> > objects after having closed the pm. Concepts like object detachment
> > and related settings might be relevant to you here.
>
> > On Jan 13, 11:07 am, deltaaruna <[email protected]> wrote:
> > > Hi all
>
> > > In my local datastore I have about 160000 records and it will go
> > > 400000+ records in future.
> > > But when I try to query the datastore following exception comes
>
> > > com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The
> > > API call datastore_v3.RunQuery() took too long to respond and was
> > > cancelled
>
> > > at com.google.appengine.tools.development.ApiProxyLocalImpl
> > > $1.createDeadlineException(ApiProxyLocalImpl.java:217)
> > >         at
> > > com.google.appengine.tools.development.TimedFuture.get(TimedFuture.java:
> > > 44)
> > >         at
> > > com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> > > 90)
> > >         at
> > > com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:
> > > 90)
> > >         at
>
> > com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.ja 
> > va:
> > > 72)
> > >         at
>
> > com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:
> > > 33)
> > >         at
>
> > com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities( 
> > QueryResultsSourceImpl.java:
> > > 84)
> > >         at
>
> > com.google.appengine.api.datastore.QueryResultIteratorImpl.ensureLoaded(Que 
> > ryResultIteratorImpl.java:
> > > 169)
> > >         at
>
> > com.google.appengine.api.datastore.QueryResultIteratorImpl.nextList(QueryRe 
> > sultIteratorImpl.java:
> > > 115)
> > >         at
>
> > com.google.appengine.api.datastore.LazyList.forceResolveToIndex(LazyList.ja 
> > va:
> > > 107)
> > >         at
> > > com.google.appengine.api.datastore.LazyList.getCursor(LazyList.java:
> > > 344)
> > >         at com.google.appengine.api.datastore.PreparedQueryImpl
> > > $1.get(PreparedQueryImpl.java:62)
> > >         at
>
> > com.google.appengine.api.datastore.QueryResultListImpl.getCursor(QueryResul 
> > tListImpl.java:
> > > 36)
> > >         at
>
> > org.datanucleus.store.appengine.query.DatastoreQuery.fulfillEntityQuery(Dat 
> > astoreQuery.java:
> > > 394)
> > >         at
>
> > org.datanucleus.store.appengine.query.DatastoreQuery.executeQuery(Datastore 
> > Query.java:
> > > 308)
> > >         at
>
> > org.datanucleus.store.appengine.query.DatastoreQuery.performExecute(Datasto 
> > reQuery.java:
> > > 255)
> > >         at
>
> > org.datanucleus.store.appengine.query.JDOQLQuery.performExecute(JDOQLQuery. 
> > java:
> > > 92)
> > >         at
> > org.datanucleus.store.query.Query.executeQuery(Query.java:1489)
> > >         at org.datanucleus.store.query.Query.executeWithArray(Query.java:
> > > 1371)
> > >         at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:266)
> > >         at
>
> > com.imcProject.server.queryServices.GuiServiceImpl.getCustomerNames(GuiServ 
> > iceImpl.java:
> > > 50)
> > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >         at
>
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > 39)
> > >         at
>
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp 
> > l.java:
> > > 25)
> > >         at java.lang.reflect.Method.invoke(Method.java:597)
> > >         at
>
> > com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime 
> > .java:
> > > 100)
> > >         at
> > > com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
> > > 569)
> > >         at
>
> > com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServi 
> > ceServlet.java:
> > > 208)
> > >         at
>
> > com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServi 
> > ceServlet.java:
> > > 248)
> > >         at
>
> > com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(Abstract 
> > RemoteServiceServlet.java:
> > > 62)
> > >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> > >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > >         at
> > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> > > 511)
> > >         at org.mortbay.jetty.servlet.ServletHandler
> > > $CachedChain.doFilter(ServletHandler.java:1166)
> > >         at
>
> > com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(He 
> > aderVerificationFilter.java:
> > > 35)
> > >         at org.mortbay.jetty.servlet.ServletHandler
> > > $CachedChain.doFilter(ServletHandler.java:1157)
> > >         at
>
> > com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFi 
> > lter.java:
> > > 60)
> > >         at org.mortbay.jetty.servlet.ServletHandler
> > > $CachedChain.doFilter(ServletHandler.java:1157)
> > >         at
>
> > com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(Trans 
> > actionCleanupFilter.java:
> > > 43)
> > >         at org.mortbay.jetty.servlet.ServletHandler
> > > $CachedChain.doFilter(ServletHandler.java:1157)
> > >         at
>
> > com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFile 
> > Filter.java:
> > > 122)
> > >         at org.mortbay.jetty.servlet.ServletHandler
> > > $CachedChain.doFilter(ServletHandler.java:1157)
> > >         at
>
> > com.google.appengine.tools.development.BackendServersFilter.doFilter(Backen 
> > dServersFilter.java:
> > > 97)
> > >         at org.mortbay.jetty.servlet.ServletHandler
> > > $CachedChain.doFilter(ServletHandler.java:1157)
> > >         at
> > > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
> > > 388)
> > >         at
> > > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
> > > 216)
> > >         at
> > > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
> > > 182)
> > >         at
> > > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
> > > 765)
> > >         at
> > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> > > 418)
> > >         at
>
> > com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(Dev 
> > AppEngineWebAppContext.java:
> > > 78)
> > >         at
> > > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> > > 152)
> > >         at com.google.appengine.tools.development.JettyContainerService
> > > $ApiProxyHandler.handle(JettyContainerService.java:362)
> > >         at
> > > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> > > 152)
> > >         at org.mortbay.jetty.Server.handle(Server.java:326)
> > >         at
> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> > > 542)
> > >         at org.mortbay.jetty.HttpConnection
> > > $RequestHandler.content(HttpConnection.java:938)
> > >         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
> > >         at
> > org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
> > >         at
> > org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> > >         at
> > > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
> > > 409)
> > >         at org.mortbay.thread.QueuedThreadPool
> > > $PoolThread.run(QueuedThreadPool.java:582)
>
> > > also this is my code.
> > > Query query = pm.newQuery(IMCData.class,"this.fldReportDate >= date1
> > > && this.fldReportDate < date2");
> > > query.declareParameters("java.util.Date date1,java.util.Date date2");
> > > try{
>
> > >                         List<IMCData> names =
> > (List<IMCData>)query.execute(d1,d2);
> > >                         for (IMCData bd : names) {
>
> > resultCustomerNamesMap.put(bd.getFldCustomerName(),
> > > bd.getFldCustCode());
>
> > >                             }
>
> > >                         }
> > > catch(Exception e){
>
> > >                         System.out.println("exception in the query
> > execution");
> > >                         e.printStackTrace();
>
> > >                         }
>
> > > Earlier I I had about 1000 records in datastore at that time the code
> > > was working well. But it is not working now.
> > > I tried to limit the number of results by query.setRange(0, 10);
> > > method but the exception comes again.
> > > Please someone help me. I am in real trouble.
>
> > > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to