DarkWanderer / ClickHouse.Client

.NET client for ClickHouse
MIT License
302 stars 58 forks source link

Query optimization suggestion #376

Closed mbtolou closed 8 months ago

mbtolou commented 9 months ago

Hi.

Is there a solution that does not request the column information list for each insert in the database? I suggest that it be sent as an argument to the function or cached as a variable in the class.

https://github.com/DarkWanderer/ClickHouse.Client/blob/53f2434bb3edc4fe2eae58820509ccba139f8123/ClickHouse.Client/Copy/ClickHouseBulkCopy.cs#L99

DarkWanderer commented 8 months ago

I've started working on this previously but shelved due to lack of time - thanks for reminding, I'll take a look in coming weeks

DarkWanderer commented 8 months ago

Added in version 6.8.0, please check and let me know in case of any issues

mbtolou commented 8 months ago

Before raising the problem, I thank you for your kindness.

I suggest you delete the current line so that if you don't know the list of columns, the class will automatically call the list of columns from the bank for the first time.

Thank

https://github.com/DarkWanderer/ClickHouse.Client/blob/096f5157ce59c974b221c5e84b6b58355cb6176a/ClickHouse.Client/Copy/ClickHouseBulkCopy.cs#L79C26-L79C26

Of course, the problem can be solved with this method apparently:

bulkCopy = new ClickHouseBulkCopy(ch_connection) { DestinationTableName = tableName, ColumnNames = columns ?? new string[0] };
DarkWanderer commented 8 months ago

Thank you for your suggestion - indeed, that's an easy opportunity for improvement. Added in 6.8.1

mbtolou commented 7 months ago

when use cache bulk copy class , The RowsWritten value is reported incorrectly