pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Using Indexes
4+ messages / 4 participants
[nested] [flat]

* Using Indexes
@ 1999-07-13 05:10 Mr. Poet <poet@linuxports.com>
  1999-07-13 05:53 ` Re: [SQL] Using Indexes Chris Bitmead <chris@tech.com.au>
  0 siblings, 1 reply; 4+ messages in thread

From: Mr. Poet @ 1999-07-13 05:10 UTC (permalink / raw)
  To: pgsql-sql@hub.org

Hello,

I know how to create and index... but how do I use it?
From my old xbase days it was use <index> but that doesn't work 
in postgres... help?

{poet}
   --poet@linuxports.com--ICQ: 33017215 
      --http://www.linuxports.com-- 
Author: Consultants, Commercial, VAR Howto
  Visit the LDP: http://www.linuxdoc.org



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] Using Indexes
  1999-07-13 05:10 Using Indexes Mr. Poet <poet@linuxports.com>
@ 1999-07-13 05:53 ` Chris Bitmead <chris@tech.com.au>
  0 siblings, 0 replies; 4+ messages in thread

From: Chris Bitmead @ 1999-07-13 05:53 UTC (permalink / raw)
  To: poet@linuxports.com; +Cc: pgsql-sql@hub.org

"Mr. Poet" wrote:
> 
> Hello,
> 
> I know how to create and index... but how do I use it?
> >From my old xbase days it was use <index> but that doesn't work
> in postgres... help?

Indexes are used automatically when the database thinks it will speed a
particular query.

I don't know what <index> did in xbase. Did it order things? If you want
ordering see the sql ORDER BY clause.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Using indexes
@ 2001-05-30 22:37 Linh Luong <linh.luong@computalog.com>
  2001-05-30 22:57 ` Re: Using indexes Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Linh Luong @ 2001-05-30 22:37 UTC (permalink / raw)
  To: pgsql-sql

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.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Using indexes
  2001-05-30 22:37 Using indexes Linh Luong <linh.luong@computalog.com>
@ 2001-05-30 22:57 ` Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2001-05-30 22:57 UTC (permalink / raw)
  To: Linh Luong <linh.luong@computalog.com>; +Cc: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-05-30 22:57 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-07-13 05:10 Using Indexes Mr. Poet <poet@linuxports.com>
1999-07-13 05:53 ` Chris Bitmead <chris@tech.com.au>
2001-05-30 22:37 Using indexes Linh Luong <linh.luong@computalog.com>
2001-05-30 22:57 ` Re: Using indexes Bruce Momjian <pgman@candle.pha.pa.us>

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