Re: [HACKERS] "internal error" triggered by EXISTS()

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Cc: pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] "internal error" triggered by EXISTS()
Date: 1998-07-15 02:45:30
Message-ID: 199807150245.WAA02896@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We only support subqueries in the target list. May have that expaned
for 6.4.

> I tried the following to find out whether a table has any records
> with field1 < X (for a constant X):
>
> tgl=> SELECT EXISTS(SELECT * FROM table WHERE field1 < X);
> ERROR: internal error: do not know how to transform targetlist
>
> Is this a bug? (I'm using development sources from yesterday.)
>
> Am I using EXISTS() incorrectly? The examples I've been able to find
> only show it as a part of a WHERE clause.
>
> If it did work, would it be any faster than a table scan? The code
> I was hoping to replace is like this:
> SELECT COUNT(field1) WHERE field1 < X;
> // test whether result > 0
> Since aggregates aren't optimized very well, this ends up reading
> much or all of the table, even if there is an index for field1.
> I was hoping EXISTS() might be smarter...
>
> regards, tom lane
>
>

--
Bruce Momjian | 830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dirk Elmendorf 1998-07-15 03:02:24 FW: MaxQuery Plan
Previous Message Vadim Mikheev 1998-07-15 02:41:09 Re: [HACKERS] "internal error" triggered by EXISTS()