Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres Indexing?

I am a newbie in postgres. I have a column named host (string varchar2) in a table which has around 20 million rows. How do I use indexing to optimize my search to find particular host. Also, this column will be updated daily do I need to write trigger indexing at particular interval? If yes, how do I do that? (For Records I am using Ruby and Rails 3)

like image 775
Bhushan Lodha Avatar asked Jan 19 '12 07:01

Bhushan Lodha


1 Answers

Assuming you're doing exact matches, you should just be able to create the index and leave it:

CREATE INDEX host_index ON table_name (host)

The query optimizer should just use that automatically.

You may wish to specify other options such as the collation to use.

See the PostgreSQL docs for CREATE INDEX for more information.

like image 102
Jon Skeet Avatar answered Oct 10 '22 23:10

Jon Skeet