Bug fix for issue #681
Merge pull request #682 from linas/sql

Bug fix for issue #681
Attempted fix for bug #680

Kind of annoying to fix it this way, but it seems to be needed.
Optimization for where to start a search.

Starting the pattern match search at the wrong spot can lead to horrible
performance.  So this is one possible optimization.
Another search starting point optimization

Explisitly look for the constant with the skinniest
incoming set.  This should sharply narrow down the
search space.
Fix a mis-design in the previous commit

It really should look for the thnnest, not the deepest constant.
Preliminary cleanup, for search start point.

The next commits will re-order the clauses so that a more
efficient search can be performed. To do this, these cannot be const.
Reorder clauses to find best start point.

Loop over all the clauses, finding the one with the thinnest
incoming set, and start the search there.  This should help
performance a lot.
Clauses do not acutally have to be reordered

There is nothing special about the first clause. The
get_next_untried_clause() method does the heavy joining.
iAdd a note for future work.
Merge pull request #683 from linas/qry

Query performance optimization
Oops - remove pointless indent

Previous work left behind some grunge .. a pointless
indent in the code. Remove it.
Typoes from previous commits