Optimizing Read-Only Scalability

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Optimizing Read-Only Scalability
Date: 2009-05-14 17:01:43
Message-ID: 1242320503.3843.562.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


In a thread on -perform it has been observed that our Read-Only
scalability is not as good as it could be. One problem being that we
need to scan the whole of the ProcArray to derive a snapshot, which
becomes the dominant task with many users.

If we think about a situation where write transactions happen
infrequently, then the likelihood is that we end up with xmin==xmax most
of the time.

If our last snapshot had xmin=xmax and the xmax hasn't changed since our
last snapshot then we don't need to scan the procarray at all, just look
at the header.

So we can optimize away the scan through the procarray by doing two "if"
tests, one outside of the lock, one inside. In normal running, both will
be optimized away, though in read-only periods we would avoid much work.

We don't need to change the API to GetSnapshotData since the snapshot is
statically allocated and unless newly created will contain the "last"
snapshot's data.

Interesting?

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-05-14 17:28:51 Re: Optimizing Read-Only Scalability
Previous Message Simon Riggs 2009-05-14 15:36:55 Re: New trigger option of pg_standby