I consider optimization in a particularly heavy part of my code. The challenge is to insert statistics into the table. These data fall into a significant part of other programs. Otherwise, I would consider using SQL Bulk attachments, etc.
So my question is ...
Is it possible to try to insert some data, knowing that it can (not too often) throw a SqlException for a repeating row?
Is an exception performance hit worse than checking each row before inserting?
-, - , . , , , , .
-, , , , . . , . (), DB .
, . , , . , , , , SQL- .
, , . , .
- . , . , , .
, IF
IF (SELECT COUNT (*) FROM X WHERE Y = Z) = 0 INSERT INTO (X) ('XX')....
ELSE...
, , . , - ..
INSERT , ..
IF NOT EXISTS, INSERT, , , .
, . Identity/Auto-number, ( 100%), , ..
, , , ..
, . , IP-.
, , .
.
, , , , , .
, , , .
, .
Source: https://habr.com/ru/post/1703263/More articles:Implement captcha in a stateless REST web service environment - .netAndroid BaseAdapter: position is not in reality? - androidSending and receiving data via USB port - windowsAPI for communication of a cellular number with a provider - mobilewindow.onbeforeunload detects if POST or GET - javascript-eventsYou must create an image in ASP.Net through webservice - .netSending big data> 1 MB via Windows Sockets using the send function - windowsIs there an equivalent SQL Server @@ error in MySQL? - databaseWhat do I need to know when switching from MS SQL server to MySQL? - databaseChildren's Tables at NHibernate - c #All Articles