From: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-performance@postgresql.org
Subject: Re: Why date index is not used
Date: Thu, 08 Jun 2006 21:10:58 +0200
Message-ID: <44887642.2040701@fuzzy.cz> (raw)
In-Reply-To: <e69rq9$2a1b$1@news.hub.org>
References: <e69rq9$2a1b$1@news.hub.org>
If you want to benefit from the usage of an index, the query has to
contain some WHERE conditions (on the indexed columns). This is a
'select all' query - there is no way to speed it up using index.
Tomas
> > Why Postgres 8.1 does not use makse_kuupaev_idx index in the
following query
> > ?
> >
> > How to speed this query up ?
> >
> > explain analyze select * from makse order by kuupaev desc, kellaaeg
desc
> > limit 100
> >
> > "Limit (cost=62907.94..62908.19 rows=100 width=876) (actual
> > time=33699.551..33701.001 rows=100 loops=1)"
> > " -> Sort (cost=62907.94..63040.49 rows=53022 width=876) (actual
> > time=33699.534..33700.129 rows=100 loops=1)"
> > " Sort Key: kuupaev, kellaaeg"
> > " -> Seq Scan on makse (cost=0.00..2717.22 rows=53022
width=876)
> > (actual time=0.020..308.502 rows=53028 loops=1)"
> > "Total runtime: 37857.177 ms"
> >
> >
> > CREATE TABLE makse(
> > kuupaev date,
> > kellaaeg char(6) NOT NULL DEFAULT ''::bpchar,
> > guid char(36) NOT NULL,
> > CONSTRAINT makse_pkey PRIMARY KEY (guid) )
> >
> >
> > CREATE INDEX makse_kuupaev_idx ON makse USING btree (kuupaev);
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tv@fuzzy.cz
Subject: Re: Why date index is not used
In-Reply-To: <44887642.2040701@fuzzy.cz>
* 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