Re: COALESCE implementation question

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: pgsql-hackers(at)hub(dot)org
Subject: Re: COALESCE implementation question
Date: 2000-08-05 08:17:11
Message-ID: 3.0.5.32.20000805181711.01e4a3a0@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 17:22 5/08/00 +1000, Philip Warner wrote:
>P.S. What's worse, I should have mentioned that the plan *with* indexes
>seems flawed:
>
>Create Table t1(f1 int);
>Create Table t1(f1 int, f2 int);
>Create Unique Index t2f1 on t2(f1);
>Create Unique Index t2f2 on t2(f2);
>
>explain update t1 set f1 = Coalesce( (select f2 from t2 x where x.f1 =
>t1.f1), t1.f1);
>NOTICE: QUERY PLAN:
>
>Seq Scan on t1 (cost=0.00..20.00 rows=1000 width=10)
> SubPlan
> -> Index Scan using t2f1 on t2 x (cost=0.00..8.14 rows=10 width=4)
> -> Seq Scan on t2 x (cost=0.00..22.50 rows=1000 width=4)
>

Oddly enough, I now think that the EXPLAIN output is a lie; it seems that
it never does a sequential scan. So I am now even more confused...

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.C.N. 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-08-06 01:54:27 Re: comparing rows
Previous Message Philip Warner 2000-08-05 07:22:50 Re: COALESCE implementation question