Skip to content

Reduce LATCH wait states #242

@Roenbaeck

Description

@Roenbaeck

When doing inserts in SQL Server we see a lot of LATCH wait states. This is due to threads having to wait while a more or less single-thread constrained insert is being executed. According to the linked whitepaper the reason for this is the sequential primary key we use in Anchor, and a suggested fix is to introduce a composed key, consisting of a small (tinyint) "hash" together with the sequential identity column. Essentially this gives you 256 sequential ranges, where tables can be partitioned by the "hash", and thereby enable parallelism for up to 256 threads when doing inserts.

https://learn.microsoft.com/en-us/sql/relational-databases/diagnose-resolve-latch-contention?view=sql-server-ver16

Need to investigate if there is a natural way to introduce such a "hash" for the anchor identities in Anchor. A sequence of type tinyint can be created that cycles 256 values over which tables can be partitioned. However, we then need 256 independent sequences for the remaining part of the identity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions