Re: Index not being used - Mailing list pgsql-general

From Manfred Koizar
Subject Re: Index not being used
Date
Msg-id d572d0hre3nvgbds4nksfk5nn8jj8b6b3k@email.aon.at
Whole thread Raw
In response to Index not being used  (Shane Wegner <shane-keyword-pgsql.a1e0d9@cm.nu>)
Responses Re: Index not being used  (Shane Wegner <shane-keyword-pgsql.a1e0d9@cm.nu>)
List pgsql-general
On Tue, 15 Jun 2004 13:06:40 -0700, Shane Wegner
<shane-keyword-pgsql.a1e0d9@cm.nu> wrote:
>The index I created reads:
>create index books_idx1 on books(publisher_id,place_id,illustrator_id,
>edition_id,type_id,category_id,binding_id,id);

This index is useless, drop it.  Is there an index on books(id)?

>The other ids in the joining tables are all serial values
>and are primary keys so are indexed automatically.
>
>explain analyze output: [lots of seq scans and hash joins]

Try

    EXPLAIN ANALYSE
    SELECT *
      FROM orders_and_books AS o
          INNER JOIN books AS b ON o.book_id = b.id
     WHERE o.order_id = 753;

This should give a nested loop using primary key index scans on both
tables.  Then add

      LEFT JOIN publishers ON publisher_id=publishers.id
      LEFT JOIN places ON place_id=places.id
      ...

one by one until the plan changes to hash joins again and show us the
results.

Servus
 Manfred

pgsql-general by date:

Previous
From: mike.griffin@mygenerationsoftware.com
Date:
Subject: 7.4's INFORMATION_SCHEMA.Columns View
Next
From: "zuhans@iname.com"
Date:
Subject: Re: why no answer? [Fwd: backup and restore just with use