pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Joyce <tim@hoop.co.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] selecting from indexes
Date: Fri, 19 Nov 1999 22:55:48 -0000
Message-ID: <003f01bf32e1$42cee930$0501a8c0@noonoo> (raw)
References: <3610.943049932@sss.pgh.pa.us>



> "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...

bloomsbury=> explain select id from books, books_title_words_idx t where
t.word=
'happy' and t.rec_id = books.id and books.category_key=1471;
NOTICE:  QUERY PLAN:

Hash Join  (cost=43709.86 rows=2817 width=8)
  ->  Index Scan using books_categories_idx on books  (cost=32855.63
rows=293573
 width=4)
  ->  Hash  (cost=733.03 rows=12221 width=4)
        ->  Index Scan using books_title_words_idx_word on
books_title_words_idx
 t  (cost=733.03 rows=12221 width=4)

EXPLAIN

thanks again

timj
>
> regards, tom lane




view thread (7+ messages)

Message-ID: <003f01bf32e1$42cee930$0501a8c0@noonoo>
Permalink:  ../003f01bf32e1$42cee930$0501a8c0@noonoo/
Also on:    postgresql.org/message-id/003f01bf32e1$42cee930$0501a8c0@noonoo

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tim@hoop.co.uk, tgl@sss.pgh.pa.us
  Subject: Re: [SQL] selecting from indexes
  In-Reply-To: <003f01bf32e1$42cee930$0501a8c0@noonoo>
  References: <3610.943049932@sss.pgh.pa.us> <003f01bf32e1$42cee930$0501a8c0@noonoo>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox