« first day (766 days earlier)      last day (4103 days later) » 
00:00 - 18:0018:00 - 00:00

6:00 PM
ok lol
you ever have one of those ideas you think is BRILLIANT and then it comes back and just bites you in the ass in a few years
 
@rfusca having kids?
kidding. i love mine
 
@swasheck lol no
@swasheck how many you got?
 
@rfusca dos zwei ni
 
ic
 
@swasheck No UNION is a logical concept. There are several possible physical implementations, only some of which involve sorting. Also, optimization may remove a UNION or translate it to something else given the context of the query as a whole. It is a mistake to try to correlate features from a declarative SQL statement to a particular physical implementation. That said, it is valid to look at an execution plan and wonder "where did that sort come from?"
 
6:14 PM
it's fun for the most part. today i'm working from home because the oldest is sick
 
DECLARE @T1 AS TABLE (col1 int);
DECLARE @T2 AS TABLE (col1 int);

INSERT @T1 VALUES (1), (2), (3);
INSERT @T2 VALUES (2), (3), (4);

SELECT col1 FROM @T1
UNION
SELECT col1 FROM @T2
OPTION (HASH UNION, HASH GROUP);
 
so now i get to see all of your (pl) imgur posts
 
Is there a better sargable way to get the date at midnight? Obviously my lack of sleep is getting to me. Current code -- CAST(FLOOR(CAST(getdate() AS FLOAT ))AS DATETIME)
 
@SQLKiwi that's kinda where i was. where's that SORT operation coming from?
 
@swasheck I don't know, I can't see it :)
 
6:16 PM
@SQLKiwi no, i know ... i'm just saying that's what prompted my question in here about it
 
@swasheck i'm working from home because my boss said "There's a release friday night...nobody else will be in the office...you should work from home too."
 
@bluefeet In SQL Server? By the way casting datetime to float is just offensive ;)
 
@SQLKiwi but thanks for the wicked-cool explanation
 
@swasheck No worries, any excuse to post an execution plan!
 
@SQLKiwi yes in sql server. Let me just say that is not my code, it is in a very poorly written stored proc that was handed to me to fix
 
6:17 PM
@bluefeet In SQL Server 2008 a cast or convert to the date data type is very popular.
 
@SQLKiwi i wish there was a way to trick the Execution PLan to use different names so that i could post it without fear of backlash from "the man"
 
@SQLKiwi How about 2005?
This code is in 2005 so cast to date doesn't work
 
working with dates in sql server....nightmare
oracle is marginally better
 
@swasheck I can never understand the general reluctance to post execution plans with table names and such in them. Do people really think they're using such amazing concepts that their whole business could be ruined this way? Pah.
 
@rfusca mongo kills it though
 
6:19 PM
@swasheck hmm i've not played with dates in mongo much
pg is freaking awesome with dates though
teradata is better than oracle but not as good as pg I think
 
@SQLKiwi i could talk until i'm blue in the face to my boss about that, but he's very sensitive about it. that's why i'm so guarded
 
@bluefeet SELECT DATEADD(DAY, DATEDIFF(DAY, '20000101', CURRENT_TIMESTAMP), '20000101');
 
@rfusca i see your sarcasm detector needs to upgrade it's heuristics
 
@swasheck oh
lol
 
@swasheck Yes. My question was why. I do not understand it at all - unless it's fear of embarrassment?
Everyone's database code sucks, people shouldn't be afraid of that.
@bluefeet Any fixed date will work. Many people use zero instead of a date, but the implicit cast offends me. Is the logic clear?
 
6:22 PM
@SQLKiwi I thought datediff was not sargable
 
@SQLKiwi well i think that my director is a paranoid schizo. super nice guy but WOW is he delusional about worst-case scenarios
 
@bluefeet It depends on the context, hang on a second.
@swasheck Oh I think I see your problem :)
@bluefeet Not when applied to a column reference, no (unless a convenient indexed computed column exists). It's fine as a seek value though:
DECLARE @T1 AS TABLE (some_datetime datetime PRIMARY KEY);

SELECT *
FROM @T1 AS t
WHERE some_datetime = DATEADD(DAY, DATEDIFF(DAY, '20000101', CURRENT_TIMESTAMP), '20000101');
 
(by the way, how cool is it that we have P.. SQL Kiwi and Aaron Bertrand in here just interacting with us ... teaching and chatting away)
4
 
Paul White you mean? I don't know, I've heard he's a bit of a dick.
 
i heard he had a good heart
Paul Dudley White (June 6, 1886 - October 31, 1973), American physician and cardiologist, was born in Roxbury, Massachusetts, the son of Herbert Warren White and Elizabeth Abigail Dudley. He was one of the leading cardiologists of his day, and a prominent advocate of preventative medicine. Early life and education White's interest in medicine was sparked early in life, when he accompanied his father, a family practitioner, on rounds and house calls in a horse and buggy. A 1903 graduate of the Roxbury Latin School, his undergraduate education at Harvard College encompassed history and fores...
 
6:34 PM
@SQLKiwi ok, thanks for the info
i have drive by downvoters
 
I was about to ask if this question should be on DBA
0
Q: catastrophic failure trying to select from linked server

Артём ЦарионовI have created a linked oledb/odbc connection to Pervasive SQL from SQL SERVER 2012: USE [master] GO /****** Object: LinkedServer [KSLAP208] Script Date: 2/8/2013 10:38:55 AM ******/ EXEC master.dbo.sp_addlinkedserver @server = N'KSLAP208', @srvproduct=N'Pervasive ODBC Interface', @provider...

and then I saw that it is aptem
 
njk
@Lamak Who is aptem?
 
@njk Oh, you don't know aptem
 
njk
Nope. Enlighten me
 
hm, not sure how can I explain it
 
njk
6:46 PM
I see he has 1250 questions
 
@Lamak shhhhhhhhhhhh
 
@swasheck?, your help
 
@njk you should help him. the best way to learn is through experience, right?
 
njk
@swasheck I'm not getting myself into something if you guys are with holding
 
@ConcernedOfTunbridgeWells Tomorrow pm should be fine
 
6:47 PM
@njk we may be kinda biased
 
njk
@Lamak Help me understand your bias
 
@njk No, go right ahead. I'll get the popcorn. We have your back, honest.
 
But is a guy that asked a lot of terrible questions, had the habit to kinda stalk users that helped him....
sounds very grateful
 
njk
@Lamak Oh no.
 
but then starts changing his questions
 
njk
6:49 PM
@SQLKiwi Thanks. Care for some butter on your popcorn?
 
and keep on asking
and asking
 
@njk Ooo ta
 
sometimes accepted answers, then had new questions, then unaccept
 
njk
@Lamak Looks like Gordon answered
 
so, he got himself in the position where many of the regulars here (through expierence) decided not to keep helping him
 
6:51 PM
wow... he's got 25 famous question gold badges....
 
njk
I suggested he take his question to dba. Hope you guys don't mind ;)
 
@MichaelFredrickson yes, he has 27 gold badges
@njk I have the feeling that you are gonna be on @Aaron's "favorite" users list for that
;-)
 
njk
@Lamak Ha :)
 
@rfusca it is a rhombus
 
@Lamak @SQLKiwi @njk I'M GOING IN
 
7:02 PM
@swasheck best of lucks
 
njk
@swasheck You'll be remembered
 
@jcolebrand exactly, and thats the awesomeness considering my 4 year old little girl knew that
 
@rfusca verrnice
 
7:19 PM
@rfusca My advice is to not confront the teacher (unless you know he/she is a cool guy). I'd say to my daughter that is a Rhombus and some people call them Diamonds, too.
Up to age 10-11, teachers should be always right, in kids minds.
 
@ypercube eh, she knows its both (rhombus and diamonds)..but the teacher was trying to say it wasn't a rhombus to her then
 
@ypercube feel free to remove that code from my answer and post your own.
 
Nah, I don't feel like posting at SO tonight.
 
@ypercube I am just about done posting tonight. New users who don't get the typical rules of accepting are driving me nuts
I had someone start commenting about how great my answer was and that is helped them but then they accepted a different one. WTF
 
njk
@bluefeet Yeah I feel you
 
7:26 PM
not only that but they got 3 different answers from me.
0
Q: SQL, multiple rows to one column

user2051103So I have the following date ID NAME MONTH COUNT 1 David December2012 500 2 Rob December2012 320 1 David January2013 400 2 Rob January2013 280 I am trying to make this....... ID Na...

I think the lack of sleep today is causing me to have very little patience
 
njk
@bluefeet If it makes you feel better, I gave you +1
 
@njk ha thanks
 
njk
@bluefeet Also wrote a comment.
 
i see that
 
It's a newbie. He probably wanted to accept your answer and hit in the wrong place.
 
7:30 PM
@ypercube I would agree but he had accepted and then changed to the other one
 
@bluefeet Are you aiming for the Legendary badge?
 
@ypercube yes I am
I have 111 days at this point
I want one and my gold pivot
 
Hi, I'm running a small webserver with a MySQL backend. I recently added indexes to a number of my tables, and ever since then my disk IO has gone up tremendously
I was seeing a bunch of "unindexed join" warnings prior to adding the indices, and I had slow performance prior to then, so that's why I added the indices
 
njk
@Guillochon Adding indexes without understanding why is not a good idea.
 
I understand why...
 
7:33 PM
@Guillochon dba.se
 
I don't understand why it would actually increase disk IO so much
 
@Guillochon Insert heavy?
 
No, not really
 
@Guillochon Wide or narrow tables?
 
Maybe 1 insert for every 1000 selects?
 
7:35 PM
InnoDB or MyISAM?
 
MyISAM
The tables are pretty narrow I think...20 columns at most
Adding the indices did get rid of 90% of the unindexed join warnings, so I'm pretty sure I did them correctly
And when I "explain" it does show the index
 
@Guillochon Not a MySql person myself but is it possible the new indexes have resulted in plans that are causing sort spills?
 
@MarkStorey-Smith That I don't know
 
Can you catch a slow query and post it as a Q on the site?
 
Ultimately, is the disk IO increase a problem given that you've resolved your perf issue?
 
njk
7:37 PM
I really hate being called bro
http://stackoverflow.com/questions/14779865/how-to-show-a-message-if-user-is-logged-out-because-of-session-time-out-in-php/14779885#comment20693267_14779885
 
with the EXplain plan and the tables definitions?
 
Are you close to exhausting the IO capacity or is it just higher than it was
 
@MarkStorey-Smith The website becomes completely unresponsive now when the traffic increases above a certain level
 
@njk chill br.. I mean, chill, man
 
and which (exact) version of MySQL do you have?
 
7:38 PM
 
njk
@Lamak :-)
 
That's the disk usage in the last 30 days, the spike is after adding the indices
mysql Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (i386) using readline 5.1
 
Any other recent change in the website that might have caused this?
 
The reason I did this in the first place was that I was having some performance issues to begin with, loading the entire tables into ram
and going into swap
it seems now it's not going into swap anymore, but instead reading from the disk far more frequently for each query
 
it may be using more temporary tables.
 
7:42 PM
any ideas on what i could try?
I could just remove the newly added indices, but then I go back to where I was
 
That's one idea. If the IO goes back to where it was before, at least you know what caused it.
How many indexes are we talking about?
 
I had about 6 tables with just the default primary index
I looked at my logs to determine which columns were being used to select, and added indices based on those
1-2 per table
 
Can you show us a table definition, as it is now, either at Pastebin or at the site?
or in a SQL-fiddle?
 
sure, how do i output the definition you would want to look at?
 
SHOW CREATE TABLE tablename;
 
7:47 PM
OK, just a moment
 
@Guillochon text columns? why?
Can you run this?
SELECT MAX(CHAR_LENGTH(votes)) AS v,
MAX(CHAR_LENGTH(sinks)) AS s,
MAX(CHAR_LENGTH(affiliation)) AS a
FROM wp_votes_users ;
 
@njk but is it still OK if we call you brah instead of bro?
 
njk
@MichaelFredrickson Yeah brah is cool
@MichaelFredrickson lol
 
| v | s | a |
+------+------+------+
| 5568 | 234 | 35 |
 
oh wow
0
Q: Joining 100 tables

iCoffeeAssume that I have a main table which has 100 columns referencing (as foreign keys) to some 100 tables (containing primary keys). The whole pack of information requires joining those 100 tables. And it is definitely a performance issue to join such a number of tables. Hopefully, we can expect th...

 
7:58 PM
@bluefeet ya...thats the big 300 text field guy
 
@Guillochon I'm kind of afraid to ask what kind of information you are storing the votes column. Up to 5568 characters to store, votes?
 
njk
@bluefeet Oh my.
 
@ypercube It's a comma-delimited list of times in unix format
 
@bluefeet does sql server ever do join removal wiki.postgresql.org/wiki/… ?
 
@ypercube I'm sorry, it's a list of IDs...got that confused
@ypercube Example: 5474,6637,17482,17480,111645
 
8:01 PM
@rfusca I think yes. @SQLKiwi was saying somethign about that. But it was sometime last year, I can't remember the details.
 
@rfusca Yes, since version 7
 
@SQLKiwi well there ya go...properly done, join to 100 tables and only using a few of them shouldn't be a big deal then, right
 
@Guillochon And the other 2 columns, sinks and affiliation, are similar, comma-separated lists?
 
affiliation no, that's just a string
 
@rfusca Properly done - but that's rare and 100 is still quite a lot. The view would need left joins, for example.
 
8:07 PM
@SQLKiwi ic
 
So, one thing maybe that could be a hint: I had added an index to another table, but it seemed like it introduced a collision into one of my queries...e.g., two results were returned because the key only used the first 10 characters
 
@Guillochon whoa. That's even wildly different from last night
 
@Guillochon The results of a query would not change by an index.
Unless you changed the query, too.
 
I deleted the index, repeated the insert operation, and there was no collision
 
8:09 PM
1
A: Joining 100 tables

Gordon LinoffWhy do you think joining 100 tables would be a performance issue? If all the keys are primary keys, then all the joins will use indexes. The only question, then, is whether the indexes fit into memory. If they fit in memory, performance is probably not an issue at all. You should try the quer...

Down-voted that lazy-ass answer. Compilation time, dude.
 
I didn't specify "unique" in the key index, so I am somewhat confused too...
 
fellow professionals - it wasnt nearly as bad as i feared
 
@ypercube SRSLY, gist is where it's at.
@swasheck he survives unscathed!
 
@SQLKiwi he posts a lot of half-ass answers
 
@jcolebrand i believe you meaned "unpropositioned"
 
8:12 PM
my favorite line from many of his answers is this code is untested and probably has syntax errors
2
 
@ypercube Yeah I don't think it should change either...it's also just possible the insert timed out because of all the disk IO...
 
@swasheck I don't even know where you went ;-)
 
@jcolebrand I know. I feel ashamed.
 
@jcolebrand i answered an Aptem question
 
ok, now everybody focus on @Guillochon who is aware dba.se exists and who is not a MySQL admin but who is having heavy IO issues and can't figure out why. He has a linode VPS and used MySQLTuner (or something like that) to tell him he needed indexes, and after adding those the system is nigh unusable.
He also has been referred to use the index luke already, so let that go too ;-)
 
8:14 PM
@bluefeet Right, I see. (and have a star)
 
@SQLKiwi woo hoo I got a star
There seems to be a real battle over this answer . . . several upvotes and downvotes. It would be really nice if the downvoters would explain their downvote. — Gordon Linoff 50 secs ago
 
@jcolebrand well, i've said it before. Back when I was a heavy mysql user, adding too many indexes seemed to 'confuse' the planner, but it was an older mysql
 
my wife says that i like to start fights through antagonization, but i don't see it
Didn't downvote but it seems more like a series of comments than an answer — swasheck 2 mins ago
 
@Guillochon I see several issues:
1. The comma-separated columns. That's a no-no-no. Read these (when you have time) about why: Is using multiple foreign keys separated by commas wrong, and if so, why? and Is storing a delimited list in a database column really that bad?
2. the text columns. Three text columns make a table really wide. If all your tables are like this, it's not good. Of course you can't chop them to narrower columns, like VARCHAR(200) when they have comma-separated lists.
 
Is there some new use for a parenthesis that I'm not aware of?
You are crazy ))) Maybe multiple views will help? — Art 19 mins ago
@swasheck and all - I think I should upgrade my comment to answer.))) — Art 2 mins ago
Super smile with no eyes maybe?
 
8:22 PM
@MichaelFredrickson bigger smile than a normal smiley
 
For the pressing problem of IO, I think that you should revert the changes and drop the indexes you have created. If that helps to bring into the sistuation you where before (no high IO), that's good.
 
and absent the colon because those are as bad as photographs, they'll steal your soul man
 
@ypercube why would those make it so a index would make it worse?
 
@jcolebrand Call me old fashioned, but I prefer faces with eyes...
 
@ypercube agreed
 
8:23 PM
@jcolebrand @MichaelFredrickson toothless grin??
 
@MichaelFredrickson ahem "old"
BAZINGA!
 
with a VPS is possible that it could be a IO problem regardless that showed up around the time you were making the indexes
 
@jcolebrand lol...
 
@rfusca The indexes may have caused, as @jcolebrand suggested, changes in the execution plans.
@rfusca I agree on that, too.
 
@rfusca or the IO issues could be from the fact that he's got shared disk from being on a linode server (is that a thing, can that cause this)
I honestly don't have the ability to answer that question right now
 
8:25 PM
@jcolebrand right, thats what I"m saying. The IO problems may exist independently of the indexes but coincidentally around the same time.
 
@rfusca also note: ongoing IO issues for at least a month that he was hoping to reduce contention for his db over, hence pursuing these changes.
 
ah
 
but he recently changed hosting providers
(it really sounds like we talked about this for over an hour last night doesn't it? :p)
 
well, in general a linode vps isn't going to be a hi pref box - compared to dedicated hardware - whats the expectation?
 
@JNK that Apex abomination is pigging up my system.
 
8:29 PM
@jolebrand @guillochon is there a Q about this with the details?
 
Hi guys, I have to take off for a bit, I'll look at the comments a bit. Sorry to leave in the middle!
 
yo dawg ... i herd you like table scans so i removed indexes so that you can scan your tables while you're scanning tables
(im to my new dev)
 
It is not often I post an answer on SO.
 
@SQLKiwi but when you do it's to thunderous applause
 
8:55 PM
@Marian I was giving the benefit of the doubt. Many ties people get the answer and then change the question and are told to ask a new question
 
@rfusca no, he asked in chat last night, I told him to come back tomorrow (meaning today)
@Guillochon just make sure you remove the indexes you added and we'll go from there
 
9:36 PM
First world problem: I dropped my phone in the toilet last night... now I don't have anything to look at while using the toilet.
 
@MichaelFredrickson you can still look at your phone
 
@swasheck Not the same any more... now it's just a lifeless token of my stupidity...
 
10:10 PM
@MichaelFredrickson You can use the DRY principle :)
Confused. Is this how EF is supposed to be used?
0
Q: How to specify EF relationships that require SQL cast?

RMartI have two legacy SQL tables: Contact Id(uniqueidentifier, not null) Foo GlobalId(nvarchar(50, null) EntityName(nvarchar(100, null) The Foo.GlobalId column stores the ID from other tables in the DB, so to get at relevant data, we'd join tables like this: select * from Foo inner join ...

 
10:37 PM
just for fun i want an RDBMS vendor to change their default ORDER option to DESC.
not that i'm a T-SQL genius but i never knew you could do a TOP (3) PERCENT
 
And in completely unrelated news, LinkedIn just sent me an email saying I'm in their top 10% most viewed profiles. I feel truly validated.
 
@swasheck even better you can do top 3 percent with ties
 
@ConcernedOfTunbridgeWells i'll just hit F5 on your profile until you're in the top 1%
@bluefeet i knew about with ties ... but the percent is new to me
 
@swasheck we used to use top 100 percent in a view so you could include an order by
 
@bluefeet hm. fancy that.
 
10:47 PM
@swasheck Oh, now that's just pretentious. Anybody would think I'm just in the habit of hangout on web sites trying to amass internet reputation or something.
 
I am smooth. Sent the guy in accounting 5 PDFs as he's having issues hitting the SSRS site. 4 were the ones he was looking for, the 5th was a brochure explaining the benefits package of the place I interviewed at
 
@ConcernedOfTunbridgeWells seriously. who does that??
@billinkc DOH!
 
@swasheck I don't know. People with no life, I suppose.
 
@swasheck Smooth like buttah
 
@ConcernedOfTunbridgeWells y'know, you're probably correct.
so ... OFFSET-FETCH ... does OFFSET 50 mean the result set starts with row 50 or 51?
looks like 50
 
10:54 PM
@billinkc It should really have been a fake job offer at about 30% over what you're on now.
Then go and ask for a raise claiming a higher offer than that. See if they offer you something matching the 30%
 
@ConcernedOfTunbridgeWells even 10% would be a net win ... unless you just really want that job at pragmatic
 
Best to make it worth while if you can.
 
I'm actually trying to figure out what that number should be for the new company. Oh well, something to ponder for the weekend
have a good weekend lads
 
you too
 
njk
11:22 PM
Sigh, 24 rep away from 10k
 
@njk hmm... looks like you got 10k to me....
 
njk
@MichaelFredrickson Yeah that escalated quickly
Glad to make it to the 10k club
 
@njk grats... enjoy the mod tools...
 
njk
@MichaelFredrickson A little surprised that there were so many flagged.
 
@njk stackoverflow.com/tools is the fun page... dog pile on all the terrible questions / answers...
 
njk
11:28 PM
@MichaelFredrickson I'm really surprised. Gonna read the moderator instruction manual.
 
11:44 PM
Has anyone seen ampersands added before and after table names, like this, in SQL-Server?
  from
    &users& u,
    &ub_usac_ms_prof& um
 
@ypercube Never... is that valid syntax?
 
Could it be for pushing the queries through some sort of pre-compiler (that converts &tablename& to [dbo].[tablename]) ?
 
I would think it would have to be... I don't think it would be valid syntax unless it were [&tablename&]
 
& as a prefix in Oracle causes SQL*Plus to prompt for a value (if not already set). Not that that helps :) (Just an observation)
 
soooooooooooooooo glad I wasn't on the team I used to be on for our application support. they're about to get reamed lol. They've been ignoring an alert all day and the boss couldn't get ahold of any of them
but in 4 minutes they all have a conference call
 
00:00 - 18:0018:00 - 00:00

« first day (766 days earlier)      last day (4103 days later) »