Re: Why date index is not used

From: "Andrus" <eetasoft(at)online(dot)ee>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Why date index is not used
Date: 2006-06-09 09:52:21
Message-ID: e6bgd5$1vgk$3@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Tom,

> Because it doesn't help --- the system still has to do the sort.

It can help a lot in this case.

kuupaev is sales date
kellaaeg is sales time

Postgres can use kuupaev index to fetch first 100 rows plus a number of more
rows whose kellaaeg value is equal to kellaaeg in 100 th row. I have 500
sales per day.
So it can fetch 600 rows using index on kuupaev column.

After that it can sort those 600 rows fast.
Currently it sorts blindly all 54000 rows in table.

> You'd need a two-column index on both of the ORDER BY columns to avoid
> sorting.

Thank you. It works.

Andrus.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Domenico - Sal. F.lli Riva 2006-06-09 12:23:04 pgsql_tmp and postgres settings
Previous Message Andrus 2006-06-09 09:40:26 Re: Why date index is not used