On 11/12/13 19:37, Charles Li wrote:
Thanks, Rob! Sounded like adding "limit 1" won't hurt.

It won't hurt -- the LIMIT operator is very cheap and as Rob syas thingas are streaming whereever possible so LIMIT is just terminate stream but if the stream is at the end anyway, that's a no-op.

If there is only one answer without LIMIT, then the main optimization (TopN queries LIMIT + ORDER BY) is not affected in any material way. Sorting one item whether by mergesort or a top N buffer is not exactly very costly.

        Andy

On Dec 11, 2013 11:27 AM, "Rob Vesse" <[email protected]> wrote:

Hard to say without seeing a complete example query

The ARQ query engine which TDB uses streams results wherever possible so
if there is only one results in principal adding LIMIT 1 won't change much.

That being said there are certain query optimisations that require a LIMIT
to be present so depending on the query adding the LIMIT 1 may result in a
different query plan which may be marginally more efficient.

Rob

On 11/12/2013 17:51, "Charles Li" <[email protected]> wrote:

Hi, everyone!

I have a sparql query running by Jena code (2.10.1) against a TDB store.
If
I know for sure the query will always return one record, will the use of
"limit 1" in the query string improve performance statistically?

Thanks!







Reply via email to