Nathan Kurz <[EMAIL PROTECTED]> wrote:
>
> SELECT uid, match("complex", "function", vector) AS match FROM vectors
> ORDER BY match DESC LIMIT 20;
SELECT uid, mx FROM
(SELECT uid, match(...) AS mx FROM vectors LIMIT -1)
ORDER BY mx DESC LIMIT 20;
The LIMIT -1 on the subquery is to fake out the optimizer and prevent
it from folding the subquery back into the main query, resulting in the
same statement you started with. A "LIMIT -1" is effectively a no-op.
It does no limiting. But subqueries that contain a limit will not be
folded into outer queries that also contain a limit.
>
> And in case it bolsters my case, here's the EXPLAIN output I see:
>
> sqlite> EXPLAIN SELECT uid, match("complex", "function", vector) AS match
> ...> FROM vectors ORDER BY match DESC LIMIT 20;
Hint: The output of EXPLAIN is much easier to read if you do ".explain"
first to set up the output formatting.
--
D. Richard Hipp <[EMAIL PROTECTED]>