From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Greg Stark <gsstark(at)mit(dot)edu> |
Cc: | Greg Stark <gsstark(at)mit(dot)edu>, <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Planner matching constants across tables in a join |
Date: | 2003-03-05 16:12:09 |
Message-ID: | 200303051612.09558.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Wednesday 05 Mar 2003 3:02 pm, Greg Stark wrote:
> Richard Huxton <dev(at)archonet(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2003-03-05 19:00:23 | Re: Planner matching constants across tables in a |
Previous Message | Tom Lane | 2003-03-05 15:20:40 | Re: OIDs as keys |