Improve speed of the SQL_RESTORATION query

I've seen it taking 1/230 of the time for this query polygon:

MULTIPOLYGON(((2.724609375 42.71473218539458,
               3.2958984375 43.929549935614595,
               4.8779296875 43.77109381775651,
               4.2626953125 42.65012181368025,
               2.724609375 42.71473218539458)))

The patch is intentionally localized, but at a glance other
SQL queries could be modified with the same pattern, basically
unrolling the subquery into filtering directly the cross product.

The patch is untested in its context as I don't know how to test
(hint: "make check" support would be gold ;)
Merge pull request #25 from strk/fast-sql-restoration

Improve speed of the SQL_RESTORATION query