Home > database >  Golang SQL: More Efficient to Query Two Tables at Once or Separate Queries/Connection Pools?
Golang SQL: More Efficient to Query Two Tables at Once or Separate Queries/Connection Pools?

Time:12-14

I have a connection pool for database A and database B. I am moving some Node.JS code over to Go (I'm using SQL Server if that matters), and some of the queries are doing this:

db.A.Query(`
    select ... from some_table;
    select ... from B..other_table;
`) 

Is it better to do it that way, or like:

db.A.Query(...)
db.B.Query(...)

I read this line:

create one sql.DB object for each distinct datastore you need to access

from enter image description here

  • Related