Re: BUG #8629: Strange resultset when using CTE or a subselect

From: bricklen <bricklen(at)gmail(dot)com>
To: jonathan(dot)camile(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8629: Strange resultset when using CTE or a subselect
Date: 2013-11-25 17:32:58
Message-ID: CAGrpgQ9m9yQ8bsosVLcpxQHyOuaFid9ZgnmRrqqGig+YoBaf=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Nov 25, 2013 at 2:27 AM, <jonathan(dot)camile(at)gmail(dot)com> wrote:
>
> WITH filtred_table AS (
> SELECT c.id
> FROM my_table t
> WHERE t.enabled = true
> AND (t.hdata->'field')::integer = ANY ('{16788}')
> )
> SELECT my_table.id
> FROM my_table
> WHERE mycontract.id IN (SELECT filtred_table.id FROM filtred_table)
> ORDER BY my_table.hdata->'field' DESC
> LIMIT 5
> OFFSET 5
>

Try with OFFSET 5 LIMIT 5. The offset should be applied *before* the LIMIT.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jonathan Camile 2013-11-25 19:32:45 Re: BUG #8629: Strange resultset when using CTE or a subselect
Previous Message v.langard 2013-11-25 15:56:40 BUG #8630: Planner behavior change between PG 9.0.14 and 9.3.1