Readpast-locking examples

The following examples illustrate readpast locking.

To skip all rows that have exclusive locks on them:

select * from titles readpast

To update only rows that are not locked by another session:

update titles 
    set price = price * 1.1 
    from titles readpast

To use readpast locking on the titles table, but not on the authors or titleauthor table:

select *
    from titles readpast, authors, titleauthor
    where titles.title_id = titleauthor.title_id
    and authors.au_id = titleauthor.au_id

To delete only rows that are not locked in the stores table, but to allow the scan to block on the authors table:

delete stores from stores readpast, authors
where stores.city = authors.city