selecting from indexes

From: "Tim Joyce" <tim(at)hoop(dot)co(dot)uk>
To: "bloomsbury development" <bloomsbury_development(at)messageboards(dot)paneris(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: selecting from indexes
Date: 1999-11-19 14:22:24
Message-ID: 003a01bf329d$2db2f3a0$0501a8c0@noonoo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-11-19 15:21:42 Re: [SQL] selecting from indexes
Previous Message Imtiaz. S. M 1999-11-19 11:07:21 Deleting rows with time 55 minutes less than max time