« first day (2120 days earlier)      last day (2754 days later) » 

1:56 AM
@Philᵀᴹ Done.
 
 
6 hours later…
7:29 AM
MondayMorning all
 
Morning Phil
 
7:47 AM
Morning
 
8:15 AM
morning
 
Morning
 
9:09 AM
1
Q: Optimizing SQL Server for an app that repeatedly hits the database with the exact same query?

Ivan McAI am dealing with performance issues with a Windows app that uses SQL Server Express (2012) on the back-end. I have managed to get this running a lot better primarily by reviewing the indexing SQL Server side but there is one particular report that is still running quite slowly. Looking into wh...

a table named "Table". Awesome.
 
@ypercubeᵀᴹ Does what it says on the tin
 
@Philᵀᴹ Yeah, the problem is not the name anyway. That "app" is probbaly doing something funny when conencting to SQL Server
Dropping and reconnecting each time? No idea how to test this in SQL Server, without access to the app's code.
 
It'll be an ORM or something. Get a row, formulate other queries based on the data in that row, etc etc
Lots of back-and-forth, that'll easily be replaced with a single query. Seen it a million times before
 
 
2 hours later…
11:07 AM
@ypercubeᵀᴹ and with a column data varbinary(max) you are good to go.
 
11:35 AM
@MikaelEriksson Sure, just store zipped json in that column and you have all your bases covered
 
You can encode it in base64 to be sure.
On a different note, am I missing something here:
I'm not sure I understand what the problem is. If all the databases, including the shared one, are on the same server instance, why do you need to replicate the shared database's data in other databases instead of just accessing the source directly from the application when required? — Andriy M 3 mins ago
 
11:52 AM
@ypercubeᵀᴹ - the number after the query is the number of times that exact query is being executed, i.e. the query "SELECT * FROM "Patient" WHERE "_Recno" = 35051" is being executed 106 times, with that _Recno. There are actually 1,031 queries being executed to build this report (in this instance, it varies) - the 23 or so above are the DISTINCT queries. As to how it connects, it is using Windows authentication and I am pretty sure TCP/IP but I don't think I'd be able to change this anyway. Can you think of performance options related to that? — Ivan McA 52 mins ago
@MikaelEriksson My wild guess (based on the above comment ^^^) is that the app/ORM sends a query for each column of each table it needs. Or something equally silly.
 
12:35 PM
My bad, I'll correct this now, but ignoring the syntax errors, it should work — Neil P 18 mins ago
 
@TomV VtCd as unclear
 
@TomV Well, I wasn't expecting that answer...
 
12:56 PM
@MarkSinkinson Interesting, he may be right but there is no way to tell without working code
 
@TomV I saw that comment, too. Would be happy to know how to make SQL server ignore syntax errors ...
@TomV He answered the question himself.
 
@ypercubeᵀᴹ Yes but he didn't apply the fix or test with maxdop=1 as far as I can see
 
The answer could be shortened: I should have checked my calendar earlier.
I was frozen for 5 years.
@TomV Yeah, we can't be sure that this was the reason. Still, 6 years unpatched ...
 
@ScottHodgin Is the database already encrypted with a certificate? If so are you replacing YourNewCertificate with the name of your certificate?
 
@ypercubeᵀᴹ and then patch it to SP2 CU13 instead of SP3, meh
@ypercubeᵀᴹ to be fair, I remember reading about that bug a lot more recently and it's still in 2014 RTM
 
1:18 PM
0
Q: Query execution takes so much time

Sohail TaiI am trying to insert data into Temporary table with the help of Select Statement The query is: insert into tempProductCategory1 select * from ProductCategory ; Problem is that this query running fine but takes so much time.When I check the execution status with the help of show...

Needs some anti-love
 
anti loved
 
@ypercubeᵀᴹ yeah the windows team thought it would be fun if they passed a new policy that hosed all of our permissions.
 
2:09 PM
And mirror can't reach port 5022
 
2:35 PM
Gah I hat this crap. I'm not a sys admin
This isn't my jam
 
Group Policy can be hilarious when done wrong. Laws are going to be the same when Donald Trump gets into power. He'll be pushing them and people will be WTFing
 
I don't even know where to begin granting access to this port
 
@Philᵀᴹ Donald Trump is in favour of Group Policy?!
 
3:06 PM
@PaulWhite What have I come into in this room
 
3:18 PM
Network settings look the same. I wonder if I just need to restart the service.
I'm confussled
 
@jcolebrand Just teasing Phil :)
 
3:38 PM
Hmm Changed the port to 5023 which allowed me to start the service but I still can't mirror over
Getting connection failed. Errors. Super frustrated right now
 
Quiz (standard SQL): What is the output of this query?:
create table a (name varchar(10));

insert into a values
  ('one'),
  ('two'),
  ('three'),
  ('four');

select count(*) from a
where name in
  ('one',
   'two'
   '',
   'four');
1 2 3 4 or Error?
 
@ypercubeᵀᴹ error
I mean, I guess
 
3?
 
but the `'two'
'',` seems like an error to me
 
yeah, no comma
Only saw it in SSMS after pasting the code.
 
3:52 PM
'two''' would mean it looks for two'
 
@Forrest there's an enter between
 
Ah right
 
@AndriyM Does SQL server raise an error? I didn't try it.
 
But the "standard SQL" preface may mean there's a catch.
@ypercubeᵀᴹ It does
Msg 102, Level 15, State 1, Line 13
Incorrect syntax near ''.
 
@AndriyM aha
didn't try it either
 
3:59 PM
I think I remember something about MySQL treating consecutive string literals as parts of the same string. Effectively 'two' '' would mean CONCAT('two', '') and thus just 'two'.
But maybe that depends on the context.
 
This is frustrating! why did poeple come in the night and hose my instance
 
@AndriyM Correct!
@AndriyM Yes.
@AndriyM Indeed
 
And I've just managed to find that out for myself: rextester.com/ILU30820
Had to change the table name because it kept telling me that table a already existed. Hm, I wonder who might have taken it.
 
@AndriyM I'm more amazed that mysql has implemented according to the standard ...
 
@ypercubeᵀᴹ I've read that in their docs some time ago. Has it been in the standard a while as well?
 
4:05 PM
@AndriyM but are those consecutive strings if there's a carriage return between them?
 
@Lamak all whitespace and comments should be ignored
 
@Lamak I guess it doesn't matter: spaces, tabs, newlines – any white space.
Even comments, didn't know about that. There you are
 
hmmmm
 
4:17 PM
Yeah, so we were mocking MySQL and didn't even know that it had implemented a piece of the standard that perhaps no other major product had. So it's got at least one part of the standard absolutely right, even though that bit is utterly useless, even potentially harmful, capable of causing mistakes that you could take hours and hours to find.
 
SELECT 'bla''';
-- vs
SELECT 'bla' '';
in PostgreSQL the first one returns bla', the second one errors out
the example in the quiz works according to the standard @AndriyM
 
@dezso Indeed it does. This doesn't, though: SELECT 'a' 'b' 'c' AS s. But it works in MySQL (returns a column s with the value of 'abc').
 
4:47 PM
@AndriyM It's in the standard, yes. See the Postgres manual about string constants.
 
@ypercubeᵀᴹ Ah, so Postgres just requires there to be a newline, right. Interesting distinction.
 
@AndriyM Yes:
> Two string constants that are only separated by whitespace with at least one newline are concatenated and effectively treated as if the string had been written as one constant. For example:
And I don't know which version of the standard had this. The copy of 2011 I have does not mention "at least one newline".
Probably an older version.
Or the paid version
 
Oh, and they are saying: This slightly bizarre behavior is specified by SQL; PostgreSQL is following the standard. (Where by bizarre behaviour they apparently mean the fact that SELECT 'foo' 'bar'; is not valid syntax – because there's no newline there, I understand.)
So according to that, treating SELECT 'a' 'b' 'c' AS s as valid SQL must be an extension to the standard then.
 
@AndriyM in MySQL?
 
Yeah
 
4:56 PM
@AndriyM I guess. Or they were reading a a different version of the standard.
Or they implemented it without the exception "at least 1 newline"
Or they just did whatever they thought was convenient. Which is most probable, if we consider how they implement features.
 
Anyway, even though it turns out that at least one newline is required between two consecutive literals for the syntax to work as per the standard, I would still hate it to be implemented in T-SQL. I think it much, much safer if that always produced a syntax error, as it currently does (in SQL Server, I mean). There's enough possibilities for subtle errors already as it is.
 
5:18 PM
@AndriyM No argue there.
Postgres developers agree:
> The intent of allowing separators at all is evidently to allow very long
literals to be split across lines. Which is fine, but I wish they'd
used some explicit syntax to specify continuation. The existing
definition is pretty error-prone, as you found out.

regards, tom lane
 
5:37 PM
Not surprising. Pity that wasn't obvious to enough people at the time of suggesting the syntax as part of the standard (or when deciding to implement it in products that have implemented it).
 
6:15 PM
Who all is at Summit this week?
 
@billinkc which summit?
 
The one you're not at, the PASS Summit. Kin, Aaron, Meagan (tomorrow)
 
@billinkc ah, yeah, bummer I couldn't go
I don't want to be banned
 
@billinkc and Brent Ozar?
 
He's not a regular Heaper though
 
6:29 PM
@billinkc I gave my friend your name so he can go bother you in my place
 
6:41 PM
Double lie: you have no friends and I cannot be bothered
 
@billinkc I do have!
well....maybe
 
@Lamak Imaginary doesn't count
 
Exactly
 
well....still
@billinkc I mean, I hope he does bother you somehow
I just hope he doesn't get too scared about the guy with the weird head and a skirt
 
so mean
 
6:47 PM
that may explain the "no friends" thing
 
'm so happy 'cause today
I've found my friends ...
They're in my head
3
 
@TomV now, this may explain @billinkc's head
 
7:27 PM
@billinkc I can most definitely refute the cannot be bothered part :-)
 
8:03 PM
@mmarie good to know
 
@AndriyM well, the original idea behind SQL was something very different from how we use it
where 'we' means the heapers, and, in a broader sense, people capable writing good queries even for complex problems
On another note, this must be/must have been fun:
1
Q: Can't Delete Orphaned MySQL Temp Table

ChrisOne of my servers had a hick-up yesterday and decided to leave temporary table while (while running alter table add indexes). ls -l *sql* -rw-rw---- 1 mysql mysql 8570 Mar 13 12:05 #sql-ib32694.frm -rw-rw---- 1 mysql mysql 98304 Mar 13 12:05 #sql-ib32694.ibd mysql> drop table `#mysql50##sql-i...

@ypercubeᵀᴹ Sorry, you need Flash to play this.
 
8:45 PM
Are there a sqlwiki in here?
@PaulWhite 's twitter handle according to Itzik :)
 
you mean sqlkiwi?
or was that the joke?
 
Not a joke but rather funny mistake by Itzik.
 
I see
 
He is talking about what would be the best answer to this question.
1
Q: Using Null With Variable

SmallFries BigGuysI have this table structure and am attempting to return the two rows where loglevel is null. How should the query be written in order to return this? Based off the sample DDL Below I want 2 rows for names returned: Pink Pig and Green Glove Declare @stuff Table (name varchar(50), vendo...

where exists (select x intersect select @x)
 
9:16 PM
@MikaelEriksson Good old Itkiz ;)
Always nice to be mentioned by one's heroes, even if they get the name wrong.
 
It was quickly corrected from the audience.
 
I was about to say that if Itzik says it's @SQLwiki and not @SQL_Kiwi he's probably right and I should change it 😀
2
 
9:32 PM
It's already taken. @SQL_wiki then 😜
 
9:43 PM
Ha ha ha
 
@PaulWhite hahaha, did not see that until now.
 
9:58 PM
Don't you know the SO motto is "We hate fun"? — APC Apr 19 '12 at 15:00
 

« first day (2120 days earlier)      last day (2754 days later) »