From: | Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Jud Gardner <jgardner(at)comprehend(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #15232: Query execution changes based on using 'explain analyze' or not |
Date: | 2018-06-08 04:06:27 |
Message-ID: | CAEepm=2LXOch6g4790r4Vwa_hL7bmVNHDwxVMdGw18XwkC165w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, Jun 8, 2018 at 1:24 PM, Thomas Munro
<thomas(dot)munro(at)enterprisedb(dot)com> wrote:
> On Fri, Jun 8, 2018 at 5:06 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Jud Gardner <jgardner(at)comprehend(dot)com> writes:
>>> When submitted through psql I don't see the issue.
>>> I also don't see it when submitting via jdbc (42.2.2) directly.
>>
>>> I'm seeing this via jdbc through dbVisualizer, haven't seen this kind of
>>> behavior before.
>>
>> Interesting. It could be that dbVisualizer is setting some parameter
>> or transaction mode that prevents parallelism. SERIALIZABLE mode
>> does so, for example, because the serializable-transaction logic
>> hasn't been taught about parallelism yet.
>
> It plans a parallel query, but it's sending an Execute message with
> max_rows = 1000. That causes PortalRun() to be called with run_once =
> false [...]
The quick fix for dbVisualizer is to type -1 into the "Max Rows" box
in the top right hand corner of the SQL query window.
The execute_once flag came in with commit 691b8d59281b, which added
this logic for 'E' messages:
!execute_is_fetch && max_rows == FETCH_ALL
In JDBC there are two separate concepts, statement.setFetchSize() and
statement.setMaxRows(). The first is for fetching in batches
(implying that you might need to execute more than once) and the
second is for imposing a total row limit (possibly executing only once
and discarding the rest, the case here AFAICT). It doesn't look like
there is any way to tell the difference from our end, because they
both finish up as max_rows in an 'E' message (in our JDBC driver
sendOneQuery() and fetch() both call sendExecute()). So... I don't
see how we could improve this situation without changing the wire
protocol so that the client could state and intention to execute only
once (independently of max_rows). I hadn't looked into that code
before today; maybe someone with more knowledge of the protocol has an
idea.
--
Thomas Munro
http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2018-06-08 04:41:37 | BUG #15234: Connection refused (0x0000274D/10061) - Service will not run? |
Previous Message | Thomas Munro | 2018-06-08 03:09:38 | Re: BUG #15225: [XX000] ERROR: invalid DSA memory alloc request size 1073741824 / Where: parallel worker |