블로그 이미지
보미아빠

카테고리

보미아빠, 석이 (532)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total
Today
Yesterday

달력

« » 2025.12
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

공지사항

최근에 올라온 글

http://www.remotedbaexperts.com/Blog/2011/03/undocumented-trace-flags-inside-the-restore-process/

SQL Server supports numerous commands, most of which are extremely well documented with detailed examples provided in “Books on Line.” However, there are quite a few that were left out of the official documentation and remain unsupported by Microsoft.

You’ll find references regarding these in blogs across the Internet and some are more useful than others. Obviously, these are unsupported commands and should only be used with great care.

TRACE FLAGS

There are quite a few undocumented trace flags in SQL Server. However, I’m only going to touch on four today. They are trace flags 3004, 3014 3604 and 3605.

These can be enabled for the current session with the following commands:

– Enable the trace flags

DBCC TRACEON(3004);

DBCC TRACEON(3014);

DBCC TRACEON(3604);

DBCC TRACEON(3605);

GO

These trace flags are going to be used in conjunction with a database restore so we can get an idea about what SQL Server is doing during the process. We’ll be looking at output in the message output screen and output sent to the SQL Server error log.

Before we go much further, I want to briefly explain the purpose of these flags and why it’s important to use them together to get the information we’re looking for.

Trace Flag 3004

Most Database Administrators are aware of instant file initialization. In a nutshell, when instant file initialization is enabled the data files do not need to be zeroed out during creation. This can save an incredible amount of time during the restoration of VLDBs. As you can imagine, the zeroing out of a 1 TB data file can take a very long time.

Trace flag 3004 turns on information regarding instant file initialization. Enabling this trace flag will not make this information available to view. You will still need to turn on trace flag 3605 to send this information to the error log.

Trace Flag 3014

Trace flag 3014 provides detailed information regarding the steps performed during the backup and restore process. Normally, SQL Server only provides a limited amount of information in the error log regarding these processes. By enabling this trace flag you’ll be able to see some very detailed and interesting information.

Trace Flag 3604

Trace flag 3604 can be used under a variety of circumstances. If you’ve ever used DBCC IND or DBCC PAGE then you’ve probably already used trace flag 3604. It simply informs SQL Server to send some DBCC output information to the screen instead of the error log. In many cases, you have to use this trace flag to see any output at all.

Trace Flag 3605

Trace flag 3605 will send some DBCC output to the error log. This trace flag needs to be enabled to see the instant file initialization information made available by trace flag 3004.

Restore without Trace Flags

I created a full backup of the AdventureWorks database and then restored it with the following command:

– Restore the database

RESTORE DATABASE AdventureWorks

FROM DISK = ‘C:\TEMP\ADVENTUREWORKS.BAK’

GO

Without these trace flags the following information is returned to the message output screen:

You can also see very similar information in the error log. I returned the contents of the error log with the following command:

– Read the error log

EXEC xp_readerrorlog;

GO

Restore with Trace Flags

I’m going to perform the restore again. This time my four trace flags have been enabled and I’m hoping to see some additional information in both the message output window and the error log.

In order to make sure the error log is easy to read, I’ve cycled it with the following command:

– Cycle the error log

EXEC sp_cycle_errorlog;

GO

The next step is to execute the restore again.

– Restore the database

RESTORE DATABASE AdventureWorks

FROM DISK = ‘C:\TEMP\ADVENTUREWORKS.BAK’

GO

After the restore is finished, and with the log cleared and the trace flags enabled, we get the following information in the message output window:

It’s easy to see that this output is far more detailed when compared to what we received during our last restore. You notice that there are quite a few additional steps that were not reported when the trace flags were not enabled.

But wait, we also need to check the error log to see what additional information is available there too.

– Read the error log

EXEC xp_readerrorlog;

GO


The most interesting information in the error log is in regard to instant file initialization. You can see that SQL Server is zeroing out the data file during the container prepare process. This means we’re not benefiting from instant file initialization.

Conclusion

It’s important to understand that SQL Server purposely hides this level of detail from us on a daily basis. Arguably, this information isn’t really that necessary. However, if you feel as though you need to have a greater understanding about what’s going on inside the database engine then this is a good starting point on your journey.

Posted by 보미아빠
, |

net start mssql$sql2008r2 /m

ADMIN:.\sql2008r2

접속완료

update sys.sysdbreg set status = status |32 where name ='db'
update sys.sysdbreg set status = status &~32 where name ='db'

이런거 강제로 셋팅이 가능.


restore database db with recovery

Error: 927, Severity: 14, State: 2
먼저 에러가 나고 다음 아래와 같은 에러 발생


메시지 4333, 수준 16, 상태 1, 줄 2
로그가 복원되지 않아 데이터베이스를 복구할 수 없습니다.
메시지 3013, 수준 16, 상태 1, 줄 2
RESTORE DATABASE이(가) 비정상적으로 종료됩니다.

메시지 4333, 수준 16, 상태 1, 줄 2
The database cannot be recovered because the log was not restored.
메시지 3013, 수준 16, 상태 1, 줄 2
RESTORE DATABASE is terminating abnormally.



restore log db from disk ='c:\a.log1' with norecovery , CONTINUE_AFTER_ERROR



메시지 4320, 수준 16, 상태 11, 줄 1
데이터베이스 또는 파일 복원을 통해 파일 "db"을(를) 완전히 복원하지 못했습니다. 이 백업 세트를 적용하기 전에 전체 파일을 복원해야 합니다.
메시지 3119, 수준 16, 상태 1, 줄 1
RESTORE 문을 계획하는 동안 문제가 발견되었습니다. 자세한 내용은 이전 메시지를 참조하십시오.
메시지 3013, 수준 16, 상태 1, 줄 1
RESTORE LOG이(가) 비정상적으로 종료됩니다.

메시지 4320, 수준 16, 상태 11, 줄 2
The file "db" was not fully restored by a database or file restore. The entire file must be successfully restored before applying this backup set.
메시지 3119, 수준 16, 상태 1, 줄 2
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
메시지 3013, 수준 16, 상태 1, 줄 2
RESTORE LOG is terminating abnormally.

dbcc traceon (3604)
dbcc dbtable


1 = autoclose; set with sp_dboption.
4 = select into/bulkcopy; set with sp_dboption.
8 = trunc. log on chkpt; set with sp_dboption.
16 = torn page detection, set with sp_dboption.
32 = loading.
64 = pre recovery.
128 = recovering.
256 = not recovered.
512 = offline; set with sp_dboption.
1024 = read only; set with sp_dboption.
2048 = dbo use only; set with sp_dboption.
4096 = single user; set with sp_dboption.
32768 = emergency mode.
4194304 = autoshrink.
1073741824 = cleanly shutdown.

binary diff 이용하기 위해 aptdiff winmerge 같은 툴 이용할것


drmsqlinit
drmsqlbackup
drmsqllogbackup

backup log a with no_log

씨봉~ ㅠ.ㅠ~

Posted by 보미아빠
, |
서비스 계정에 권한을 주면 된다.
restore 를 할 경우도 해당 윈도우 계정이 c:\에 권한이 없으면 명령을 수행하지 못한다.


Posted by 보미아빠
, |

노트북을 가볍게 만들어 줄것을 약속 드립니다. 쿨럭~ 쥑이네~
soluto 프로그램을 깔아서 분석해 보세요


Posted by 보미아빠
, |

아빠~ 심심해~

심심하단 말이야....

나를 기쁘게 해줘~

웅?

옹~? 못해?

주스 한잔 빨구 생각해 보자궁~

나 이뻐요?

아빠 목에서 안떨어지기~

뭐~ 없나~?

이렇게 나들이 한번 더 가야 할건데.......

Posted by 보미아빠
, |

Aaron Bertrand

Aaron is a senior consultant for SQL Sentry, Inc., makers of performance monitoring and event management software for SQL Server, Analysis Services, and Windows. He has been blogging here at sqlblog.com since 2006, focusing on manageability, performance, and new features; has been a Microsoft MVP since 1997; tweets as @AaronBertrand; and speaks frequently at user group meetings and SQL Saturday events.

SQLCruise : What's New in Denali?

During SQLCruise Alaska last week, I was tasked with presenting "What's New in Denali?" If you've been following here, or paying attention to the SQL Rally, SQL Bits or SQL Saturday circuits, you'll know that I have given this talk before. My challenge this time around: make my 60-minute presentation a 90-minute presentation. With this crowd, it was no problem; I think we spent more time on open discussion than I spent actually presenting. And to me this was a good thing - while you didn't get to see the things we were talking about, I still thought the conversations were fantastic!

Here is the deck from the session (sorry Buck, it is more than 4 slides):

Denali.pptx.zip

I also have some demo files and sample snippets. Note that most of the demo files will work on Denali CTP1; however, two of the files (08.Forceseek.sql and 09.NewDMVs.sql) will require SQL Server 2008 R2 SP1 CTP, since the DMVs and hints mentioned there are not yet in Denali.

Denali_SamplesSnippets.zip

The second demo file, 02.SSMS.sql, doesn't really help you at all, since it was meant to be an interactive demo where I would show you visually what I was doing. I do plan to write a more extensive blog post on the snippets feature specifically, but some of the benefits of the new VS shell for Management Studio are ones you just have to touch and feel for yourself.

In any case, since I cleared out a lot of the noise in the deck (mostly links), I promised a resource list, and here it is - in the order of the slides. Please note that much of the content being linked to was written months ago, and that some of the information may have changed (and continues to change) - so may not be 100% in line with what is on the slide deck above.


Setup

http://bit.ly/AB_Denali_Setup


Books Online

http://bit.ly/AB_Denali_BOL


AlwaysOn

AlwaysOn resource site: http://bit.ly/AB_Denali_AlwaysOn
PASS keynote video: http://bit.ly/AB_Denali_Keynote2
Bob Dorr blog post: http://bit.ly/AB_Denali_BobDorr
Brent Ozar blog post: http://bit.ly/AB_Denali_OzarAlwaysOn


Contained Databases

http://bit.ly/AB_Denali_CDBtag


Custom server roles

Mike Walsh blog post: http://bit.ly/AB_Denali_MikeWalsh


Juneau

TechEd Europe video: http://bit.ly/AB_Denali_BIDSVid


Programmability / SSMS

http://bit.ly/AB_Denali_SSMS


Metadata discovery / EXEC ... WITH RESULT SETS

http://bit.ly/AB_Denali_Metadata


OFFSET

http://bit.ly/AB_Denali_OFFSET


SEQUENCE

http://bit.ly/AB_Denali_SEQUENCEtag


THROW

http://bit.ly/AB_Denali_THROW


FORCESEEK / FORCESCAN

http://bit.ly/AB_Denali_ForceSeek


Spatial Whitepaper

http://bit.ly/AB_Denali_Spatial_WP


Columnstore Index

http://bit.ly/AB_Denali_Apollo


List of changed system objects

(These do not include many of the new DMO sets I discussed during the session)
http://bit.ly/AB_Denali_SystemObjects


Deprecated functionality

http://bit.ly/AB_Denali_Deprecated


Launch point for Denali BI resources

http://bit.ly/AB_Denali_BI


----------------------


Download CTP1 (11.1103.9)

http://bit.ly/AB_Denali_Download


Forums

http://bit.ly/AB_Denali_Forums


Feedback / suggestions / bug reports

http://connect.microsoft.com/sql/
Posted by 보미아빠
, |

많이들 공유해 주세요~
Thanks 에 내 이름도 있네요
주언이 형~ 고마워요~


Posted by 보미아빠
, |

SQL Server 의 경우 Cache시스템을 자체적으로 사용 합니다. OS 에서 파일 시스템 메모리 캐시 영역을 많이 가져가는 상황에서 SQL Server 메모리 동작을 동적 메모리 제어로 된다면, 상대적으로 어플리케이션이나 서비스는 메모리 사용을 더 많이 하지 못하게 됩니다.

LargeSystemCache [ http://technet.microsoft.com/en-us/library/cc784562(WS.10).aspx ]설명에도 있듯이 일반적으로 System Cache 가 크면 일반적으로 서버의 성능이 증가합니다. 그러나, 어플리케이션이나 서비스에서 사용할 물리 메모리 사용량은 상대적으로 줄어들게 됩니다. 그 아래 설명은 해당 값이 1 이면, 시스템 데이터를 디스크 서브시스템으로 늦게 반영 시키고 다르게 말해 해당 셋팅을 끄면 어플리케이션에서 물리 메모리를 더 사용 할 수 있다는 이야기입니다. 그래서, Large system cache 옵션을 쓰지 말라는 것입니다. 자 이제 개념을 이해 했으면, SQL Server 전용 서버에서의 메모리 사용계획 옵션을 프로그램으로 설정하는게 바른 설정 이겠지요?


시스템 등록 정보 > 고급 > 성능 옵션 > 메모리 사용 계획
이 옵션은 Windows Kernel에서 System Cache를 Large System Cache로 설정 할지를 선택하는 옵션입니다. 해당 설정은 Registry HKLM\SYSTEM\CurrentControlSet\Control\SessionManager\Memory Management\LargeSystemCache에서 수동으로 설정이 가능합니다.
해당 옵션은Windows Vista와 Windows 2008에서 없어졌습니다(GUI로 설정할 수 있는 방법은 없습니다), 설정을 원하시면 해당 Registry 값에서 LargeSystemCache 값을 0 or 1로 변경합니다.

http://blogs.technet.com/b/sankim/archive/2008/05/19/largesystemcache.aspx


위와 같은 Large system cache 라는 옵션은 OS 에서 파일 데이터를 자동으로 캐시에 넣어 두겠다. 라는 옵션입니다. SQL Server 의 경우 고정메모리 할당에서(MAX MIN 메모리 고정으로 사용의 경우)는 퍼포먼스의 차이가 거의 없습니다. (그래서 GUI 설정에서 빼버렸는지도 모르겠습니다. -_-개인 사견.....)


이걸 SQL Server 가 어플리케이션이니 어플리케이션으로 설정하라고 하면 서운 하겠죠 또한 SQL Server 외 다른 서비스가 있다면, 적절히 옵션을 조정하도록 하는것이 성능에 좋습니다.

Posted by 보미아빠
, |

현재까지 no_merge, no_push_pred 라는 힌트는 sql 에서 지원되지 않는다.
아직 멀었다. 아직 어린이 티가 팍팍 나지 않는가?
착한 어린이 mssql 2011 denali 이렇게 선전하면 좋을듯..........

개인적으로 mssql query hint 는 정말 꼬질 꼬질하고 다른 DBMS와 비교해 아주 신생아 수준인거 같음......
force seek force scan 나오지만 이런 기본적인게 안된다.......-_- 생각을 바꾸어 봐야 하나....
바꾸어도 용서가 안되는데.........바봉~ 이렇게 멍청하고 한 우물만 파는 바보들이 있으니 내가 밥 먹고 살겠지......
감사합니다. mssql 님....^-----^;


if object_id('ttt') is not null
drop table ttt
go

;with test
as (
select '19800101' birth,'20110101' today union all
select 'asdf' birth ,'20110101' today
)
select *
into ttt
from test
go

select * 
  from (select birth , today
    from ttt
   where isdate(birth)=1
     and isdate(today)=1 )a
 where datediff(yy,cast(birth as datetime),cast(today as datetime)) > 30
go

-- 위 쿼리는 당연히 돌아야 할 것 같은 쿼리이지만 돌아가지 않는다.
-- view predicate merge issue 를 모르면 당연한 이야기 이다.
-- 이것만 책으로 100장이 넘게 설명한 책도 있다.

--단순하게 아래와 같이 수정해 보자

select birth, today  
  from (select top 100000000000 birth, today
    from ttt
   where isdate(birth)=1
     and isdate(today)=1 )a
 where datediff(yy,cast(birth as datetime),cast(today as datetime)) > 30 
 


 -- 잘 돌아가지요? 해당 이슈에 대해서는 스터디때 설명해 드리겠습니다. 
 
스터디 모집 광고는 다음을 참고 하세요~
어디 성욱이가 잘 정리해 둔게 있었는데....어디쥐......

http://cafe.naver.com/sqlmvp/1148 일단 이거 참고요~

Posted by 보미아빠
, |
Posted by 보미아빠
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함