pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Clayton Cottingham <drfrog@smartt.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] quest:optimization with indexes
Date: Wed, 11 Aug 1999 16:30:13 +0300
Message-ID: <l03130302b3d727c777c5@[147.233.159.109]> (raw)
In-Reply-To: <37B0AAE0.926AE58D@smartt.com>

At 01:42 +0300 on 11/08/1999, Clayton Cottingham wrote:


> if we put in an index or not an explain say it still does a seq scan,
> same amount of time taken!
>
> ive tried putting the index using just the oid , a combo of some fields
> of our data using btree
>
> where/what rules should be followed for setting up a good indexing
> scheme under pg?

You should put indices on the fields mentioned in your query's WHERE clause.

You should try and avoid using functions on the fields in a WHERE clause.
For example, even if you have an index on the field "surname" in your
table, a query with WHERE upper( surname ) = "SMITH" will not use that
index. You can define indices on the function upper(surname) if this sort
of query is common.

The same goes for operators such as LIKE. LIKE will only use the index if
the expression is anchored to the beginning of the string, as in WHERE
surname LIKE 'Smi%', but not WHERE surname LIKE '%mit%'.

And always keep in mind that adding indices penalizes you on insert and update.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (7+ messages)  latest in thread

Message-ID: <l03130302b3d727c777c5@[147.233.159.109]>
Permalink:  ../l03130302b3d727c777c5@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130302b3d727c777c5@[147.233.159.109]

 · 

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: herouth@oumail.openu.ac.il, drfrog@smartt.com
  Subject: Re: [SQL] quest:optimization with indexes
  In-Reply-To: <l03130302b3d727c777c5@[147.233.159.109]>
  References: <37B0AAE0.926AE58D@smartt.com> <l03130302b3d727c777c5@[147.233.159.109]>

* 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