hera icon indicating copy to clipboard operation
hera copied to clipboard

DML query must be inside a transaction?

Open quagmt opened this issue 4 years ago • 1 comments

What I Did

  • I created some insert queries, with and without using transaction. I'm using postgresqlworker

What I Expected

  • Should have new records for both cases

What I Saw Instead

  • Only insert query runs with transaction successful (which creates a new record)
  • The normal query couldn't create a record but it returned no error

My question is: does DML query only work with transaction? The performance with and without transaction is really different:

With transaction:

goos: linux goarch: amd64 pkg: github.com/tinoquang/hera-client/internal/services/ledger cpu: AMD Ryzen 7 5800H with Radeon Graphics
BenchmarkHeraCreateWithTranasction 208 5696227 ns/op 3774 B/op 94 allocs/op BenchmarkHeraCreateWithTranasction-2 429 2706561 ns/op 3779 B/op 94 allocs/op BenchmarkHeraCreateWithTranasction-4 733 1551963 ns/op 3804 B/op 94 allocs/op

Without transaction:

goos: linux goarch: amd64 pkg: github.com/tinoquang/hera-client/internal/services/ledger cpu: AMD Ryzen 7 5800H with Radeon Graphics
BenchmarkHeraCreateWithTranasction 717 1644049 ns/op 3125 B/op 78 allocs/op BenchmarkHeraCreateWithTranasction-2 1580 756031 ns/op 3101 B/op 78 allocs/op BenchmarkHeraCreateWithTranasction-4 3846 315235 ns/op 3101 B/op 78 allocs/op

quagmt avatar Mar 27 '22 06:03 quagmt

@tinoquang Thanks for taking time to test this out. I appreciate it! Would you be able to share a snippet of the code you tried? We'll review that and get back to you.

venkatsridhar95 avatar Apr 07 '22 18:04 venkatsridhar95