Re: getting ERROR: stack depth limit exceeded on a WHERE IN query on a view

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Aditya Rastogi <adirastogi(at)outlook(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: getting ERROR: stack depth limit exceeded on a WHERE IN query on a view
Date: 2014-02-24 16:40:06
Message-ID: 2754.1393260006@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Aditya Rastogi <adirastogi(at)outlook(dot)com> writes:
> The query is similar to the following query:
> select count(*) from gui_die_summary where (x_coord, y_coord) in ((25,5),(41,13),(25,7),(28,3),(25,8),(34,7),(26,6),(21,10)); ,
> only that the list of pairs specified in the in clause is pretty large - around 5000-4000 pairs and that's when I get the stack depth limit exceed error.

Even without the stack depth issue, that would perform pretty horridly for
so many pairs.

Do you know that the pairs are all distinct, so that you don't really need
the duplicate-elimination behavior of IN? If so, you could recast this
like so:

select count(*) from
gui_die_summary,
(values (25,5),(41,13),(25,7),(28,3),(25,8),(34,7),(26,6),(21,10)) v(vx,vy)
where (x_coord, y_coord) = (vx, vy);

which should work better for large numbers of pairs.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Aditya Rastogi 2014-02-24 17:39:04 Re: getting ERROR: stack depth limit exceeded on a WHERE IN query on a view
Previous Message Aditya Rastogi 2014-02-24 06:51:58 getting ERROR: stack depth limit exceeded on a WHERE IN query on a view