Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA78924 for ; Fri, 19 Nov 1999 17:19:54 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id RAA03612; Fri, 19 Nov 1999 17:18:52 -0500 (EST) To: "Tim Joyce" cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] selecting from indexes In-reply-to: Your message of Fri, 19 Nov 1999 20:06:34 -0000 <000201bf32d3$28805310$0501a8c0@noonoo> Date: Fri, 19 Nov 1999 17:18:52 -0500 Message-ID: <3610.943049932@sss.pgh.pa.us> From: Tom Lane "Tim Joyce" 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