"Tim Joyce" <tim@hoop.co.uk> writes:
>>>> select id from books, book_words where book_words.word='happy' and
>>>> book_words.id = books.id and books.category_key=1471;
>>
>> If this is what you're really doing, I think what you actually want is
>> indexes on book_words.word and books.id.
> I have indexes on both of these.
Hmm. So the question is why the system is (apparently) doing an
indexscan on category_key rather than on id. You didn't show us
the EXPLAIN output...
regards, tom lane