Re: Should I create an index for partition with fixed key? - Mailing list pgsql-general

From Sergey Samokhin
Subject Re: Should I create an index for partition with fixed key?
Date
Msg-id e42595410909071321m2b901ff8k9c3fa85c46de164a@mail.gmail.com
Whole thread Raw
In response to Should I create an index for partition with fixed key?  (Sergey Samokhin <prikrutil@gmail.com>)
List pgsql-general
Hello.

> Should I do that if the key will be the same for the whole partition?
> Will there be any benefits of having an index on site_id column?

It looks like there is no any need in index on the site_id column for
partitions.

Here is SQL illustraing DB structure and typical usage (which I should
have listed in the original letter):

CREATE TABLE site ( site_id varchar(50) PRIMARY KEY, descr text);

-- req is a master table
CREATE TABLE req ( site_id varchar(50), timestamp timestamp );

-- now let's create a few child tables

INSERT INTO site (site_id) VALUES ('google_com'); CREATE TABLE
req_google_com ( CHECK (site_id = 'google_com') ) INHERITS (req);

INSERT INTO site (site_id) VALUES ('twitter_com'); CREATE TABLE
req_twitter_com ( CHECK (site_id = 'twitter_com') ) INHERITS (req);

-- and now write some requests:
INSERT INTO req_google_com VALUES ('google_com', now()), ('google_com', now());

--
Sergey Samokhin

pgsql-general by date:

Previous
From: Jerry LeVan
Date:
Subject: Re: More Snow Leopard problems...
Next
From: Alban Hertroys
Date:
Subject: Re: More Snow Leopard problems...