Re: Query started showing wrong result after Ctrl+c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
Cc: Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Query started showing wrong result after Ctrl+c
Date: 2017-10-12 14:14:17
Message-ID: 31577.1507817657@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

tushar <tushar(dot)ahuja(at)enterprisedb(dot)com> writes:
> On 10/12/2017 03:46 PM, Marko Tiikkaja wrote:
>> 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.

> Bang on . After adding order by clause - i am getting same result
> consistently. but why i got the  different result after canceling the
> query only?

If you let the query run to completion, the syncscan start pointer will
return to the start of the table. Cancelling it partway through allows
the syncscan pointer to be left pointing somewhere in the middle of the
table.

If you turn off synchronize_seqscans, you should find that you always
get the physically-first table row from that subselect.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2017-10-12 14:27:15 Re: Discussion on missing optimizations
Previous Message Robert Haas 2017-10-12 14:06:44 Re: Discussion on missing optimizations