Optimizing perfomance using indexes

From: Vladimir Litovka <pgsqll(at)barnet(dot)kharkov(dot)ua>
To: PgSQL-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Optimizing perfomance using indexes
Date: 1998-10-15 12:35:53
Message-ID: Pine.LNX.4.03.9810151528040.23894-100000@barnet.kharkov.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Hello!

There are examples below and can anybody explain me - how to use indexes
in PostgreSQL for best perfomance? Look here:

create table aaa (num int2, name text);
create index ax on aaa (num);

explain select * from aaa where num = 5;
Index Scan on aaa (cost=0.00 size=0 width=14)

explain select * from aaa where num > 5;
Seq Scan on aaa (cost=0.00 size=0 width=14)

Why PostgreSQL in the first case uses index, but in the second - doesn't ?
As I understand, there is no big difference between queries. Are there
general recommendations on creating indexes?

This questions because I'm relatively new to SQL and hope somebody can
help me :) Thank you.

---
Vladimir Litovka <doka(at)webest(dot)com>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Zeugswetter 1998-10-15 12:37:49 AW: [HACKERS] PostgreSQL v6.4 BETA2...
Previous Message Jan Wieck 1998-10-15 12:23:43 Re: [HACKERS] What about LIMIT in SELECT ?

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Good 1998-10-15 12:37:53 Re: [SQL] Using the IN predicate in an UPDATE...
Previous Message Michael Shields 1998-10-15 07:35:35 Re: [SQL] dilemma