From: | Josh Berkus <josh(at)agliodbs(dot)com> |
---|---|
To: | Matthew Engelbert <mje1975(at)yahoo(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Indexing Strategy |
Date: | 2004-12-10 23:42:18 |
Message-ID: | 200412101542.18353.josh@agliodbs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice pgsql-sql |
Matthew,
> I'm having trouble correctly indexing a large table. The table will be
> receiving about 30 million rows/day, and has the following definition:
>
> CREATE TABLE quote (
> symbol varchar (5),
> price numeric (7,4),
> time timestamp
> );
>
> I need to configure the indices so that I can minimize the time to request
> all the records for a particular symbol, for a particular day, ordered by
> time.
Please post the query you're using. How are you selecting the day? What
version of PostgreSQL are you using?
> I've tried clustering a single index based on symbol, then time, but this
> operation takes much too long. I think this is because this operation
> would have O(N^2) complexity(?).
Nope, just because it's a very large table and you're probably swapping. Try
increasing sort_mem dramatically, like half your RAM.
> I think my next best option would be to
> cluster on an index based on symbol, then have another index on time.
Not that either. You need a multicolumn index. When you answer the above
quesitons, I'll explain it.
> Does any one know of some resources on the web that discusses indexing
> strategies ? Any help would be appreciated? Thanks.
Not that covers your question. I'm writing a book which covers this right
now, but it won't be published until January 2006.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2004-12-11 00:55:42 | Re: Version 8 & column order |
Previous Message | Keith Worthington | 2004-12-10 20:47:19 | can't set sequence |
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Crawford | 2004-12-11 00:10:16 | Re: Cast NULL into Timestamp? |
Previous Message | Muhyiddin A.M Hayat | 2004-12-10 19:26:33 | Create Calendar |