April 1, 2010 at 12:25 pm
It's fair use.
I pinged Eric, and not sure what he'll do. I did let him know that some people see the facts as incorrect.
April 1, 2010 at 1:59 pm
CirquedeSQLeil (4/1/2010)
I enjoyed the blog post. I felt silly that I hadn't thought of a great idea like that (or blogging for April Fools Day). I had nothing last night to put out - for a joke.
I quite enjoyed your blog post Jason. I think I'll pull out my code and put yours in! Thanks for all that work cleaning it up and testing it.
Chad
April 1, 2010 at 2:04 pm
Chad Crawford (4/1/2010)
CirquedeSQLeil (4/1/2010)
I enjoyed the blog post. I felt silly that I hadn't thought of a great idea like that (or blogging for April Fools Day). I had nothing last night to put out - for a joke.I quite enjoyed your blog post Jason. I think I'll pull out my code and put yours in! Thanks for all that work cleaning it up and testing it.
Chad
That is actually a different query that I am referencing than yours. They are similar but different. Your query didn't need that kind of work.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 1, 2010 at 2:08 pm
Crud. Alright, I'll ask it. Why wouldn't a table stored in memory be faster as long as it was small? I can see that a large table in memory wouldn't be as efficient, but a very small table might be. Or is it how the table variables and temp tables are stored that you are disagreeing with?
Chad
April 1, 2010 at 2:13 pm
The original that Chad is referencing can be found here[/url].
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 1, 2010 at 2:15 pm
Chad Crawford (4/1/2010)
Crud. Alright, I'll ask it. Why wouldn't a table stored in memory be faster as long as it was small? I can see that a large table in memory wouldn't be as efficient, but a very small table might be. Or is it how the table variables and temp tables are stored that you are disagreeing with?Chad
It is how they are stored. Both temp tables and table variables can be stored both in memory and on disk.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 1, 2010 at 2:44 pm
In short, table variables are handled VERY much like temp tables. A couple of major differences follow:
Table variables aren't subject to logging.
Statistics aren't kept on table variables, which can be very bad for performance.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
April 1, 2010 at 4:12 pm
Looks like Paul has improved his daily post average.
He is now at 100.9333 posts a day.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 1, 2010 at 4:55 pm
CirquedeSQLeil (4/1/2010)
Trey Staker (4/1/2010)
I can't believe of few of the whiney comments in the editorial discussion. I guess some people are born without a sense of humor.I fell for one this morning. The copier had an instruction sheet for a new voice activated module. It was on HP letter head and looked official. I didn't really follow the instructions but I did comment out loud, "Why would anyone ever need a voice activated module on a copier." It made a few people laugh at my expense but I don't mind being the fool on occasion.
Can you forward that to me? I know several copy machines throughout my building.
Sorry...I've left work already. Just after I posted that work got hectic.
---------------------------------------------------------------------
Use Full Links:
KB Article from Microsoft on how to ask a question on a Forum
April 1, 2010 at 5:00 pm
Trey Staker (4/1/2010)
CirquedeSQLeil (4/1/2010)
Trey Staker (4/1/2010)
I can't believe of few of the whiney comments in the editorial discussion. I guess some people are born without a sense of humor.I fell for one this morning. The copier had an instruction sheet for a new voice activated module. It was on HP letter head and looked official. I didn't really follow the instructions but I did comment out loud, "Why would anyone ever need a voice activated module on a copier." It made a few people laugh at my expense but I don't mind being the fool on occasion.
Can you forward that to me? I know several copy machines throughout my building.
Sorry...I've left work already. Just after I posted that work got hectic.
That's fine. Thanks anyway.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 1, 2010 at 11:08 pm
The Dixie Flatline (4/1/2010)
Table variables aren't subject to logging.
Well...I know what you mean, but it's not literally true:
-- For the demo
USE tempdb;
-- Truncate the log
CHECKPOINT;
-- Show log records
-- (just LOP_BEGIN_CKPT and LOP_END_CKPT)
SELECT *
FROM fn_dblog(NULL, NULL);
DECLARE @NotLogged
TABLE (col1 INT NULL);
INSERT @NotLogged (col1) DEFAULT VALUES;
-- Show log generated by the table variable
SELECT [Current LSN],
Operation,
Context,
Description,
[Log Record Length],
[Log Reserve],
AllocUnitId,
AllocUnitName,
[Page ID],
[Slot ID],
[End Time],
NewAllocUnitId
FROM fn_dblog(NULL, NULL);
Interesting, right? Note especially the AllocUnitName, which gives the 'hidden' temporary table associated with the table variable.
April 2, 2010 at 3:17 am
The Dixie Flatline (4/1/2010)
Table variables aren't subject to logging.
It's perhaps better to say that they don't participate in transactions.
Table variable changes are still logged, they have to be (all data changes are, even in tempDB), because, although table variables aren't affected by a ROLLBACK TRANSACTION, they still have to be able to roll back in the case of a data modification failing part way through and that requires (and uses) the transaction log.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 2, 2010 at 3:41 am
GilaMonster (4/2/2010)
It's perhaps better to say that they don't participate in transactions.
Or locking...that's something else that is often forgotten 🙂
Table variable changes are still logged, they have to be (all data changes are, even in tempDB), because, although table variables aren't affected by a ROLLBACK TRANSACTION, they still have to be able to roll back in the case of a data modification failing part way through and that requires (and uses) the transaction log.
Concerning tempdb...
Operations on internal objects (e.g. worktables, spool operations) are never logged.
UNDO information is always logged otherwise, but REDO information may not be.
At one point, skipping the REDO logging was only available on heaps for user tables created in tempdb, though I think that has now been extended to the more general case. I'll have to check on that.
April 2, 2010 at 6:25 am
GilaMonster (4/1/2010)
Now I have someone whining about my april fool's blog post. 🙁
I liked the last comment (thus far). "Optimize for Nested Cursors" option! I know shops that need that one!
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
April 2, 2010 at 7:21 am
I think the statement that table variables don't participate in transactions is clearer. It implies that they can be exempt from a rollback, which is handy. I worry about marking them as "not logging" when that could imply something else to less experienced developers.
Viewing 15 posts - 13,756 through 13,770 (of 66,815 total)
You must be logged in to reply to this topic. Login to reply