Comments (7)
Sorry for not replying for so long time.
Batching is efficient when the network distance between the client and the server is long.
When a network round trip requires 1ms, inserting 10k rows requires at least 10s excluding time spent in the server side.
If 1000 rows are sent in a batch, it decreases to 10ms.
Well, I'll implement it in two or three weeks.
from rust-oracle.
Rust-oracle 0.5.1 was published. It includes batching support.
from rust-oracle.
I added batch support. See the following doc comment. I'll release it after I add notice that batch errors and row counts are available only when both the client and the server are Oracle 12.1 or upper.
Lines 227 to 406 in 0f62963
from rust-oracle.
The StmtParam::FetchArraySize option is for queries, using it for updates will only increase the amount of memory your program need.
The batch support works, I personally tested the latest version of rust-oracle with a 19c database and performance is quite good,
furthermore, if you put all the logic inside a SQL block and send it with rust-oracle similar to what you would do with a SQL tool where you run your SQL scripts will notice that performance with rust-oracle is better than with a Java thin driver which most SQL tools use.
If summary your code should look like this:
let ids: Vec<i32> = (0..10000).map(|v| v + 1).collect();
let now = Instant::now();
let mut stmt = conn.prepare("UPDATE table SET field='something' WHERE id = :1", &[])?;
for id in &ids {
stmt.execute(&[id])?;
}
println!("Time for {} updates: {}", ids.len(), now.elapsed().as_millis());
conn.commit()
Some numbers: running the above code using two VMs in the same machine, one runing the rust program and the other the DB in a container with 10k records, got 1970 ms, now putting all the logic inside a SQL string block and running it with the same stmt.execute got only 104 ms which is fater than my 145 ms using a SQL tool with Java thin driver.
Hope this help,
R
from rust-oracle.
Thanks for your comment.
I'll give it another try, I must have been doing something wrong with batching.
from rust-oracle.
Hi @rgutierrez2004 , could you give a bit more detail on "putting all the logic inside a SQL string block" please? Do you mean also including the ID and time stamp generation into the SQL script? If yes, can you share the final script as an example?
Thanks in advance!
Some numbers: running the above code using two VMs in the same machine, one runing the rust program and the other the DB in a container with 10k records, got 1970 ms, now putting all the logic inside a SQL string block and running it with the same stmt.execute got only 104 ms which is fater than my 145 ms using a SQL tool with Java thin driver.
Hope this help,
R
from rust-oracle.
Thanks a lot @kubo should I close the issue or let you do it?
from rust-oracle.
Related Issues (20)
- Any idea why I'm getting `DPI Error: DPI-1080: connection was closed by ORA-3156` HOT 3
- Usage with asynchronous code problem - how to shut down `.connect()` call that hangs indefinitely HOT 6
- Insert null values HOT 3
- How to change the value of "oracleClientLibDir" in dpiContextCreateParams struct HOT 3
- API to upload file as BLOB without preallocation HOT 3
- Question - async/await stream to many users using just 1 thread HOT 2
- the `?` operator can only be used in a function that returns `Result` or `Option` HOT 1
- QUESTION the trait `ToSql` is not implemented for `SqlValue`
- Question - Calling Oracle Stored Procedures Example HOT 3
- Convert recordset to Vec of Columns HOT 1
- Question - Alter Sessions HOT 1
- A way to set path for oracle instant client HOT 2
- How to extract `Geometry` type. HOT 2
- How can I save ResultSet<'_, oracle::Row> for later access? HOT 6
- `*mut oracle::binding::binding::dpiStmt` cannot be sent between threads safely HOT 2
- Question - Trying to use like operator with wildcards within query_as HOT 5
- Ability to auto-gen structs from db HOT 1
- execute create table sql error? HOT 3
- Question about performance HOT 12
- Why the lifetime is 'static
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-oracle.