> Try breaking down the A query with LIMIT/OFFSET so that it never holds > locks for long. That way B will not wait for long, if at all, and will > not fail. Just as a remark, this will only work if the chunks can be processed in separate transactions. If the whole thing is related and A must be completely wrapped in a transaction, then the locks placed by the first queries will still hold until the end of the transaction... Cheers, Csaba.