pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedMVCC and Implications for (Near) Real-Time Application
3+ messages / 3 participants
[nested] [flat]
* MVCC and Implications for (Near) Real-Time Application
@ 2010-10-25 18:46 Steve Wong <powerpchead@yahoo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Steve Wong @ 2010-10-25 18:46 UTC (permalink / raw)
To: pgsql-performance
Hi experts,
I have a (near) real-time application in which inserts into the database needs
to be visible to queries from other threads with minimal delay. The inserts are
triggered by real-time events and are therefore asynchronous (i.e. many
performance tips I read related to batch inserts or copy do not apply here,
since these events cannot be predicted or batched), and the inserted data need
to be available within a couple of seconds to other threads (for example, an
inserted row that only appears to other query threads 5 seconds or more after
the insert is not acceptable). The delay should be under 2 seconds maximum,
sub-1 second would be great.
My questions are: (1) Does the MVCC architecture introduce significant delays
between insert by a thread and visibility by other threads (I am unclear about
how multiple versions are "collapsed" or reconciled, as well as how different
query threads are seeing which version)? (2) Are there any available benchmarks
that can measure this delay? (3) What are relevant config parameters that will
reduce this delay?
Thanks for your patience with my ignorance of MVCC (still learning more about
it),
Steve
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: MVCC and Implications for (Near) Real-Time Application
@ 2010-10-29 17:05 A.M. <agentm@themactionfaction.com>
parent: Steve Wong <powerpchead@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: A.M. @ 2010-10-29 17:05 UTC (permalink / raw)
To: pgsql-performance
On Oct 25, 2010, at 2:46 PM, Steve Wong wrote:
> Hi experts,
>
> I have a (near) real-time application in which inserts into the database needs
> to be visible to queries from other threads with minimal delay. The inserts are
> triggered by real-time events and are therefore asynchronous (i.e. many
> performance tips I read related to batch inserts or copy do not apply here,
> since these events cannot be predicted or batched), and the inserted data need
> to be available within a couple of seconds to other threads (for example, an
> inserted row that only appears to other query threads 5 seconds or more after
> the insert is not acceptable). The delay should be under 2 seconds maximum,
> sub-1 second would be great.
>
> My questions are: (1) Does the MVCC architecture introduce significant delays
> between insert by a thread and visibility by other threads (I am unclear about
> how multiple versions are "collapsed" or reconciled, as well as how different
> query threads are seeing which version)? (2) Are there any available benchmarks
> that can measure this delay? (3) What are relevant config parameters that will
> reduce this delay?
There is no way to know without testing whether your hardware, OS, database schema, and database load can meet your demands. However, there is no technical reason why PostgreSQL could not meet your timing goals- MVCC does not inherently introduce delays, however the PostgreSQL implementation requires a cleanup process which can introduce latency.
If you find that your current architecture is not up to the task, consider using LISTEN/NOTIFY with a payload (new in 9.0), which we are using for a similar "live-update" system.
Cheers,
M
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: MVCC and Implications for (Near) Real-Time Application
@ 2010-10-29 17:18 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: Steve Wong <powerpchead@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Grittner @ 2010-10-29 17:18 UTC (permalink / raw)
To: pgsql-performance; Steve Wong <powerpchead@yahoo.com>
Steve Wong <powerpchead@yahoo.com> wrote:
> (1) Does the MVCC architecture introduce significant delays
> between insert by a thread and visibility by other threads (I am
> unclear about how multiple versions are "collapsed" or reconciled,
> as well as how different query threads are seeing which version)?
As soon as the inserting transaction commits the inserted row is
visible to new snapshots. If you are in an explicit transaction the
commit will have occurred before the return from the COMMIT request;
otherwise it will have completed before the return from the INSERT
request.
You will get a new snapshot for every statement in READ COMMITTED
(or lower) transaction isolation. You will get a new snapshot for
each database transaction in higher isolation levels.
-Kevin
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2010-10-29 17:18 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-25 18:46 MVCC and Implications for (Near) Real-Time Application Steve Wong <powerpchead@yahoo.com>
2010-10-29 17:05 ` A.M. <agentm@themactionfaction.com>
2010-10-29 17:18 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox