Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

###Summary

Summary

Stick to what you are using right now.

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

###Summary

Stick to what you are using right now.

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

Summary

Stick to what you are using right now.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

###Summary

Stick to what you are using right now.

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

###Summary

Stick to what you are using right now.

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

###Summary

Stick to what you are using right now.

Source Link
Simon Forsberg
  • 59.7k
  • 9
  • 157
  • 311

For exact knowledge about finding out which is the most effective, the best way to find that out is to time using:

long start = System.nanoTime();
... perform operations ...
long stop = System.nanoTime();
double milliSecondsElapsed = (stop - start) / 1000000.0;

I think your way of doing it currently is quite good.

I found that there is another way of doing it but it seems to involve writing a seemingly SQL query that looks like this:

INSERT INTO Contacts 
SELECT 'ae0caa6a-8ff6-d63f-0253-110b20ac2127' AS ID, 'xxx' AS FirstName, 'xxx' AS LastName, '9008987887' AS PhoneNumber, '[email protected]' AS EmailId, 'Yes' AS Status 
UNION SELECT '9afab56e-a18a-47f2-fd62-35c78d8e0d94', 'yyy', 'yyy', '7890988909', '[email protected]', 'Yes' 
UNION SELECT '378d757a-ee60-07a4-e8bc-396b402c3270', 'zzz', 'zzz', '9000898454', '[email protected]', 'Yes'

Unless that alternative way of inserting rows to the database improves performance significantly, I would stick to the way that you are doing it now. I imagine that the code required to write this SQL statement would be quite ugly (if you would want to transform your current String[]/ContentValues approach into this SQL statement). Especially considering that I assume you only perform this mass-insertion once. Besides, the code required to transform into SQL also takes time to execute of course, which might neglect the performance increase you would get from doing the mass-insertion with a single SQL statement.

Also, your current approach is very easy to read and understand.

As for whether or not you should write a bulkInsert() method, you could do it just for the challenge of it... if you don't have anything better to do :)

###Summary

Stick to what you are using right now.

lang-java

AltStyle によって変換されたページ (->オリジナル) /