Re: Query started showing wrong result after Ctrl+c

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Query started showing wrong result after Ctrl+c
Date: 2017-10-12 10:16:10
Message-ID: CAL9smLCC32F-f61OZu3nA16sqES-7vbvEvYdcmckBR=mqRisTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 12, 2017 at 12:03 PM, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
wrote:

> postgres=# SELECT * FROM ( SELECT n from tv where n= (select * from
> (select n from tv limit 1) c)) as c ;
> n
> ------
> 3713
> (1 row)
>
> This time , query is started showing wrong result. Is this an expected
> behavior and if yes -then how to get the correct result ?

The subquery:

select n from tv limit 1

could in theory return any row due to the lack of ORDER BY. What I'm
guessing happened is that you're seeing a synchronized sequential scan in
follow-up queries. Add an ORDER BY.

.m

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message tushar 2017-10-12 10:38:23 Re: Query started showing wrong result after Ctrl+c
Previous Message tushar 2017-10-12 10:03:43 Query started showing wrong result after Ctrl+c