Skip site navigation (1) Skip section navigation (2)

Re: [SQL] could not devise a query plan

From: Szűcs Gábor <surrano(at)gmail(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>,"pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [SQL] could not devise a query plan
Date: 2005-05-24 11:55:21
Message-ID: 42931629.6030103@gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-sql
Dear Gnanavel,

(please reply to the lists...)

Indeed it works!

Still, I think it's a bug.

As for this solution being a workaround, it's a bit of pain, since the 
subselect names (effectively, the included subselects) are not constant.

As for my workaround, I used a condition to not include the last WHERE 
clause in the query when the inner WHERE clauses are present (since it does 
nothing).

--
G.


On 2005.05.24. 13:14, Gnanavel Shanmugam wrote:
> replace
>  WHERE a+b = 3;
> with
>  WHERE aa.a+aa.b = 3;
> 
> (or)
>  WHERE bb.a+bb.b = 3;
> 
> 
> with regards,
> S.Gnanavel
> 
> 
> 
>>-----Original Message-----
>>From: surrano(at)gmail(dot)com
>>Sent: Tue, 24 May 2005 12:39:04 +0200
>>To: pgsql-bugs(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
>>Subject: Re: [SQL] could not devise a query plan
>>
>>Dear Gurus,
>>
>>Sorry for upping a 13-month-old thread; please tell if I should've opened
>>another one.
>>
>>Here I come again, with another silly join. Please forgive me, but our
>>queries are built from blocks :)
>>
>>VERSION: 7.4.6, 7.4.8, 8.0.0rc4 (sorry, no newer installed right now)
>>
>>ABSTRACT: The following query fails.
>>
>>	SELECT * FROM
>>	  (SELECT a,b FROM cdqp WHERE a=1 AND b=2) AS aa
>>	  NATURAL FULL JOIN
>>	  (SELECT a,b FROM cdqp WHERE a=1 and b=2) AS bb
>>	WHERE a+b = 3;
>>
>>DETAILS: It seems it's something about the redundant WHERE clauses. If I
>>comment (replace with "WHERE true") any of the three WHERE clauses, it
>>works.
>>
>>Session log: See below.
>>
>>TIA,
>>
>>--
>>G.
>>
>>
>>serv1:tir=> \d cdqp
>>    Table "pg_temp_20.cdqp"
>>  Column |  Type   | Modifiers
>>--------+---------+-----------
>>  a      | integer |
>>  b      | integer |
>>
>>serv1:tir=> SELECT * FROM
>>serv1:tir->   (SELECT a,b FROM cdqp WHERE a=1 AND b=2) AS aa
>>serv1:tir->   NATURAL FULL JOIN
>>serv1:tir->   (SELECT a,b FROM cdqp WHERE a=1 and b=2) AS bb
>>serv1:tir-> WHERE a+b = 3;
>>ERROR:  could not devise a query plan for the given query
>>serv1:tir=> SELECT * FROM
>>serv1:tir->   (SELECT a,b FROM cdqp WHERE a=1 AND b=2) AS aa
>>serv1:tir->   NATURAL FULL JOIN
>>serv1:tir->   (SELECT a,b FROM cdqp WHERE a=1 and b=2) AS bb
>>serv1:tir-> WHERE true;
>>  a | b
>>---+---
>>  1 | 2
>>(1 row)
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 9: the planner will ignore your desire to choose an index scan if
>>your
>>      joining column's datatypes do not match

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2005-05-24 14:14:54
Subject: Re: BUG #1671: Long interval string representation rejected
Previous:From: Szűcs GáborDate: 2005-05-24 10:39:04
Subject: Re: could not devise a query plan

pgsql-sql by date

Next:From: Richard HuxtonDate: 2005-05-24 11:59:23
Subject: Re: Transaction in plpgslq
Previous:From: Jan B.Date: 2005-05-24 11:00:36
Subject: Re: Transaction in plpgslq

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group