10000 Expose oracledb fetch array size by justin-cotarla · Pull Request #6200 · knex/knex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Expose oracledb fetch array size #6200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions docs/src/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ const pg = require('knex')({
});
```

:::

When using the PostgreSQL driver, another usage pattern for instantiating the Knex configuration object could be to use a `connection: {}` object details to specify various flags such as enabling SSL, a connection string, and individual connection configuration fields all in the same object. Consider the following example:
Another usage pattern for instantiating the Knex configuration object could be to use a `connection: {}` object details to specify various flags such as enabling SSL, a connection string, and individual connection configuration fields all in the same object.

::: info PostgreSQL
If `connectionString` is highest priority to use. If left unspecified then connection details will be determined using the individual connection fields (`host`, `port`, etc), and finally an SSL configuration will be enabled based on a truthy value of `config["DB_SSL"]` which will also accept self-signed certificates.
The `connectionString` takes priority over other connections fields if set. If left unspecified then connection details will be determined using the individual connection fields (`host`, `port`, etc), and finally an SSL configuration will be enabled based on a truthy value of `config["DB_SSL"]` which will also accept self-signed certificates.

```js
const pg = require('knex')({
Expand All @@ -82,8 +79,6 @@ const pg = require('knex')({

:::

The following are SQLite usage patterns for instantiating the Knex configuration object:

::: info SQLite3 or Better-SQLite3
When you use the SQLite3 or Better-SQLite3 adapter, there is a filename required, not a network connection. For example:

Expand Down Expand Up @@ -196,6 +191,28 @@ const knex = require('knex')({

:::

::: info OracleDB
When using the node-oracledb driver, row fetching can be tuned by providing a value for `fetchArraySize`:

```js
const knex = require('knex')({
client: 'oracledb',
connection: {
host: '127.0.0.1',
port: 1521,
user: 'your_database_user',
password: 'your_database_password',
database: 'myapp_test',
fetchArraySize: 10000,
},
```

If not provided, `fetchArraySize` falls back to the driver default of 100.

See [Tune Fetch Performance](https://node-oracledb.readthedocs.io/en/latest/user_guide/tuning.html#rowfetching) for more details.

:::

::: info
The database version can be added in knex configuration, when you use the PostgreSQL adapter to connect a non-standard database.

Expand Down
4 changes: 4 additions & 0 deletions lib/dialects/oracledb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ class Client_Oracledb extends Client_Oracle {
this.connectionSettings
);

if (this.connectionSettings.fetchArraySize) {
this.driver.fetchArraySize = this.connectionSettings.fetchArraySize;
}

if (this.connectionSettings.prefetchRowCount) {
oracleDbConfig.prefetchRows = this.connectionSettings.prefetchRowCount;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dialects/oracledb/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function monkeyPatchConnection(connection, client) {
return cb(err);
}
const fetchResult = { rows: [], resultSet: result.resultSet };
const numRows = 100;
const numRows = client.driver.fetchArraySize;
const fetchRowsFromRS = function (connection, resultSet, numRows) {
resultSet.getRows(numRows, function (err, rows) {
if (err) {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,7 @@ declare namespace Knex {
requestTimeout?: number;
connectString?: string;
expirationChecker?(): boolean;
fetchArraySize?: number;
}

// Config object for pg: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pg/index.d.ts
Expand Down
0