8000 Make streamId a sql parameter of type SqlDbType.Char by cheesebridge · Pull Request #197 · SQLStreamStore/SQLStreamStore · GitHub
  • [go: up one dir, main page]

    Skip to content
    This repository was archived by the owner on Aug 15, 2024. It is now read-only.

    Conversation

    @cheesebr
8000
idge
    Copy link

    In our project we saw serious performance issues when having millions of streams.
    This issue was caused by a CONVERT_IMPLICIT() function that was always executed when searching streams by streamId.
    Our streamId was a regular Guid and the parameter type got translated to a nvarchar(36)
    The result was an index scan on the streams table instead of an index seek.

    In this PR, all streamId parameters are typed as SqlDbType.Char with length 42 because the streamid column on the streams table is declared as CHAR(42).
    Now an index seek can be done.

    image

    Before
    image

    After
    image

    …onversion is done in MsSql when searching for a stream
    @thefringeninja
    Copy link
    Contributor

    Just waiting on CI now... I had b0rked the build but just fixed it

    @thefringeninja
    Copy link
    Contributor

    Wow, I can't say for sure but it looks like this PR has shaved a few seconds off of the CI build. Thanks!

    @thefringeninja thefringeninja merged commit 3cd3929 into SQLStreamStore:master Oct 26, 2018
    @damianh
    Copy link
    Member
    damianh commented Oct 26, 2018

    Great stuff

    @damianh damianh added the bug label Oct 26, 2018
    @damianh damianh added this to the v1.1.3 milestone Oct 26, 2018
    @damianh
    Copy link
    Member
    damianh commented Oct 26, 2018

    I'm going to cherry pick this across to a 1.1.3 release branch.

    @damianh damianh modified the milestones: v1.1.3, v1.2.0 Oct 26, 2018
    damianh added a commit that referenced this pull request Oct 26, 2018
    Make streamId a sql parameter of type SqlDbType.Char (cherrypicked from #197)
    @damianh
    Copy link
    Member
    damianh commented Oct 26, 2018

    v1.1.3 is now on nuget.org.

    @damianh damianh added enhancement and removed bug labels Oct 26, 2018
    @damianh
    Copy link
    Member
    damianh commented Oct 26, 2018

    @cheesebridge awesome first PR. Many thanks!

    @yreynhout
    Copy link
    Contributor

    Good stuff! Not sure we can improve on this but Index Scan is generally not a good thing - we should strive for Index Seeks (but as said, I don't know whether that is possible here).

    @cheesebridge
    Copy link
    Author

    You're welcome. It's a great product 👍

    @yreynhout Well this PR turns the index scan into an index seek as you can see in the 'after' screenshot of the query execution plan. ;-)

    @yreynhout
    Copy link
    Contributor

    My bad 😂

    Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    4 participants

    0