- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
[quote=DBA from TFA]Please tell me this wasn't found in our product...[/quote] Well, Ralph could now claim he found it at TheDailyWTF with their product following a similar pattern.
Admin
a team that
over a period of 2 years.
This must be some new definition of quickly that I'm not familiar with. Or maybe it's just a different kind of movement.
Admin
https://pbs.twimg.com/media/BDk7b_aCcAEpBjA.jpg
Admin
But why?
Admin
Of course they're not. Writing code is too time-consuming already without them.
Admin
So, how would you have done the pack-several-records-in-a-struct thing with C# and SQL Server? XML parameters?
Admin
Simple: XMSQL#.Linq
Admin
Well I do not know if it would work, but with XML it would at least be Enterprisy.... :smile:
Admin
Where do all those records come from? As there wasn't a DBA on the project I find myself wondering if the whole thing couldn't have been done by a stored procedure extracting the original data into as many temp tables as needed, then doing any necessary joins, sorts and extracts, and finally reading the result into the temp table.
Admin
Painstakingly agile.
Admin
Where do all those records come from? As there wasn't a DBA on the project I find myself wondering if the whole thing couldn't have been done by a stored procedure extracting the original data into as many temp tables as needed, then doing any necessary joins, sorts and extracts, and finally reading the result into the temp table.
Oh you mean by creating a view which could then be directly queried?
Admin
"The term Wunderkind (from German: "wonder child") "
In the software world usually neither "wonder" nor "child" actually applies.
Admin
This used to be the recommended way to pass this type of thing into SQL Server. Table variables (which are great) still generated a ton of individual database calls, SQL Bulk Copy required an actual table to be created (or clever use of a permanent "temp" table and a scope field that differentiated each call). XML worked once SQL Server supported xml queries, but there was a ton of transport overhead for that. Entity Framework/LINQ2SQL just generated a bajillion individual inserts the last time I looked.
Of course, documentation would have been good, but he probably just copied & pasted from an answer on some blog because he was a Wunderkind.
Admin
TRWTF here is that apparently neither the Wunderkind nor the author of the article has heard of
BULK INSERT
, which is how you solve the problem that the Wunderkind is attempting to solve here in a supported, well-understood way.One time I was asked to look at some reporting code that could take several hours to run. After a bit of spelunking I realized that most of the time was being taken up by processing a few million INSERT statements, each one being run as its own call to the database, over the network, with all the latency that implies. So I reworked the system to use a single bulk insert and sent it to the PM to give to the client.
The next day, I got a panicky call from the PM, stating that my code wasn't working. I double-checked their database, and told her that it sure looked like everything had run successfully. She was like, "wait... you mean it's done already?!? They came back to check after 45 minutes and found it doing nothing!" Turns out the whole thing had taken about 15 minutes to run, down from around 8 hours.
Admin
A 30-times speedup? Nice!
(The best I've done with optimizing things in recent years was about 25-times, but that was without switching algorithms so it still isn't shabby. And it wasn't with DB interactions.)
Admin
I wonder if it would be childish to point out the word "wund"...
Admin
All good blogs with code samples I've seen so far are unsparingly commented.
Oh wait...