Re: why do we need two snapshots per query? - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: why do we need two snapshots per query?
Date
Msg-id m2ehwu7je1.fsf@2ndQuadrant.fr
Whole thread Raw
In response to Re: why do we need two snapshots per query?  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: why do we need two snapshots per query?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Hi,

Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Nov 13, 2011 at 8:57 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> In the -M extended case, we take a snapshot from exec_parse_message(),
>> and the same two in the exec_bind_message() call that are taken in the
>> -M prepared case.  So reducing the prepared case from two snapshots to
>> one will reduce the extended case from three snapshots to two, thus
>> saving one snapshot per query regardless of how it's executed.

I like the idea and I think it's better semantics to use the same
snapshot for planning and executing in the simple query case.

I didn't try to reproduce the performance benefits seen by Robert here,
nor did I tried to double check to compilation warnings etc.  I guess
that reviewing a commiter's patch allows for being not as thorough :)

> +    /* Done with the snapshot used for parameter I/O and parsing/planning */
> +    if (snapshot_set)
> +        PopActiveSnapshot();

This comment needs adjusting.

> diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
> index 466727b..c41272b 100644
> --- a/src/backend/tcop/pquery.c
> +++ b/src/backend/tcop/pquery.c
> @@ -455,7 +455,7 @@ FetchStatementTargetList(Node *stmt)
>   * tupdesc (if any) is known.
>   */
>  void
> -PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
> +PortalStart(Portal portal, ParamListInfo params, bool use_active_snapshot)

You need to be editing the comments for this function.  To be specific
you didn't update this text:
* The caller can optionally pass a snapshot to be used; pass InvalidSnapshot* for the normal behavior of setting a new
snapshot. This parameter is* presently ignored for non-PORTAL_ONE_SELECT portals (it's only intended* to be used for
cursors).

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


pgsql-hackers by date:

Previous
From: Alexander Shulgin
Date:
Subject: Re: Notes on implementing URI syntax for libpq
Next
From: Alexander Shulgin
Date:
Subject: Re: Notes on implementing URI syntax for libpq