- 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
That link is broken. Could you correct it, @PJH?
Admin
I’m starting to think any programming language’s documentation should present synchronization objects before threads.
Also, why does @snoofle’s description has “C” and “C++” between quotes?
Admin
Done.
Admin
Maybe it is C and C++ but written Java-style? It's the only language not in quotes ...
Admin
/facepalm
Threading is hard to begin with, threading while communicating with a database is..... /double_facepalm
Admin
Another WTF in the same post:
Thread is a class, not an interface, so you implement the Runnable interface or extend the Thread class which implements Runnable. Then you can start the execution with calling an appropriate start method like new Thread(new StreetQuery()).start(); or just call it if you extended your class from Thread.
Admin
Nobody has yet commented on the clear implication in the code of normalisation run wild. It's implied that they have a "street" table in which some sort of city ID is a foreign key referencing the "city" table, which in turn has a foreign key referencing the "state" table etc.
And no, not all addresses (in the real world) have provinces. Even in countries that have some sort of equivalent of provinces (e.g. France, where there are four main administrative levels: commune, département, région, and the whole of France) those provinces aren't necessarily used in people's addresses (e.g. France, where an address would normally be 123 rue Quelque Chose, DDNNN Nom-de-Ville, France - and nothing more than that - DDNNN is the post code, two digits for the département and three to identify the commune within the département. The name of the département and région aren't used.).
Admin
Is it now a thing that we have to link to our own memes in stories?
Admin
Admin
No, I'm saying that this article uses brillance, and links to the relevant TDWTF story and I see no need for this to even be a thing.
Admin
Admin
The President's Daughter would never stand for this
Admin
Admin
No, no, that's not what I mean.
This article, on the main site, links the word 'brillance' to the Paula Bean article of old.
I see no reason for this to be a thing.
Admin
Admin
Well, yeah, but this is what I mean... why is this a thing now? Or is it something that has been a thing forever and I just never noticed?
Admin
"Threading while using a database" How do you think we code servers? The wtf is multithreading an atomic query. But I wonder if they got the idea from Hibernate?
Admin
multithreading multiple requests from multiple sources for a server = good
multithreading multiple requests from the same source with the same WHERE/JOIN/GROUP clauses and selecting different columns = /triple_facepalm
Admin
FullAddress NVARCHAR(MAX)
Admin
maybe it is "you must be new here" post prevention.
Admin
B-b-b-but that's sport around these parts!
Admin
FTFY
Admin
@PJH, whoosh badge time!
Admin
No, I just discofied it. Which is the opposite of fixing.
Admin
TRWTF is the busy wait loop, of course. Unless you have more cores than active threads, busy waiting is always bad for performance. Add a simple Thread.yield() in there, and it will be suddenly a lot faster while using less resources :)
Admin
So, now we are going to turn into this
Admin
I suspect only until the authors get bored of it. That's actually pretty tedious to do, speaking as someone who occasionally does it.
Admin
Can't be more tedious than adding Cornify tags ...
Admin
I like how the link on the "main" comment preview page links to post #127191, which I assume is meant to go to the end.
Who wants to get this thread above 128k posts?
Admin
Maybe suggest that turning off UAC is good or start giving out free likes.
Admin
why 127191?
seriously‽
why not just:
http://what.thedailywtf.com/t/parallel-sql-queries/4135/last
that works out of the box!
Admin
@apapadimoulis, does she need a PR?
Admin
hmm...
remind me tonight i'll fork and submit one.
we don't want to get alex upset by trying to game the system more than usual and having it leak onto the front page.
Admin
huh... the number 127191 doesn't appear in source....
where did it come from then?
Admin
124774 on the previous day.
I don't get it.
Admin
theory. it's using
MAX(post_id)
for that value when it generates the link.don't have time to look more thoroughly right now i'll do that tonight.
Admin
.............uggh.
Admin
That's what I said, I just used fewer words to do it.
Admin
yes, but i actually had to borrow a co-worker's hand to get the triple facepalm.
Admin
Lines 15-18 of ViewCommentsViewModel.cs:
Set on line 14 of ViewCommentsViewModel.cs:
this.MaxDiscoursePostId = this.Comments.Any() ? this.Comments.Max(c => c.DiscoursePostId ?? 0) : 0;
Admin
you want to make the pull request since you have the code in front of you?
just replace the whole lot with:
Admin
I just had a flash flood at work. Maybe a year from now, haha.
Admin
fair enough.
Admin
https://github.com/tdwtf/WtfWebApp/pull/77
Admin
Breaking up the query into multiple queries can cause issues with bad results depending on your isolation level. For example if you have read committed isolation level (default in SQL Server, not in Oracle), it could be that the first query does get the proper data, then before the next select can run a update is ran against the field, and now the query that returns the 2nd column in the same row has different data. Isolation levels are rarely thought of except by developers who have DBA experience or have been hit by it in the past, so just watch out for that.
SQL Server handles parallelism pretty well and has a threshold you can set to see how strongly it should try to do it for you, but I'd recommend having an experienced DBA help you figure it out as it's part art and part science which involves knowing the code base well, which queries are really important, and a few other variables such as certain CPU wait times correlating against cxpackets (A cxpacket wait type will not tell you if there is an issue, it'll just tell if you if parallelism is working, typically you need several baselines, execution plans, wait_stats looking, and perhaps SOS_Scheduler_Yield and some other metric I forgot that's like "C2 CPU" in PerfMon).
SQL 2005+ Enterprise Edition ($$$) handles parallelism using a 'Advance Scanning' mechanism and keeping the data in memory to be used with another query that has a current execution plan and is executing using a full table scan. This avoids cases where bad indexes or statistics can stop the index from being used and we have to scan the full table.
I'm not sure what the dev who did this was thinking. Perhaps he was a MySQL Developer who is used to the non ACID compliance in the MyISAM data table instead of the INNODB table type. Odd. Otherwise I have no idea why they would think this is a good idea. Why didn't they even test this before trying it? O.o
Edit: Even moar edits! This makes even less sense now that I thought about it for a few mins. A "Bookmark Lookup" operation in SQL is very expensive, that's when you're using a non clustered index to gather some of the data, but the remaining data is in the base table. SQL Server will then try to get all the data from the index, and get the rest from the base table by identifying the row. If it takes too long to do that, it'll just do a full table scan where the Enterprise Edition table scan sharing would be helpful. If he was having bookmark lookups, why not just put the columns in the proper index? If not, then why force this parallelism across the same table when the scan has to read the index anyways??
I'm going to go have a drink I think.
Admin
Only lasted 3 hours. Now it's just a huge pile of work, but no fires.
Admin
The other thing I was wondering was if it was the most recent post in the thread, or the last one that the specific user had read...
Admin
not entirely sure. would be more useful if the later.
Admin
I'll dig into the code at some point this week.
EDIT: Depends on how Comments_GetComments gets DiscoursePostId when referenced from the FromArticle() method in CommentModel.cs.
EDIT2: Must be stored in the table.
So not stored by user, probably just the last comment.
Admin
I did that too when I read the parallel threading bit.