# Slow Writing Performance compared to MariaDB when using Python client

**URL:** https://community.influxdata.com/t/slow-writing-performance-compared-to-mariadb-when-using-python-client/19624
**Category:** InfluxDB 2
**Tags:** influxdb, client-libraries, python
**Created:** [April 27, 2021, 3:58pm UTC](https://community.influxdata.com/t/slow-writing-performance-compared-to-mariadb-when-using-python-client/19624 "2021-04-27T15:58:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kraui](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/kraui/32/6421_2.png) [@Kraui](https://community.influxdata.com/u/Kraui)
#### Post date: [April 27, 2021, 3:58pm UTC](https://community.influxdata.com/t/slow-writing-performance-compared-to-mariadb-when-using-python-client/19624/1 "2021-04-27T15:58:55Z")

</div>

Hi,

I am new to InfluxDB and I am trying to compare the performance of MariaDB and InfluxDB 2.0. Therefore I perform a benchmark of about 350.000 rows which are stored in a txt file (30mb).

I use ‘executemany’ to write multiple rows into the database when using MariaDB which took about 20 seconds for all rows (using Python).

So, I tried the same with InfluxDB using the Python client, attached are the major steps of how i do it.

> #Configuring the write api  
> write\_api = client.write\_api(write\_options=WriteOptions(batch\_size=10\_000, flush\_interval=5\_000))
> 
> #Creating the Point  
> p = Point(“Test”).field(“column\_1”,value\_1).field(“column\_2”,value\_2) #having 7 fields in total
> 
> #Appending the point to create a list  
> data.append(p)
> 
> #Then writing the data as a whole into the database, I do this after collecting 200.000 points (this had the best performance), then I clean the variable “data” to start again  
> write\_api.write(“bucket”, “org”, data)

When executing this it takes about 40 seconds which is double the time of MariaDB.

I am stuck with this problem for quite some time now because the documentation suggests that I write it in batches, which I do and in theory it should be faster than MariaDB.

But probably I am missing something

Thank you in Advance! 🙂

---

<div class="post-metadata">

### Author: ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)
#### Post date: [April 27, 2021, 8:57pm UTC](https://community.influxdata.com/t/slow-writing-performance-compared-to-mariadb-when-using-python-client/19624/2 "2021-04-27T20:57:43Z")

</div>

@bednar can you please help with this?

---

<div class="post-metadata">

### Author: ![bednar](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/bednar/32/3690_2.png) [@bednar](https://community.influxdata.com/u/bednar)
#### Post date: [April 29, 2021, 6:34am UTC](https://community.influxdata.com/t/slow-writing-performance-compared-to-mariadb-when-using-python-client/19624/3 "2021-04-29T06:34:26Z")

</div>

Hi @Kraui,

the best performance for importing file you will achieve by using synchronous writes with batches. The following example shows how to do it: [import\_data\_set\_sync\_batching.py](https://github.com/influxdata/influxdb-client-python/blob/4f1e14e4a01200b1a927e2ca470b3662fcb376fd/examples/import_data_set_sync_batching.py).

You can also improve this example by:

- increase batch size to `5_000`: [influxdb-client-python/import\_data\_set\_sync\_batching.py at 4f1e14e4a01200b1a927e2ca470b3662fcb376fd · influxdata/influxdb-client-python · GitHub](https://github.com/influxdata/influxdb-client-python/blob/4f1e14e4a01200b1a927e2ca470b3662fcb376fd/examples/import_data_set_sync_batching.py#L46)
- produce `Line Protocol` instead of `Point` to avoid underlaying type conversion: [influxdb-client-python/import\_data\_set\_sync\_batching.py at 4f1e14e4a01200b1a927e2ca470b3662fcb376fd · influxdata/influxdb-client-python · GitHub](https://github.com/influxdata/influxdb-client-python/blob/4f1e14e4a01200b1a927e2ca470b3662fcb376fd/examples/import_data_set_sync_batching.py#L20)

Regards
