Subject | Re: [firebird-support] Generator Performance |
---|---|
Author | Ann Harrison |
Post date | 2011-09-23T21:34:17Z |
On Fri, Sep 23, 2011 at 2:18 PM, Matheus Degiovani
<matheus@...>wrote:
architectures (i.e. SuperServer) a connection that changes a generator value
gets a transient write lock on the page, makes its change and releases the
page. In a cache-per-connection architecture (e.g. super-classic, classic)
a connection that changes a generator value reads the appropriate generator
page, gets a transient write lock on the page, and makes its change. If
another connection wants to read or change a generator value on that page,
it requests a read lock on the page which causes the connection that holds
the write lock to write the page and release its lock. The other connection
reads the page from disk.
In fact, the write is real, but the read will be satisfied from the
operating system page cache.
high contention page (e.g. header page, transaction inventory page, page
inventory pages).
Good luck,
Ann
[Non-text portions of this message have been removed]
<matheus@...>wrote:
>Generator values are stored on generator pages. In shared cache
> The firebird manual says that generators are thread-safe [1]. How does the
> firebird engine guarantee that two consecutive executions of a "SELECT
> NEXT VALUE FOR..." do not return the same value?
architectures (i.e. SuperServer) a connection that changes a generator value
gets a transient write lock on the page, makes its change and releases the
page. In a cache-per-connection architecture (e.g. super-classic, classic)
a connection that changes a generator value reads the appropriate generator
page, gets a transient write lock on the page, and makes its change. If
another connection wants to read or change a generator value on that page,
it requests a read lock on the page which causes the connection that holds
the write lock to write the page and release its lock. The other connection
reads the page from disk.
In fact, the write is real, but the read will be satisfied from the
operating system page cache.
> Does it use a lock on the RDB$GENERATOR table?No.
> Does the call to "SELECT NEXT VALUE..." block, whenNot exactly. See above.
> another thread is reading/writing into it?
> Would that mean that havingYes, under classic, but not particularly SuperServer. This is true for any
> multiple clients connected and issuing these commands simultaneously
> degrade the performance of the database?
>
high contention page (e.g. header page, transaction inventory page, page
inventory pages).
>Should work OK ... better or worse depending on the architecture.
> My application case is the following: I want to append a column to some
> tables in my database representing an "update counter". Whenever an insert
> or update command is issued, this field will be incremented (globally for
> the whole database).
>
Good luck,
Ann
[Non-text portions of this message have been removed]