Constructing query result iterator takes as long as the query execution itself
Hi all, When using the QueryProcessor to execute a query, then, constructing an iterator from the Result object takes almost as long as the query execution itself. For example, if QueryProcessor.execute() consumes 100 ms, then Result.iter() takes an additional 75%. Same with Result.value().
Is there something I can boost up?
Thanks!
Erdal
Hi Erdal,
execution times are generally highly dependent on the queries you are working with, but in the given case, you may get better performance by directly calling QueryProcessor.iter() instead of QueryProcessor.execute(). Btw, I’m not sure where to find the Result.iter() function? Do you refer to QueryProcessor.iter() ?
Christian ___________________________
2013/10/11 Erdal Karaca <erdal.karaca.de at gmail.com>:
Quoted text · Erdal Karaca · 18 lines
> Hi all, > When using the QueryProcessor to execute a query, then, constructing an > iterator from the Result object takes almost as long as the query execution > itself. > For example, if QueryProcessor.execute() consumes 100 ms, then Result.iter() > takes an additional 75%. Same with Result.value(). > > Is there something I can boost up? > > Thanks! > > Erdal > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Hi Christian, Thanks! You are right, I mean QueryProcessor.iter().
So, calling QueryProcessor.execute() AND after that calling QueryProcessor.iter/value() does the work twice? I.e., to get the result, I do not need to execute() the query, but instead directly call QueryProcessor.iter() or QueryProcessor.value()?
2013/10/11 Christian Grün <christian.gruen at gmail.com>
Quoted text · Christian Grün · 33 lines
> Hi Erdal, > > execution times are generally highly dependent on the queries you are > working with, but in the given case, you may get better performance by > directly calling QueryProcessor.iter() instead of > QueryProcessor.execute(). Btw, I’m not sure where to find the > Result.iter() function? Do you refer to QueryProcessor.iter() ? > > Christian > ___________________________ > > 2013/10/11 Erdal Karaca <erdal.karaca.de at gmail.com>: > > Hi all, > > When using the QueryProcessor to execute a query, then, constructing an > > iterator from the Result object takes almost as long as the query > execution > > itself. > > For example, if QueryProcessor.execute() consumes 100 ms, then > Result.iter() > > takes an additional 75%. Same with Result.value(). > > > > Is there something I can boost up? > > > > Thanks! > > > > Erdal > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > >
Quoted text · Erdal Karaca · 4 lines
> So, calling QueryProcessor.execute() AND after that calling > QueryProcessor.iter/value() does the work twice? > I.e., to get the result, I do not need to execute() the query, but instead > directly call QueryProcessor.iter() or QueryProcessor.value()?
Well, yes… Just try ;)
Yes, I tried, but couldn't believe it :-) Just thought of JDBC Connections, where you first execute a statement, then call the getResult() method. With directly calling QueryProcessor.value(), I have just halved the execution time of a query (10 sec to 5 sec, for example).
Thanks!
2013/10/11 Christian Grün <christian.gruen at gmail.com>
Quoted text · Christian Grün · 8 lines
> > So, calling QueryProcessor.execute() AND after that calling > > QueryProcessor.iter/value() does the work twice? > > I.e., to get the result, I do not need to execute() the query, but > instead > > directly call QueryProcessor.iter() or QueryProcessor.value()? > > Well, yes… Just try ;) >
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.