Re: Synchronized scans - Mailing list pgsql-patches

From Tom Lane
Subject Re: Synchronized scans
Date
Msg-id 24268.1180989723@sss.pgh.pa.us
Whole thread Raw
In response to Re: Synchronized scans  (Heikki Linnakangas <heikki@enterprisedb.com>)
Responses Re: Synchronized scans  (Heikki Linnakangas <heikki@enterprisedb.com>)
Re: Synchronized scans  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-patches
Heikki Linnakangas <heikki@enterprisedb.com> writes:
> I don't think anyone can reasonably expect to get the same ordering when
> the same query issued twice in general, but within the same transaction
> it wouldn't be that unreasonable. If we care about that, we could keep
> track of starting locations per transaction, only do the synchronization
> on the first scan in a transaction, and start subsequent scans from the
> same page as the first one.

I think the real problem here is that the first scan is leaving state
behind that changes the behavior of the next scan.  Which can have no
positive benefit, since obviously the first scan is not still
proceeding; the best you can hope for is that it's a no-op and the worst
case is that it actively pessimizes things.  Why doesn't the patch
remove the shmem entry at scan termination?

> I think the warning on LIMIT without ORDER BY is a good idea, regardless
> of the synchronized scans patch.

I seriously doubt that can be done in any way that doesn't both warn
about perfectly-safe cases and fail to warn about other unsafe ones.
Furthermore, it's not uncommon for people to do "SELECT * ... LIMIT 1"
just to remind themselves of column names or whatever.  Do we really
want the thing to be so nannyish?  I was envisioning simply a stronger
warning in the SELECT reference page ...

            regards, tom lane

pgsql-patches by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Synchronized scans
Next
From: Heikki Linnakangas
Date:
Subject: Re: Synchronized scans