FAQ
I have a sequence in my code that runs 3 queries as part of the same
transaction in order to deliver a message to its recipients. The 3 queries
are:

1) Save the message
2) Enqueue delivery for external recipients
3) Deliver to local recipients

Since these happen sequentially, I've figure to make use of those go
routines and run them in parallel. Now, has anyone tried this before and if
so, do you see any potential issues with it? I know the DB connection pool
is thread-safe, but does it apply to a transaction too?

Lastly, I feel this could add a significant speed improvement, am I wrong?

If it helps to visualize, here is a split diff before and after the
change: https://github.com/gbbr/gomez/commit/1be4fa2a60ae82a08ee410f0e013a44bd68c365e?diff=unified

I haven't had time to write an actual benchmark for the 2 versions but if I
don't get any good answers I will! :)

Thank you!

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Egon at Oct 23, 2014 at 6:49 am

    On Thursday, 23 October 2014 00:53:02 UTC+3, Gabriel Aszalos wrote:
    I have a sequence in my code that runs 3 queries as part of the same
    transaction in order to deliver a message to its recipients. The 3 queries
    are:

    1) Save the message
    2) Enqueue delivery for external recipients
    3) Deliver to local recipients

    Since these happen sequentially, I've figure to make use of those go
    routines and run them in parallel. Now, has anyone tried this before and if
    so, do you see any potential issues with it? I know the DB connection pool
    is thread-safe, but does it apply to a transaction too?
    Think what will happen when the server crashes? Will the messages be still
    delivered? Or whether it's not a problem when you lose some messages?

    Lastly, I feel this could add a significant speed improvement, am I wrong?
    It does not matter.

    People usually check their messages once in an hour; so if you take 1sec to
    send the message, no one will care.

    If it helps to visualize, here is a split diff before and after the
    change:
    https://github.com/gbbr/gomez/commit/1be4fa2a60ae82a08ee410f0e013a44bd68c365e?diff=unified
    <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fgbbr%2Fgomez%2Fcommit%2F1be4fa2a60ae82a08ee410f0e013a44bd68c365e%3Fdiff%3Dunified&sa=D&sntz=1&usg=AFQjCNFnWQyOR7xgw19zyBHNhJja047XvA>

    I haven't had time to write an actual benchmark for the 2 versions but if
    I don't get any good answers I will! :)

    Thank you!
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 22, '14 at 9:53p
activeOct 23, '14 at 6:49a
posts2
users2
websitegolang.org

2 users in discussion

Gabriel Aszalos: 1 post Egon: 1 post

People

Translate

site design / logo © 2022 Grokbase