« first day (2247 days earlier)      last day (2615 days later) » 
00:00 - 20:0020:00 - 00:00

12:16 AM
wow, the broken images problem is happening here on DBA too o.O
 
 
2 hours later…
2:06 AM
i feel like i'm cheating on sql server ... i'm fooling around with graphengine on the side
 
hussey
 
sometimes I feel like I'm cheating because of all of the bad and hacky things that I do
I think I have a way to force search 2 optimization but haven't tested extensively
 
 
1 hour later…
3:15 AM
@AaronBertrand right? thanks for confirming what i thought. btw ... had a fun time with Scott F. SentryOne's roadmap plans look pretty awesome
 
3:32 AM
@swasheck Scott's a good egg. Just don't try to make him feel guilty about voting for Gary Johnson. :-)
 
@AaronBertrand really like the guy. i'd not try to make him feel guilty about anything. i dont know him that well ;)
but yeah, he seems like he'd get defensive pretty quickly. he said that there may be a senior SE position coming up soon. i may ... consider it
 
3:53 AM
Are you on our PAC? You should be.
 
@AaronBertrand PAC?
 
Product advisory council
Drop me an e-mail, we'll chat
 
ok
@AaronBertrand feel free to delete if you're not comfortable with that being out there
 
 
2 hours later…
5:47 AM
In preparation for my return in 11 hours.
 
6:38 AM
@JoeObbish TF 8677?
A USE PLAN also forces stage 2, but that's probably not what you meant :)
 
Hello and good morning. I might be asking something which I don't call it as its actual name but I'll try. I know that there are statistics in SQL server which also emit data about usages of SP's , execution times and another useful info. But I've heard that all those statistiacs are gone while the service is restarted ( the SQL server service). And so I ask : is there any ready query templates which creates structure logs table and ofcourse a job which updates the statistics in those tables ?
I'm pretty sure that there has to be something ready out there
My goal : come after half a year to my SQL SERVER and see where are the bottlenecks and what should I optimize , while not being afraid if SQL service has restarted.
 
@RoyiNamir It's from the Dynamics team, but the general stuff should work on any database
 
Thank you very much Tom
 
If you are talking about logging dmv data that is, which I think you are
The documentation for it is a bit spread over several msdn blogs but I'm sure you'll find them
And the keywords you are looking for are things like "persisting dmv" or "logging dmv data" or stuff like that, it's called dmv/dynamic management views @RoyiNamir
 
I knew it has to do with DMV but I didn't know if it was only it
 
6:55 AM
@TomV Cool. Never thought of that.
 
Again thank you. I will download and test it.
 
@PaulWhite Yeah
 
7:10 AM
@hot2use I'm trying hard to avoid having multiple browser instances, but it may be a losing battle.
Or multiple desktops, but I've never really been sure how to do that.
 
7:29 AM
I like Stardocks' Fences for decluttering my desktop. (Disclaimer: I am in no way affiliated with Stardock, Inc.)
I guess it all has to do with focus and de-multi-tasking
Do one thing at once good and stop multi-tasking in favour of fast and good results for one project.
But that's in IMH(S)O.
 
8:21 AM
Ooh, Thomas LaRock (and Pinal Dave) coming to Antwerp
Unfortunately I don't recognize any of you lot in the speakers list
 
@hot2use I agree 100%
 
9:19 AM
@EvanCarroll is anyone allowed in apart from you? 'Microsoft users' is a bit broad, never mind the rest.
 
9:46 AM
@McNets yes I've changed it — but have you tried clicking the 'markdown' link?
 
@hot2use Even doing one thing at a time, one still needs a queue, and history.
 
@JackDouglas No, this was the next question. ;) What 'markdown' is stand for
sorry, delete stand for
 
@McNets it's supposed to be an easy way of pasting scripts with results directly from DBFiddle into dba.se questions and answers
 
@PaulWhite True. That's why I use the GTD system and Bullet Journal (History)
 
9:54 AM
GTD?
 
@JackDouglas great job again. Is there a reason to surround tables between /* */?
 
@McNets it prevents syntax highlighting on dba.se, and I think it helps distinguish between the statements and results. Happy to persuaded there is another way though :)
 
64
Q: Please can we have markdown tables on dba.se

Jack DouglasSeveral sites have MathJax enabled, so there is obviously some room for site-specific markdown. Therefore please can we have markdown tables here on dba.se? There is an open feature-request for this on mSO, but whereas it is hardly a key feature for a programming Q&A site, a significant percent...

^ would prefer this of course
 
@JackDouglas I see.
 
 
2 hours later…
12:17 PM
Nobody is faster than G. L. on SO.
 
12:36 PM
1
Q: Simplify SQL server trigger logic

Royi NamirI have an Images table where that table has these basic columns — ImageId (int) VotesUp (int) VotesDown (int) Each image can get upvotes (up , down , retract vote) The upvotes table has : ImageId (int) UserId (int) Score (int ) [-1,0,+1] So if — A user inserts +1 score then ( if not ...

I can't see the simplification and it's driving me crazy becuase I'm sure that there is a better solution.
 
 
1 hour later…
1:49 PM
@RoyiNamir First of all, since your trigger is ON INSERT, UPDATE, you can't inner join inserted and deleted. It should be along the lines of inserted LEFT JOIN deleted. Also, if it's possible to insert or update several entries related to the same ImageId, your trigger won't work as expected. I would aggregate the upvote changes by ImageId prior to joining Images to them.
 
@TomV I bet you can get an autograph
of pinal
 
The simplification part itself is probably easy, although I don't believe you can do completely without CASEs. You are computing two results from the same column – obviously you need a conditional to choose which value contributes to which result.
 
2:05 PM
@Lamak And send it to Paul for his birthday
3
"The present you always wanted but never dared to ask"
 
that would be awesome
 
@AndriyM Andriy , why can't I , I explictly check IF EXISTS( SELECT 1 FROM DELETED )
 
you should ask 2 autographs then
one for Paul and one for Aaron
 
@Lamak I see your icon 10% loaded.... why ?:-)
 
the big brother
 
2:09 PM
@RoyiNamir Oh, sorry, I was looking at the first of the two queries, thinking it was the only one. I can see now that the one I was talking about is meant to processes only updated rows.
 
@RoyiNamir to me, the simplest way would be to do this in the software. Everytime a user votes, you perform an update in the images table and record the user vote
why depend on a trigger for this?
 
2:36 PM
@PaulWhite Not TF 8677. What does that one do? I can't find it on any of the lists.
 
@AndriyM It might be possible to use LEFT JOINs instead of CASE but I doubt it would be much simpler - or easier to read and understand.
 
@JoeObbish It's not on any of the lists. It enters search 2 instead of search 1 (maybe after search 0).
@TomV How very thoughtful.
 
@RoyiNamir I deleted my answer as it is not complete (realized after reading @AndriyM's comments above)
@McNets he has given a new meaning to FGITW
 
@PaulWhite he is, I bet you can't wait for your birthday now
 
Counting the days :)
 
2:42 PM
@ypercubeᵀᴹ let me read, I did't notice you're talking here about this question.
 
@McNets my code, I think you can't see deleted posts: dbfiddle.uk/…
 
@PaulWhite Looks like it stays at search 0 if it wouldn't normally make it into search 1, at least for this one query
thanks for the TF though
I was very unsophisticated in my approach... just inflated the cost a lot
 
@JoeObbish Yes, it just affects where to go after trivial plan/s0. Not every query qualifies for s0 (is what I meant by 'maybe after' before).
 
@ypercubeᵀᴹ I've saw it for a while before you deleted it.
 
@JoeObbish That's not unsophisticated.
 
2:52 PM
@ypercubeᵀᴹ yep, deleted too
 
:-(
So I guess i'll stick around with my solution ?
 
@RoyiNamir I still don't really get why you can't have 2 separate processes for every vote
 
@RoyiNamir One other point I meant to mention before we had a power outage here is that having one query to process the insert part and another for the update part kind of defeats the purpose of a single insert+update trigger. You could just as well have two triggers, one for each action.
 
@AndriyM I wouldn't even use a trigger
just run 2 sp's for every vote
no need to check for all those conditions
 
@Lamak Good point. If Royi is in full control of that part's development process, it would make more sense to introduce a stored procedure (or several, if necessary) and use it in all applications instead of direct updates and inserts.
 
3:04 PM
@AndriyM yeah, that's the part about this that I don't really get
I mean, in the software, you would know exactly if it's an upvote or a downvote, and run the corresponding sp's without checking the change in score and all that
seems like too much trouble really
one sp changes the score, the other stores the vote of the user or something like that
 
Then, of course, there's the option a materialised aggregate view.
Perhaps not a very efficient one. At least not for a site like SO, I guess.
 
@AndriyM yeah, but I don't see the need really...I get your point though
 
3:26 PM
@AndriyM I should read it carefully., thanks.
 
Looks like I'm ruining answers today.
 
3:48 PM
Where is the ` key located in your keyboard? I must press`and add one space to get it. For us it is used to accentuate: à è
 
@McNets top left for me, below escape, to the left of 1
 
º
ºC ºF top left for me is º
 
4:37 PM
@McNets What happens if you press it twice in a row?
 
@AndriyM If I press twice I get two of them
Then I can write between
 
@McNets that's the normal behavior of a keyboard with a language that admits accents
 
@Lamak .. and uses ` for that
 
@ypercubeᵀᴹ I mean, when you got accents, then that behavior appears for ` and ´
 
Yes, you are right. Just wanted to mention that it's not always the bacquote key that is used.
 
4:46 PM
of course
 
In Greek, it's the key next to L.
 
in spanish, at the right of the L we get the Ñ. The next key is the {[^ and then }]`
 
Fake keyboards
 
@billinkc ah, now I understand your comment
 
5:17 PM
@AndriyM Andriy , I don't see any problem with a single trigger which will handle update and insert statements. its whole purpose is to update rank on the Images table. Anyway I was after a simplified logic (if any) to my code in that trigger
An I certainly won't do it by code. ( it will hold the connection longer). So the only option left is Sp or trigger. Anyway I think that this kind of operation does fit a trigger purpose. I don't see any problem when an ran is added to votes table - to increase a value in other table.
This also saves me a begin tran
 
@RoyiNamir no, it's not the only option
you can run 2 sp's instead of just one
 
But why ?
a single trigger can do them both.
 
@RoyiNamir because right now you have to check every possible combination of change in score to get if it was an upvote or a downvote
 
This trigger purpose is to update rank in the Images table for a quick fetch
 
instead of just taking the knowledge from the action
and run the right sp
but well, do what you want
 
5:21 PM
Lamark , ofcourse I'm here to learn
But I also want to be corrected if I'm going to the wrong direction
let's say I have 2 sp's
 
I just don't get it
 
?
I don't see how 2 sp's saves me from anything
even if I have an update Sp , I still have to see what was the old value and was is the new value
 
well, I've already explained it, I don't want to really write an answer here.
@RoyiNamir why?, you would know if it was an upvote or not
and just change the score accordingly
no need to know the old value at all
 
Lamark - in that case i will have different logic. so i'm not saving anything here ( correct me if i'm wrong)
say a user downvotes an image
now the image rank is -1
 
@RoyiNamir I don't see a problem with such triggers either. I'm merely saying that the way this specific trigger is designed is hardly different from two separate triggers for each action, because you are using two distinct queries for each action anyway.
 
5:31 PM
now the user clicks again(!) -1
I will hve to have a logic to see if already downvoted and block this and to make that value 0
-
Also if user put -1 to an image , and now he sets it to +1
I will have to show that this image has less downvotes and more upvotes
each image is shown as [........image.......] 76 upvotes / 21 downvotes
and when a user change his mind from upvote to downvote - I will have to update two values PLUS checking if already downvoted
this is what i've made in my trigger ( more or less)
I just don't see the benefit of 2 Sp's ( it's just 2 places to deal with , with not less code ). Please correct me if i'm wrong.
@AndriyM I see the module division you're suggesting and you're right. But still that logic ( complicated and non-intelligent of mine - imho , In my current code) - well I thought it can be simplified ( and maybe it can't)
(Lamak I'm sorry , I see now that I wrote Lamark , by mistake).
 
@RoyiNamir the logic might be easier if you had 2 columns in the Upvotes tables, too: VoteUp, VoteDown that accept 0 and 1 only
 
@ypercubeᵀᴹ in a single row in upvotes table --- THOSE ARE THE VALUES
for the same image you and my and anriy can upvotes and that table will have 3 rows
 
    UPDATE imgs
    SET    VotesUp = VotesUp - del.VoteUp + ins.VoteUp,
           VotesDown = VotesDown - del.VoteDown + ins.VoteDown
    FROM ...
 
WITH
  DeletedAgg AS
  (
    SELECT
      ImageId,
      UpDelta   = COUNT(CASE Score WHEN +1 THEN 1 END),
      DownDelta = COUNT(CASE Score WHEN -1 THEN 1 END)
    FROM
      deleted
    GROUP BY
      ImageId
  ),
  InsertedAgg AS
  (
    SELECT
      ImageId,
      UpDelta   = COUNT(CASE Score WHEN +1 THEN 1 END),
      DownDelta = COUNT(CASE Score WHEN -1 THEN 1 END)
    FROM
      inserted
    GROUP BY
      ImageId
  )
UPDATE
  img
SET
  VoteUp   = ISNULL(img.VoteUp, 0)   - del.UpDelta   + ins.UpDelta,
 
Whoa wall-o-code :)
 
5:45 PM
@RoyiNamir single row, 2 columns I meant
 
@ypercubeᵀᴹ But I have to remember which user did what
 
@RoyiNamir I don't follow.
 
i know this is an unrealistic hypothetical, but i'd like some peoples' opinions here.

so microsoft says that they're going to either send you a PFE or get you a PSS support engineer. in which are you more confident?
 
@swasheck PSS. But PFEs can also be very good.
You also get better/faster the more money you donate.
 
(imgur seems to be down , I can't upload an image....)
 
5:53 PM
@PaulWhite thanks. that's what i thought. we've had some really good PFEs, and some really poor PFEs.
and have had a more consistent experience with PSS
 
@ypercubeᵀᴹ I'm checking it.
 
@RoyiNamir Yes. Seems to be.
 
Can we use computed columns in triggers (with INSERTED.computed_column)?
 
I think I got it ypercube
before that , I'm just remindering I have to know each user if he upvote / downvote
that's why in the upvotes table I have –ImageId |UserId | Score
(Just like in Stackoverflow)
Well here is the idea :
If you look at the upper section of the trigger :
UPDATE imgs

 SET    VotesUp = CASE

 	                WHEN deleted.Score = 1 AND INSERTED.score =0      THEN ISNULL(VotesUp, 0) -1
 	                WHEN deleted.Score = 1 AND INSERTED.score =-1      THEN ISNULL(VotesUp, 0) -1
 	                WHEN deleted.Score = 0 AND INSERTED.score =1      THEN ISNULL(VotesUp, 0) +1
 	                WHEN deleted.Score = -1 AND INSERTED.score =1      THEN ISNULL(VotesUp, 0) +1
 	                ELSE ISNULL(VotesUp, 0)
 	            END
 	            ,
 	VotesDown = CASE
You can see that VotesUP is calculated as :
 
@ypercubeᵀᴹ I can't think of any problems with that.
 
6:05 PM
deleted -> changed to a smaller value ? => negative
deleted -> changed to a higher value ? => positive
And I dont care if its 0 or 1 or -1
same goes for votesDown ( oposite way)
deleted -> changed to a smaller value ? => POSITIVE
deleted -> changed to a higher value ? => Negative
I think this whole update can be summarized to a single update
 
I suppose this means images won't work on main either.
 
I wonder if SE has a solution for that scenerious
 
No it does seem like an issue with Amazon S3 (and possibly EC2).
 
I mean what if imgur is shutdown forever ?
interesting...
 
It's not imgur. Their status page has:
> **AWS Outage** Identified - Imgur is currently impacted by the AWS S3 outage. Some browsing might still be possible, but expect poor performance and no upload ability until the issue is resolved.
Feb 28, 10:11 PST
 
6:14 PM
hi guys!
I got a flag from a user asking to get their question migrated over here, and I'm not quite sure about how well it would be received
5
Q: Locking in MySQL stored procedure for deduplication

Robert FraserMultiple upstream servers are sending notifications to a load-balanced django app. If all the upstream servers are working correctly, the app will always receive duplicates of these notifications (since all the upstream notifiers should send the same notifications; it's just for redundancy). I wa...

if you want it, I'll move it; otherwise I'll just decline the flag (OP asked to delete it, but there's one answer with one upvote, so I won't)
 
@Mat'sMug It's not off-topic for you is it?
 
good point
declining :)
 
Sweet. Thanks for asking!
 
Well I give up. I will stick with my trigger and that's it. it's working and I didn't find any suiting solution.
@PaulWhite I think it's something more serious.
I wanted to find if imgur is down :
And that site is also down
something is going on
 
could it be a sequel to yesterday's DDoS?
 
@RoyiNamir You replied to the wrong message, so I'm not sure which of my responses you are referring to. The status.imgur.com page would seem to be the definitive source, and that is blaming Amazon S3.
@Mat'sMug Maybe SO was a test run?
 
Yes wrong refrence . sorry
 
hmm... IoT toasters are taking the world over
 
@RoyiNamir Have patience. People may be working on an answer for you. Perhaps they'd like to be able to post images ;)
@Mat'sMug Internet of Threats.
 
I'm doing my part
I don't think I'm in the target market though
my appliances have enough issues without being on the internet
 
6:24 PM
gosh, almost 1:30PM ...lunch time!
 
@PaulWhite definitely not a test run - meta.stackoverflow.com/a/344699/426671
 
@bluefeet How does that make it definitely not a test run?
AWS status: "We've identified the issue as high error rates with S3 in US-EAST-1, which is also impacting applications and services dependent on S3. We are actively working on remediating the issue."
I knew this cloud thing wouldn't last.
 
@PaulWhite just pointing out the articles that mention something similar happening before
 
@bluefeet Oh sure. And I agree it's probably not related - but the attack on SO could have been a smaller-scale test run for an attack on AWS.
Without being able to post images, speculating about it is the most fun I can have right now.
 
ah true.
 
6:32 PM
Why anyone would need an internet-connected soccer ball is beyond me :)
 
why wouldn't you?
 
So you don't contribute to DDos attacks :-D
 
lock that stuff down!
 
@PaulWhite it can tell you how hard you kicked it?
 
@JoeObbish Goodness only knows. Perhaps to upload GPS data of where it was during a game, but seriously!
 
6:38 PM
@RoyiNamir check my effort: dbfiddle.uk/…
I must be doing something wrong in the UPDATE trigger. The INSERT one works
 
@ypercubeᵀᴹ Thank you for that ypercube
@AndriyM Thank you
 
@ypercubeᵀᴹ You're setting UpVotes and DownVotes to NULL for ImageId 2 & 3. It pays to always specify NULL or NOT NULL in the table def, otherwise you're depending on a default.
 
i blame cloudflare for the outages
A new comment makes me want to flag my own (one of the early ones) answer as NAA :)
 
6:53 PM
@PaulWhite Thnx. I'll leave to @RoyiNamir to fix it. Have to catch a bus ;)
 
Then again all the answers on that question should have been comments
 
@ypercubeᵀᴹ Cool. Just to be clear, making the column nullable allows the trigger to complete instead of throwing an error (which dbfilddle does not pass on). The code still needs fixing. For example INSERT dbo.Upvotes (ImageId, UserId, Score) VALUES (1, 0, 1); produces the same problem.
 
SO I guess (did that work?)
 
@TomV Yep :)
Also deleted is always empty for an INSERT trigger.
 
@PaulWhite Also inserted is always empty for a DELETE trigger
(don't know what I'm saying though)
 
7:04 PM
It's true.
 
that I don't know what I'm saying?
 
the heads of my developers are always empty for all SQL statements
 
@Lamak both
 
that makes sense
 
I don't know any more
I had to thank Bill yesterday
I'm confused
 
@swasheck are they triggers or not? In any case, how often do they get fired?
3
 
@dezso not often enough
 
@TomV you what??
@dezso that was quite clever
 
@Lamak had to think hard
 
you can take the rest of the day
 
7:10 PM
@Lamak Yea, I couldn't sleep knowing what I did
 
@Lamak well, I got a paper saying I am allowed to rest the whole week
and that's what I am doing
 
@dezso surgery?
 
@swasheck not yet
only a bronchitis
 
@dezso you shouldn't be thinking hard then
 
you should have that lung removed
 
7:13 PM
a well deserved punishment
 
soooo the cloudpets thing ... the dbms in question ....
Mongo!!!!!!!!!!!!!!!!!!!!
 
@swasheck hey, didn't realize it was you with that gravatar
 
notoriously lackluster with security
@Lamak curveball
 
@swasheck The RDBMS or the web 3.0 admins?
 
@TomV ahem DBMS and the admins
 
7:16 PM
I overheard a discussion during lunch a few weeks back
A bunch of mongodb "admins" discussing some setup, and every 2 sentences I thought "Oh really, get a reliable system then"
Drop the buzzwords and get to work!
2
 
maybe their work is using buzzwords
 
but that wont get me ad clicks and notoriety
 
I forgot to troll them with an "eventually" joke, too bad
 
dude, forgetting to troll mongodb admins, thanking @billinkc...is everything ok?
 
^^^
 
7:24 PM
guys, a serious question. Which software do you recommend to document a SQL Server database? (definitions)
 
Contemplating the pythian opening but I'm not sure I'm good enough for that team
 
I think Shawn Melton, used to chat in here from time to time, has been happy with them
US org though
 
@billinkc Yes but I'm fairly sure I'd be rejected based on my resume
 
Not sure how the EU side will do
That's a trick statement, you use CVs over there
 
@swasheck that's ugly on so many levels
 
7:29 PM
And I'm not sure I want to drop my Dynamics exp points
 
@swasheck and in any case, I really don't get this IoT thing - I know enough about security to not allow anything like that in my flat/car/etc.
 
@TomV Specializing in an ERP means you have to be pretty close to the business side, right? How often do you get called into solving purely business problems?
 
@RoyiNamir Why are you using a trigger at all? Seems like it should be an indexed view, then SQL Server automatically keeps everything consistent for you.
I added an answer.
 
@Forrest I never get called into fixing a business problem
but I often have to point out a performance/database problem really is a business problem
"users in production are blocked" "yea but you should run that during business hours" type of thing
 
@TomV you are ready to be a consultant
everything is always a business problem
 
7:39 PM
@Lamak It isn't but when working with an off the shelf software some things can't be easily fixed technically
so a lot of times it's either a software/business/budget problem
 
@TomV So do you tell them the software/business/budget solution, or say it's not in your domain?
 
I tell them the truth, usually
I don't try to get away with "its not my domain"
but there is a difference between responsability and domain or how do you call it
 
@TomV are you the master of your own domain?
 
@Lamak Tricky question, I have no domain :)
unless "whznever the rest gives up is a domain
 
well....it was really a Seinfeld reference
thought you would get it
 
7:47 PM
Ah no, I didn't like seinfeld
 
too bad, that particular episode was hilarious
 
@RoyiNamir I would have used PIVOT, but indexed views don't allow PIVOT. SUM(CASE... works fine.
 
someone said pivot!
 
hey @PaulWhite, do you know of a nice tool to document a SQL Server database?
hi @bluefeet
 
@Lamak is bidocumenter still maintained
 
7:54 PM
@Lamak heya
 
@TomV gonna look for it
@bluefeet how's everything going?
 
@Lamak Not really my thing. Did you read the Q & A: How do you document your databases??
 
@Lamak it used to be a codeplex thing, I haven't looked at it in years
 
@Lamak it's good. How are you?
 
I mean, I'm doing it now
@TomV thanks
@bluefeet everything's well, thank you
 
7:57 PM
@bluefeet Well played. I assume the GIF is unavailable at this time?
You rang?
 
@PaulWhite it's here but I didn't want to torture everyone with an animated gif
 
This lot deserve everything we throw at them.
 
I assumed you wanted to use PIVOT because everyone knows it's faster
 
@JoeObbish 'Twas implied, I hope :)
 
00:00 - 20:0020:00 - 00:00

« first day (2247 days earlier)      last day (2615 days later) »