Re: How does Index Scan get used - Mailing list pgsql-general

From Luis Amigo
Subject Re: How does Index Scan get used
Date
Msg-id 3C767A25.78D224AA@atc.unican.es
Whole thread Raw
In response to Re: How does Index Scan get used  (Holger Marzen <holger@marzen.de>)
List pgsql-general
 
> >
> > create table test (test_col text);
> > create index test_index on test (test_col);
> > insert into test values ('abc.xyz');
> > insert into test values ('abcxyz');
> > insert into test values ('abc/xyz');
> >
 
First of all when you create an index u must specify what kind of ops will use that index, in this case create index test_index on test (test_col , text_ops)
Second, a index only will be used if there is an advantage on using it, in this case, u have 3 unique values, unless random-page cost is lower than 3, planner would not use it.
Third of all, if u want to learn how to use indexes, try numeric values first, because indexing texts is a bit more difficult.
Attachment

pgsql-general by date:

Previous
From: "Samuel J. Sutjiono"
Date:
Subject: Regular Expression for 'and' instead of 'or'
Next
From: Jean-Luc Lachance
Date:
Subject: Re: environment variables, output format & setting current