[infinispan-dev] Query.getResultSize() to be available on the simplified DSL?

Sanne Grinovero sanne at infinispan.org
Mon Mar 10 08:23:10 EDT 2014


Hi all,
we are exposing a nice feature inherited from the Search engine via
the "simple" DSL version, the one which is also available via Hot Rod:

org.infinispan.query.dsl.Query.getResultSize()

To be fair I hadn't noticed we do expose this, I just noticed after a
recent PR review and I found it surprising.

This method returns the size of the full resultset, disregarding
pagination options; you can imagine it fit for situations like:

   "found 6 million matches, these are the top 20: "

A peculiarity of Hibernate Search is that the total number of matches
is extremely cheap to figure out as it's generally a side effect of
finding the 20 results. Essentially we're just exposing an int value
which was already computed: very cheap, and happens to be useful in
practice.

This is not the case with a SQL statement, in this case you'd have to
craft 2 different SQL statements, often incurring the cost of 2 round
trips to the database. So this getResultSize() is not available on the
Hibernate ORM Query, only on our FullTextQuery extension.

Now my doubt is if it is indeed a wise move to expose this method on
the simplified DSL. Of course some people might find it useful, still
I'm wondering how much we'll be swearing at needing to maintain this
feature vs its usefulness when we'll implement alternative execution
engines to run queries, not least on Map/Reduce based filtering, and
ultimately hybrid strategies.

In case of Map/Reduce I think we'll need to keep track of possible
de-duplication of results, in case of a Teiid integration it might
need a second expensive query; so in this case I'd expect this method
to be lazily evaluated.

Should we rather remove this functionality?

Sanne


More information about the infinispan-dev mailing list