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

Performance optimizations when bulk loading large amounts of timestamps #2194

Merged
merged 4 commits into from
Nov 2, 2023

Conversation

hannes92
Copy link
Contributor

While writing software to sync a couple of hundred million rows from another rdbms to sql server via the BulkCopy API, I discovered a disproportioned amount of time was spent serializing Timestamp objects to then deserialize them into Timestamp objects once again.
My fix for this is to be able to accept Timestamp objects directly (which should cover the majority of objects passed) and only serialize them once when passing the date values to the TDSWriter.

I have attached an example to show the difference while importing about 600k rows with 16 columns with dates only.
image

@hannes92
Copy link
Contributor Author

hannes92 commented Aug 15, 2023 via email

@Jeffery-Wasty
Copy link
Contributor

Thank you for the PR @hannes92. We'll review it when we're able to and get back to you with our next steps.

@lilgreenbird
Copy link
Contributor

could you please add a test which covers the scenario

@hannes92
Copy link
Contributor Author

Added a test case, I lowered the mount of rows inserted to 10000 to not slow down the test suite

@Jeffery-Wasty
Copy link
Contributor

Hi @hannes92,

The PR passes our internal testing, we'll now be reviewing it.

public class BulkCopyTimestampTest extends AbstractTest {

public static final int COLUMN_COUNT = 16;
public static final int ROW_COUNT = 10000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not really necessary to do this that many times, just make sure this is run at last once cover the newly added code

Copy link
Contributor

@lilgreenbird lilgreenbird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make changes as per comments

@lilgreenbird lilgreenbird added this to the 12.5.0 milestone Sep 22, 2023
@lilgreenbird
Copy link
Contributor

@hannes92

@tkyc
Copy link
Member

tkyc commented Oct 18, 2023

After making the newly requested changes, LGTM.

@lilgreenbird lilgreenbird merged commit a762d7c into microsoft:main Nov 2, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed/Merged PRs
Development

Successfully merging this pull request may close these issues.

4 participants