From: Tim Joyce <tim@hoop.co.uk>
To: bloomsbury development <bloomsbury_development@messageboards.paneris.org>
To: pgsql-sql@postgresql.org
Subject: selecting from indexes
Date: Fri, 19 Nov 1999 14:22:24 -0000
Message-ID: <003a01bf329d$2db2f3a0$0501a8c0@noonoo> (raw)
Hi,
I am trying to improve search times on a moderately large table (approx 1
GB).
I have noticed that clustering the data improves performance significantly,
but is a bit of a pain especially with dynamic data.
What I would like to do is select data direct from the index and not have to
go back to the table itself each time.
eg, my query is:
SELECT id FROM books WHERE category_key = 1471;
(this takes ages on a table not ordered by category_key even if I have an
index on category_key)
If I created an index:
CREATE INDEX books_category_id ON books(category_key,id);
and then run the above query, it has no need to go to the books table to
retrieve the id, and should be fast. But it appears that it still does
access the books table.
I have tried
SELECT id FROM books_category_id WHERE category_key = 1471;
but you can't select from an index :(
Another option would be to do the clustering using a view, but:
create view books_category as select id,category from books order by
category;
ERROR: Order by and Distinct on views is not implemented.
Does anyone know when this will be implemented?
Has anyone got any better ideas, or shall I just do static clustering once
in a while?
Thanks for any advice.
Cheers
Tim Joyce
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tim@hoop.co.uk, bloomsbury_development@messageboards.paneris.org
Subject: Re: selecting from indexes
In-Reply-To: <003a01bf329d$2db2f3a0$0501a8c0@noonoo>
References: <003a01bf329d$2db2f3a0$0501a8c0@noonoo>
* 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