Re: Why date index is not used - Mailing list pgsql-performance

From Andrus
Subject Re: Why date index is not used
Date
Msg-id e6bgd5$1vgk$3@news.hub.org
Whole thread Raw
In response to Why date index is not used  ("Andrus" <eetasoft@online.ee>)
List 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.



pgsql-performance by date:

Previous
From: "Andrus"
Date:
Subject: Re: Why date index is not used
Next
From: "Domenico - Sal. F.lli Riva"
Date:
Subject: pgsql_tmp and postgres settings