go-clickhouse icon indicating copy to clipboard operation
go-clickhouse copied to clipboard

Could you add async_insert to options?

Open SlavaVV opened this issue 2 years ago • 2 comments

This is new feature for CH. Allows to avoid using buffer tables

New asynchronous INSERT mode allows to accumulate inserted data and store it in a single batch in background.

https://clickhouse.com/docs/ru/operations/settings/settings/#async-insert - by default=0

SlavaVV avatar Nov 20 '21 13:11 SlavaVV

For now it solved adding user's profile. Maybe add to library not too problematic

<?xml version="1.0"?>
<yandex>
	<profiles>
		<http_writer>
			<async_insert>1</async_insert>
		</http_writer>
	</profiles>
	<users>
		<gen_writer>
			<profile>http_writer</profile>
		</gen_writer>
	</users>
</yandex>

SlavaVV avatar Nov 20 '21 15:11 SlavaVV

Hi! Sorry for the late reply. In the current opts implementation you can pass any valid clickhouse option and it will be proxied to all the requests. Consider adding &async_insert=1 to your dsn or add it in cfg.Params

DoubleDi avatar Dec 13 '21 00:12 DoubleDi