why do we need two snapshots per query?
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2011-11-11T14:07:33Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix copyright notices, other minor editing in new range-types code.
- f1585362856d 9.2.0 cited
-
Redesign the plancache mechanism for more flexibility and efficiency.
- e6faf910d750 9.2.0 cited
I noticed while playing around this morning that, in read committed mode, the following query - or any other straightforward query - calls GetSnapshotData() twice: SELECT 1; What happens is this: exec_simple_query() calls analyze_requires_snapshot() on the query. Since the query is a SELECT, this returns true, whereupon exec_simple_query() takes a snapshot for parse analysis / planning. It then plans the query and releases the snapshot. exec_simple_query() then calls CreatePortal(), PortalDefineQuery(), and PortalStart(), the last of which takes a new snapshot to run the query. Considering that GetSnapshotData() is the number-one consumer of CPU time on many profiling runs I've done, this seems needlessly inefficient. Can't we arrange to retain the snapshot used for parse analysis / planning and reuse it for the portal that we create just afterwards? Off the top of my head, I'm not exactly sure how to do that cleanly, but it seems like it should work. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company