On Tue, Oct 20, 2020 at 6:51 PM wrote:
> var count int
> var favorited string
>
> fetchBookmarks := Config.DB.QueryRow("SELECT COUNT(*) FROM
> favorites where userID = ? and postID = ? and status = ?", userID, postID,
> "added").Scan(&count)
>
> if fetchBookmarks !
On Oct 21, 2020, at 6:41 AM, Bill wrote:
>
> Hello,
> I created the sql to fetch all info in one call instead of multiple calls per
> each row.
>
> One thing I noticed about golang is that when I ping my Remote DB from
> localhost (running in vscode) I get ping -> 1.573826274s. So I think thi
On Oct 20, 2020, at 1:18 PM, Marcin Romaszewicz wrote:
>
> Go's database layer is generally pretty quick, I use it a lot, but your code
> immediately sets off my DB alarms, because you are doing queries within the
> body of another query loop, which means you're opening up lots of
> connection
Can you connect to that DB any faster from the same machine not using Go?
-- Marcin
On Wed, Oct 21, 2020 at 3:43 AM Bill wrote:
> Hello,
> I created the sql to fetch all info in one call instead of multiple calls
> per each row.
>
> One thing I noticed about golang is that when I ping my Remote
To reuse connections, and pay the slowness only on the first connection, set
Config.DB.SetMaxIdleConns(2)
Or something like that.
As *sql.DB is a pool, this can keep two connections alive - one for your
main query, and one for the per-row extra queries.
Bill a következőt írta (2020. októbe
Hello,
I created the sql to fetch all info in one call instead of multiple calls
per each row.
One thing I noticed about golang is that when I ping my Remote DB from
localhost (running in vscode) I get ping -> 1.573826274s. So I think this
is the reason that all my calls to db are delayed.
Hav
Go's database layer is generally pretty quick, I use it a lot, but your
code immediately sets off my DB alarms, because you are doing queries
within the body of another query loop, which means you're opening up lots
of connections, which could be slow.
I'd reorganize as followd.
- Cache the resul
I use Go with github.com/go-sql-driver/mysql to connect to MySQL. The
performance in Go vs other languages is terrible or I'm missing something.
I use Go for my REST API, an example is below:
We have a table with posts. We fetch the posts, on each post we search
favorites table (if user has fav