From: | "Ian Cass" <ian(dot)cass(at)mblox(dot)com> |
---|---|
To: | "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: JOINS and non use of indexes |
Date: | 2002-04-08 14:41:48 |
Message-ID: | 00c401c1df0b$893ee7c0$6602a8c0@salamander |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
You're right. But I do this....
my $sql = "create table messages_$month () inherits (messages)";
...
my $sql = "create unique index messages_" . $month . "_ix1 on
messages_$month using btree (host, qos_id)";
...
my $sql = "create index messages_" . $month . "_ix2 on messages_$month using
btree (client_id, user_name)";
...
Similar thing for my statusinds tables too.
--
Ian Cass
----- Original Message -----
From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Ian Cass" <ian(dot)cass(at)mblox(dot)com>; <pgsql-sql(at)postgresql(dot)org>
Sent: Monday, April 08, 2002 3:33 PM
Subject: Re: [SQL] JOINS and non use of indexes
> I haven't had a good look, but just remember that indexes on a table in
> postgres are NOT inherited by its children. You cannot define a unique
> index over a column that is inherited - it will be unique for the table
you
> define it on only. Hence, you may not actually have indexes on those
> inherited tables, and therefore they cannot be used...
>
> Chris
>
> > Explain plan....
> > Limit (cost=0.00..35.06 rows=5 width=620)
> > -> Nested Loop (cost=0.00..30986063.51 rows=4418898 width=620)
> > -> Append (cost=0.00..441.93 rows=111 width=496)
> > -> Seq Scan on messages (cost=0.00..0.00 rows=1 width=496)
> > -> Index Scan using messages_200203_ix2 on messages_200203 messages
> > (cost=0.00..272.61 rows=68 width=383)
> > -> Index Scan using messages_200204_ix2 on messages_200204 messages
> > (cost=0.00..169.32 rows=42 width=384)
> > -> Append (cost=0.00..180413.11 rows=7996912 width=124)
> > -> Seq Scan on statusinds (cost=0.00..0.00 rows=1 width=124)
> > -> Seq Scan on statusinds_200203 statusinds (cost=0.00..142835.73
> > rows=6292073 width=71)
> > -> Seq Scan on statusinds_200204 statusinds (cost=0.00..37577.38
> > rows=1704838 width=65)
> >
> > (tables_YYYYMM are inherited)
> >
> > --
> > Ian Cass
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-04-08 14:46:08 | Re: JOINS and non use of indexes |
Previous Message | Christopher Kings-Lynne | 2002-04-08 14:33:15 | Re: JOINS and non use of indexes |