From: Richard Huxton <dev@archonet.com>
To: Greg Stark <gsstark@mit.edu>
Cc: Greg Stark <gsstark@mit.edu>
Cc: pgsql-performance@postgresql.org
Subject: Re: Planner matching constants across tables in a join
Date: Wed, 5 Mar 2003 16:12:09 +0000
Message-ID: <200303051612.09558.dev@archonet.com> (raw)
In-Reply-To: <87llzt97ra.fsf@stark.dyndns.tv>
References: <200303051113.14320.dev@archonet.com>
<200303051424.12351.dev@archonet.com>
<87llzt97ra.fsf@stark.dyndns.tv>
On Wednesday 05 Mar 2003 3:02 pm, Greg Stark wrote:
> Richard Huxton <dev@archonet.com> writes:
> > Filter: ((line_id)::text = '0912345 0004'::text)
>
> So I think this means that line_id is being casted to "text". Though I'm
> not clear why it would be choosing "text" for the constant if line_id
> wasn't text to begin with.
A domain defined as varchar() actually - which is why it's not using an index,
but that's neither here nor there regarding the constant issue.
> In any case my plans here look like:
> > Filter: (aa = 'x'::text)
>
> so it looks like there's something extra going on in your plan.
>
> what does your table definition look like?
rms=> \d campaign
Table "rms.campaign"
Column | Type | Modifiers
----------+-----------+-----------
id | integer | not null
title | item_name |
cam_from | date |
cam_to | date |
owner | integer |
Indexes: campaign_pkey primary key btree (id),
campaign_from_idx btree (cam_from),
campaign_to_idx btree (cam_to)
rms=> \d campaign_items
Table "rms.campaign_items"
Column | Type | Modifiers
-------------+---------+-----------
cam_id | integer | not null
line_id | tel_num | not null
prod_id | integer | not null
chg_per_min | integer |
rev_per_min | integer |
Indexes: campaign_items_pkey primary key btree (cam_id, line_id, prod_id),
cam_item_line_idx btree (line_id)
Foreign Key constraints: $1 FOREIGN KEY (cam_id) REFERENCES campaign(id) ON
UPDATE NO ACTION ON DELETE NO ACTION,
$2 FOREIGN KEY (line_id) REFERENCES line(telno) ON
UPDATE NO ACTION ON DELETE NO ACTION,
$3 FOREIGN KEY (prod_id) REFERENCES product(id) ON
UPDATE NO ACTION ON DELETE NO ACTION
rms=> \d activity
Table "rms.activity"
Column | Type | Modifiers
------------+-----------------------------+-----------
line_id | tel_num | not null
start_time | timestamp without time zone | not null
call_dur | integer |
Indexes: activity_pkey primary key btree (line_id, start_time),
activity_start_idx btree (start_time)
Foreign Key constraints: $1 FOREIGN KEY (line_id) REFERENCES line(telno) ON
UPDATE NO ACTION ON DELETE NO ACTION
--
Richard Huxton
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-performance@postgresql.org
Cc: dev@archonet.com, gsstark@mit.edu
Subject: Re: Planner matching constants across tables in a join
In-Reply-To: <200303051612.09558.dev@archonet.com>
References: <200303051113.14320.dev@archonet.com> <200303051424.12351.dev@archonet.com> <87llzt97ra.fsf@stark.dyndns.tv> <200303051612.09558.dev@archonet.com>
* 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