question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OracleBulkCopy default implementation

See original GitHub issue

The Oracle provider has, in my opinion, strange defaults when it comes to bulk copy.

1. It defaults to multiple rows.

Wouldn’t it be better to check if OracleBulkCopy is available? Unfortunately it’s available only in the native provider (not classic-managed, nor core-managed) and Oracle seems in no hurry to fix that. But when using native, isn’t that the best option?

2. Multiple rows defaults to INSERT ALL

With Oracle, isn’t INSERT INTO actually a better choice? It uses array parameters to send a simple, short, parameterized insert statement with N sets of parameters at once.

You can easily and efficiently send 100 rows at a time with a short SQL statement, it’s more efficient than generating a huge 100 x P parameters INSERT ALL statement.


It’s not critical as you can easily change the defaults, but I wonder why the best options aren’t the actual defaults?

Given that it changes the generated queries when users upgrade, that would qualify as a major release change, of course… unless we can piggy-back another new flag to change the defaults, e.g. the Oracle 12 dialect proposed in #1879

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jods4commented, May 30, 2022

@viceroypenguin I changed my mind on what is the “better” default but it’s still not the one proposed by linq2db.

I changed my mind about native bulk because even though it’s best in terms of throughput, non-transactional is very dangerous if you’re not aware.

Using array bindings is the IMHO the right default, as it’s simply more efficient than a “SELECT ALL”. It uses way less parameters, with a short and simple SQL statement. You can easily batch hundreds of rows in one round-trip. “SELECT ALL” needs one parameter per value per row, generates a query that’s as long as the number of rows you want to insert, it’s not efficient to send and parse and could run into max query length and max # parameters if you try to scale it up to more rows per roundtrip.

1reaction
jods4commented, Mar 14, 2021

Everything works fine for me, yes (in the limits of how Oracle works, anyway).

I opened this issue just to suggest more performant default values. INSERT ALL can generate very long SQL queries and the last one sent is probably different each time if the number of elements modulo batch size isn’t constant (which implies new execution plan and cache pollution).

Array binding queries are short and natively handled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OracleBulkCopy Class
This constructor instantiates a new instance of OracleBulkCopy class using the specified connection and default value for OracleBulkCopyOptions .
Read more >
What specifically does OracleBulkCopy do, and how can I ...
During an Oracle bulk copy, the following constraints are automatically enabled by default: NOT NULL; UNIQUE; PRIMARY KEY (unique-constraints on ...
Read more >
OracleBulkCopy Class in Oracle.ManagedDataAccess.dll?
At the time of this writing OracleBulkCopy is not supported in ODP.NET, Managed Driver. ... If we get enough votes, they may implement...
Read more >
OracleBulkCopy: different behavior between Oracle 12c ...
I'm transferring data from an SQLite database to an Oracle Database with fully managed ODP.NET, 4.122.19.1. So far it has been 12c which...
Read more >
Two Ways To Insert Bulk Data Into Oracle Database Using ...
This article will explain how we can insert bulk amount of data in Oracle database using C#. Generally, what happens, we insert one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found