You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SQL.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@ Behind the scene, `database/sql` APIs are implemented using the native interface
9
9
1.[Initialization of `database/sql` driver](#init)
10
10
*[Configure driver with `ydb.Connector` (recommended way)](#init-connector)
11
11
*[Configure driver with data source name or connection string](#init-dsn)
12
-
2.[Session pooling](#session-pool)
13
-
3.[Client balancing](#balancing)
12
+
2.[Client balancing](#balancing)
13
+
3.[Session pooling](#session-pool)
14
14
4.[Query execution](#queries)
15
15
*[Queries on database object](#queries-db)
16
16
*[Queries on transaction object](#queries-tx)
@@ -72,21 +72,9 @@ Data source name parameters:
72
72
* static credentials with authority part of URI, like `grpcs://root:password@localhost:2135/local`
73
73
*`query_mode=scripting` - you can redefine default [DML](https://en.wikipedia.org/wiki/Data_manipulation_language) query mode
74
74
75
-
## Session pooling <aname="session-pool"></a>
76
-
77
-
Native driver `ydb-go-sdk/v3` implements the internal session pool, which uses with `db.Table().Do()` or `db.Table().DoTx()` methods.
78
-
Internal session pool are configured with options like `ydb.WithSessionPoolSizeLimit()` and other.
79
-
Unlike the session pool in the native driver, `database/sql` contains a different implementation of the session pool, which is configured with `*sql.DB.SetMaxOpenConns` and `*sql.DB.SetMaxIdleConns`.
80
-
Lifetime of a `YDB` session depends on driver configuration and error occurance, such as `sql.driver.ErrBadConn`.
81
-
`YDB` driver for `database/sql` includes the logic to transform the internal `YDB` error codes into `sql.driver.ErrBadConn` and other retryable and non-retryable error types.
82
-
83
-
In most cases the implementation of `database/sql` driver for YDB allows to complete queries without user-visible errors.
84
-
But some errors need to be handled on the client side, by re-running not a single operation, but a complete transaction.
85
-
Therefore the transaction logic needs to be wrapped with retry helpers, such as `retry.Do` or `retry.DoTx` (see more about retry helpers in the [retry section](#retry)).
86
-
87
75
## Client balancing <aname="balancing"></a>
88
76
89
-
`database/sql` driver for `YDB` like as native driver for `YDB` use client balancing, which happens on `CreateSession` request.
77
+
`database/sql` driver for `YDB` like as native driver for `YDB` use client balancing, which happens on `CreateSession` request.
90
78
At this time, native driver choose known node for execute request by according balancer algorithm.
91
79
Default balancer algorithm is a `random choice`.
92
80
Client balancer may be re-configured with option `ydb.WithBalancer`:
@@ -112,6 +100,18 @@ if err != nil {
112
100
db:= sql.OpenDB(connector)
113
101
```
114
102
103
+
## Session pooling <aname="session-pool"></a>
104
+
105
+
Native driver `ydb-go-sdk/v3` implements the internal session pool, which uses with `db.Table().Do()` or `db.Table().DoTx()` methods.
106
+
Internal session pool are configured with options like `ydb.WithSessionPoolSizeLimit()` and other.
107
+
Unlike the session pool in the native driver, `database/sql` contains a different implementation of the session pool, which is configured with `*sql.DB.SetMaxOpenConns` and `*sql.DB.SetMaxIdleConns`.
108
+
Lifetime of a `YDB` session depends on driver configuration and error occurance, such as `sql.driver.ErrBadConn`.
109
+
`YDB` driver for `database/sql` includes the logic to transform the internal `YDB` error codes into `sql.driver.ErrBadConn` and other retryable and non-retryable error types.
110
+
111
+
In most cases the implementation of `database/sql` driver for YDB allows to complete queries without user-visible errors.
112
+
But some errors need to be handled on the client side, by re-running not a single operation, but a complete transaction.
113
+
Therefore the transaction logic needs to be wrapped with retry helpers, such as `retry.Do` or `retry.DoTx` (see more about retry helpers in the [retry section](#retry)).
114
+
115
115
## Query execution <aname="queries"></a>
116
116
117
117
### Queries on database object <aname="queries-db"></a>
0 commit comments