kasei/perlrdf — pull request #52 by kjetilk (2012-03-15 13:39:10+00:00)
Title: Possible optimization for zero-match BGPs

Hi!

I've been thinking a bit about a very simple "zero-one-many" selectivity estimation system.

The optimization is basically that there are three special cases, one of them is that if any of the triples in a BGP has no matches, the whole BGP has no matches, and thus we should jump out as quickly as possible. So, I looked into the default get_pattern, and I hope that this patch actually does that. It still passes all tests...

Since calling a subroutine in Perl is an expensive operation, and constructing a new object is even more expensive, so, I would think it would be good if you could jump out before calling RDF::Trine::Iterator::Bindings->new, but I guess that would break things (even though no tests failed with this either). Anyway, I guess it might be that there is something in the code that takes care of this situation, but I figured I'd send a patch just in case it hasn't been on your radar. :-)

(the other two special cases, is that the it is a common case that a triple has only one match, and therefore very low selectivity, lower than any other, often that's all a BGP optimizer would need to know, but that's a problem for $later)