0

Can we run multiple select queries as a batch/pipeline using Xorm Engine in Go? I have a set of 5 queries and if any of them fails my whole logic should fail, but then if they succeed I need the output from all of them. So I want to save on the round trip time in running individually vs batch. Any way to achieve this using Xorm Engine in Go?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Harshit Gupta
  • 167
  • 1
  • 1
  • 10
  • You have just described a "transaction". According to the documentation, Xorm does support transactions, but this also depends on the database you're using. Most do support transactions, but not all. – Jonathan Hall Dec 30 '20 at 11:55
  • If I understand correctly, transaction is just a logical block. Round trips would still be 5 if I use transaction? I am using MySQL database – Harshit Gupta Dec 30 '20 at 11:56
  • Yes, you still have multiple round trips. If you want to avoid that, you probably need to use a stored procedure. And at that point, `xorm` is probably all but irrelevant. – Jonathan Hall Dec 30 '20 at 12:16
  • Got it thanks, will have to work with round trips then. – Harshit Gupta Dec 30 '20 at 12:19

0 Answers0