Skip to content
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

The DataFrame serialisation is slower than in v1 #92

Closed
benb92 opened this issue May 11, 2020 · 2 comments · Fixed by #97
Closed

The DataFrame serialisation is slower than in v1 #92

benb92 opened this issue May 11, 2020 · 2 comments · Fixed by #97
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@benb92
Copy link

benb92 commented May 11, 2020

Using python pandas. Version 1 i used this:

def dbpop_influx(data, dbname, measurement, columns):
    ## constants:
    dbclient = DataFrameClient(host='localhost', port=8086, username='root', password='root', database=dbname)
    n_import_chunks = math.ceil(len(data) / 10000)
    data_chunks = np.array_split(data, n_import_chunks)
    for d in data_chunks:
        dbclient.write_points(d, measurement, tag_columns = columns, protocol = 'line')

Takes 29 seconds (was looking to improve that speed with multiprocessing)

Version 2 i used this:

_client = InfluxDBClient(url="http://localhost:9999", token=token, org="org")
_write_client = _client.write_api(write_options=WriteOptions(batch_size=10000,
                                                             flush_interval=10_000,
                                                             jitter_interval=0,
                                                             retry_interval=5_000))


start = time.time()
_write_client.write('data', record=imp_dat[0], data_frame_measurement_name='coinmarketcap_ohlcv',
                    data_frame_tag_columns=['quote_asset','base_asset'])
print(time.time() - start)

this takes 118 seconds...

data looks like:
image

@bednar

@bednar bednar added the enhancement New feature or request label May 11, 2020
@bednar
Copy link
Contributor

bednar commented May 11, 2020

Randomized data to testing: https://we.tl/t-QBtxHlvfvx

Time format:

image

@bednar
Copy link
Contributor

bednar commented Jun 2, 2020

Hi @bburden,

The issue is fixed in 1.8.0 milestone.

If you would like to use a dev version then install client via:

pip install git+https://github.com/influxdata/influxdb-client-python.git@master

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants