pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Linh Luong <linh.luong@computalog.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using indexes
Date: Wed, 30 May 2001 18:57:44 -0400 (EDT)
Message-ID: <200105302257.f4UMviC16759@candle.pha.pa.us> (raw)
In-Reply-To: <3B157646.EABF2998@computalog.com>

Man I am tired of this question.  I have updated the FAQ:


    <P>Indexes are usually not used for <SMALL>ORDER BY</SMALL>
    or joins: a sequential scan followed by an explicit sort is
    faster than an indexscan of all tuples of a large table, because it
    takes fewer disk accesses.</P>                                      


> Hi,
> 
> Indexes are used to find a record faster in a table.
> 
> It only seems to work if I am working with one table.
> eg)
> > create index customer_id_idx on customer(id); 
> > select * from customer where id=1;
> -- This uses the index I create
> 
> However, when I start to join 2 or more tables together it doesn't seem
> to use it.. WHY???
> 
> eg)
> > create index customer_id_idx on customer(id);
> > select * from customer, purchaseorder where customer.id=purchaseorder.id;
> 
> -- This results in a seq scan .. WHY??
> 
> Is there a way to make it so that it uses my index
> 
> Thanks again.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



view thread (4+ messages)

Message-ID: <200105302257.f4UMviC16759@candle.pha.pa.us>
Permalink:  ../200105302257.f4UMviC16759@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200105302257.f4UMviC16759@candle.pha.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pgman@candle.pha.pa.us, linh.luong@computalog.com
  Subject: Re: Using indexes
  In-Reply-To: <200105302257.f4UMviC16759@candle.pha.pa.us>

* 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