[EMAIL PROTECTED] wrote:
Stephen Toney <[EMAIL PROTECTED]> wrote:
select count(*) from keyword a, keyword b where a.key=b.key and
a.value='music' and b.value='history';

4,318 records have value='music' and 27,058 have value='history'. The
keys are 12-byte strings. That doesn't seem like an extreme case to
me.


The result should be 116,836,444.
A faster approach would be:

   SELECT (SELECT count(*) FROM keyword WHERE value='music')*
          (SELECT count(*) FROM keyword WHERE value='history');

You seem to be overlooking a.key=b.key condition.

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to