원문 출처 : http://sqlblogcasts.com/blogs/tonyrogerson/archive/2007/06/28/what-is-a-page-split-what-happens-why-does-it-happen-why-worry.aspx


28 June 2007 13:50 tonyrogerson

What is a page split? What happens? Why does it happen? Why worry?

You’ve probably heard the term banded around but do you know what it means and what it means to the performance of your application? I’m going to demonstrate a page split, use DBCC PAGE to show what happens, SQL Profiler to show the locks and talk round what’s going on.

Terms

IAM      Index Allocation Map
(See http://blogs.msdn.com/sqlserverstorageengine/archive/2006/06/24/645803.aspx for a good talk about these)
GAM     Global Allocation Map
SGAM    Shared Global Allocation Map
PFS       Page Free Space
 (See http://blogs.msdn.com/sqlserverstorageengine/archive/2006/07/08/under-the-covers-gam-sgam-and-pfs-pages.aspx for a good talk about these)
Page     8Kbytes of data
Extent   8 Pages (totals 64Kbytes)

Background

A page is 8Kbytes of data which can be index related, data related, large object binary (lob’s) etc...

When you insert rows into a table they go on a page, into ‘slots’, your row will have a row length and you can get only so many rows on the 8Kbyte page. What happens when that row’s length increases because you entered a bigger product name in your varchar column for instance, well, SQL Server needs to move the other rows along in order to make room for your modification, if the combined new length of all the rows on the page will no longer fit on that page then SQL Server grabs a new page and moves rows to the right or left of your modification onto it – that is called a ‘page split’.

Example

Create a new database, a new table and put some rows in it.

use master

go

drop database pagesplit

go

 

create database pagesplit

go

use pagesplit

go

 

create table mytest (

    something_to_see_in_data    char(5)        not null constraint pk_mytest primary key clustered,

    filler                      varchar(3000)  not null

)

go

 

insert mytest ( something_to_see_in_data, filler ) values( '00001', replicate( 'A', 3000 ) )

insert mytest ( something_to_see_in_data, filler ) values( '00002', replicate( 'B', 1000 ) )

insert mytest ( something_to_see_in_data, filler ) values( '00003', replicate( 'C', 3000 ) )

go

Now look at the contents of one of your data pages, use DBCC IND to identify what pages are targeted by our object.

DBCC IND ( 0, 'mytest', 1);

GO


 

 

We can see that page 80 and 73 have data pertaining to our object, looking at the output, a PageType of 10 indicates an IAM page and a PageType of 1 a data page. I’m not going to go into IAM’s because I’d lose the focus of what I’m talking about, but I’ve put a reference at the top for further reading.

 

So here we will concentrate on the data page (page 73).

 

dbcc traceon( 3604 )        --  Output to the console so we can see output

go

 

dbcc page( 0, 1, 73, 1 )    --  page ( <0 for current db>, <file>, <page>, <level of detail> )

go

Page 73 contains all our data; the row offset table is shown below...

OFFSET TABLE:

 

Row - Offset                        

2 (0x2) - 4128 (0x1020)             

1 (0x1) - 3112 (0xc28)              

0 (0x0) - 96 (0x60)                 

Before we update our middle row to force a page split we should get SQL Profiler running so we can capture the Locks used so we can identify when the split has occurred and the locks in use.

Start SQL Profiler, New Trace, select ‘blank trace’, now on the events selection bit – choose Locks (Lock:Aquired, Lock:Released and Lock:Esculation), on TSQL choose SQL:StmtStarting and SQL:StmtCompleted. Now remember to set the filter to the SPID that you are going to run the test in.

First, let’s update a row that does not cause a page split...

update mytest

    set filler = replicate( 'B', 1000 )

where something_to_see_in_data = '00002'

Looking at the profiler trace (below) we can see there is a simple exclusive lock on the page and key being updated. The important part here is that no other pages are locked, ok, in reality we may have indexes on the columns being updated that would indeed cause locks but I’m keeping it simple!

Lets now update the middle row but this time make it so that the combined length of the rows currently on the page will no longer fit into 8Kbytes.

update mytest

    set filler = replicate( 'B', 3000 )

where something_to_see_in_data = '00002'

Before looking at the profiler output, let’s take a look and see what pages we now have allocated to our object...

DBCC IND ( 0, 'mytest', 1);

GO




Interestingly we now have 2 more, page 89 and page 109, looking at the PageType again, page 109 is a data page (type of 1) and 89 is an index page (type of 2); for a single data page there is no balanced tree to speak of because there is a one to one relationship between the root node of the index and the data page. Also, look at the page chain (columns NextPagePID and PrevPagePID ), 109 links to 73 and vice versa. Our IAM is still page 80.

Visualisation of what’s going on

Looking at the Profiler trace we see a number of things have happened...

1)    The exclusive lock is taken on the page and key being updated.

2)    The IAM page is locked (page 80), well, one of the slots in it – this is because we are being allocated some new data pages and IAM keeps track of these, you will notice that the lock is acquired and released within the transaction and not at the end, this keeps contention low; imagine how much slower inserts would be on a table if you also locked the IAM page until the end of the transaction – it would be disaster.

3)    The new index page is locked (page 89), again – notice how that lock is also released before the statement commits, why? Well, you aren’t updating the index keys so effectively there really isn’t a change so a rollback doesn’t really mean anything. One of the recommendations I make is that you be careful what columns you index – be aware of the additional locking time incurred when you are updating columns in an index.

4)    The new data page is locked (page 109), notice how that lock is kept until after the update has finished (the transaction completes).

5)    The page is split – some of the rows (id 2 and 3) are moved from page 73 to page 109, locks aren’t taken on the keys, in fact if we start a transaction and update row ‘3’ thus to prevent another connection from updating or deleting the row then SQL Server still (under the covers) moves the row to the other page – clever.

Summing Up

A page split does require resources and on a system that has continual page splits then that is going to affect performance and scalability.

Concurrency (blocking) problems are kept to a minimum by some internal tricks so they aren’t as expensive as they used to be in previous editions of SQL Server.

How do you avoid them? There are strategies for doing this, one such strategy is to use a low fill factor when you create and index, but that will be at the expense of read operations and because you usually have more reads to writes then that’s bad.

Personally, the usual thing I recommend (and by no means is this a one box fits all recommendation) is that you defrag indexes using DBCC INDEXDEFRAG (SQL 2000) or the equivalent ALTER INDEX REORGANIZE (SQL 2005), other things are to pre-populate columns so the row length doesn't grow when you update, don't use NULL's everywhere. If you have say a varchar type column that is frequently updated to different sizes then perhaps consider putting that in its own table.

Paul Randal has covered a lot of stuff in this area so make sure you check his blog out.

Background Reading

http://blogs.msdn.com/sqlserverstorageengine/archive/2006/12/13/More-undocumented-fun_3A00_-DBCC-IND_2C00_-DBCC-PAGE_2C00_-and-off_2D00_row-columns.aspx


http://www.betanews.net/article/373739&ad=548

Windows 2008 에서 강화된 것들이 많이 있다고 합니다.

심심할때 틀어놓고 한번씩 봐도 괜찮을것 같습니다.

특히!!!!!

1번의 서버 가상화

그리고.. 6번의 서버 관리 부분의 Powershell..

거의 모.. 엄청난 기능의 PowerShell......

제 자리에도 깔아서 한번 해봤는데 좋네요!!

COM Object도 만들 수도 있고..;

대신 XP에서는 다운로드 받아서 깔아야 합니다!

링크는 여기!!

http://www.microsoft.com/downloads/details.aspx?FamilyID=6ccb7e0d-8f1d-4b97-a397-47bcc8ba3806&displaylang=en&Hash=hMb0xT%2fQxPY4WoiSsSilkG2fbj5kmcOlctOeuEecI3sf%2bQ2w211a1WwGqZyUD4QIjt807w3b5TOxTsMII1Oucw%3d%3d

대신 Powershell을 잘 쓰려면 .NET 도 잘 알아야 한다는!!

그리고 스크립트 간단한거 넣어놨으니.. 한번 해보시길!!

저는 해보고 입이 딱 벌어졌음


Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.

COM Object 만들어서 뭔짓을 할수도 있다
PS C:\Documents and Settings\novice> $ie = New-Object -comobject "internetexplorer.application"
PS C:\Documents and Settings\novice> $ie | get-member
PS C:\Documents and Settings\novice> $ie.Visible = $True
PS C:\Documents and Settings\novice> $ie.Navigate("www.joymax.co.kr")
PS C:\Documents and Settings\novice> $ie.Quit()

변수에 오브젝트를 그냥 담아버릴 수도 있다
PS C:\Documents and Settings\novice> $proc = Get-Process
PS C:\Documents and Settings\novice> $proc.Count
PS C:\Documents and Settings\novice> $proc | Get-Member
PS C:\Documents and Settings\novice> $proc | Where-Object {$_.CPU -ge 10}

그냥 계산기도 된다
PS C:\Documents and Settings\novice> 5+10
PS C:\Documents and Settings\novice> 100 * 100

몇몇 구문도 먹는다던데.. Foreach 이런것도..

출처 : http://www.youtube.com/watch?v=yeA4CBInqKo


Ease at Work - Kent Beck 1 / 7


Ease at Work - Kent Beck 2 / 7


Ease at Work - Kent Beck 3 / 7


Ease at Work - Kent Beck 4a / 7


Ease at Work - Kent Beck 4b / 7


Ease at Work - Kent Beck 5 / 7


Ease at Work - Kent Beck 6 / 7


Ease at Work - Kent Beck 7 / 7

BOOL EnsureSingleInstance( LPCTSTR lpszName )
{
	HANDLE hMutex = ::CreateMutex( NULL, FALSE, lpszName );

	if ( ERROR_ALREADY_EXISTS == ::GetLastError() )
	{
		::ReleaseMutex( hMutex );
		return FALSE;
	}

	return TRUE;
}



EnsureSingleInstance 에 원하는 이름만 넣어주면 됩니다.
Kernel Object Namespaces 에 따라서 움직입니다.

자세한 Naming 방법은 Link를 참고해주세요~

아.. Code Hilighting 완전 노가다.......... -_-;

우리 회사의 절친한 형을 통해 알게된 사이트입니다.

잘생긴 팀원이 알려줬다는 사이트인데..

전에 이런 동작을 하게 하려고 직접 IANA에서 자료를 다운로드 받아서

파싱해서 데이터베이스를 만드는 프로그램을 만들었더랬습니다.

이렇게 찾게되니 좀 허망하네요.. ㅎㅎ

그래도 참 좋습니다. 이런 일을 해주는 사람들이 있다니 ㅎㅎ

MySQL 에서 돌아가도록 만들어진 Query를 직접 다운로드 받을 수 있게 해주었습니다.

http://www.ip2nation.com/

데드라인.doc

 


프로젝트 관리에 대한 책을 읽어봤습니다.

언제 읽어보나.. 하다가 학교 소프트웨어공학 시간에 레포트로 나오게 되어서

자세히 읽고 독후감도 썼다죠..;

독후감도 같이 첨부합니다.

그래도 책 읽으니 참 좋았습니다.

지하철에서.. 버스에서.. 내내 책 속으로 빠져드는듯한 느낌이었으니까요..  ^^



출처 : http://support.microsoft.com/kb/314053

TCP/IP 구성 매개변수를 바꿀 수 있는 방법에 대해
설명해주는 문서입니다.

내용이 많아서 링크만 둡니다.

::InternetOpen() / ::InternetOpenUrl() 이쪽 API를 Multi-Thread로
동시에 여러 페이지에 접근할 수 있도록 하려면
아래처럼 레지스트리 수정을 해줘야 한다고 합니다.
저희회사 xeph님께 감사하는 의미로~


출처 : http://www.pctools.com/guides/registry/detail/536/

Registry Home > Network > Protocols

Change the Number of Simultaneous HTTP Sessions (All Windows) Popular

Windows normally limits the number of simultaneous connections made to a single web server. This behavior can be seen in Internet Explorer when downloading multiple files from a web site and only a certain number will be active at any one time.

This tweak can be easily applied using WinGuides Tweak Manager.
Download a free trial now!

Windows will limit connections to a single HTTP 1.0 server to four simultaneous connections. Connections to a single HTTP 1.1 server will be limited to two simultaneous connections. The HTTP 1.1 specification (RFC2068) mandates the two connection limit while the four connection limit for HTTP 1.0 is a self-imposed restriction which coincides with the standard used by a number of popular Web browsers.

Open your registry and find the key below.

Create two new values, or modify the existing values, called 'MaxConnectionsPerServer' and 'MaxConnectionsPer1_0Server'. Change the values to equal the number of simultaneous requests allowed to a single HTTP server, the default values are 2 and 4 respectively.

Restart Windows for the change to take effect.

Note: By changing these settings you are causing Windows to break the HTTP protocol specification for any Internet applications running on your machine.

Note: This affects all Windows Internet applications that use the standard API, including Internet Explorer.

Registry Editor Example
| Name Type Data |
| (Default) REG_SZ (value not set) |
| MaxConnectionsPerServer REG_DWORD 0x00000005 (5) |
| MaxConnectionsPer1_0Server REG_DWORD 0x00000005 (5) |
-
| HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\... |
-
Registry Settings
User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Internet Settings]
Value Name: MaxConnectionsPerServer, MaxConnectionsPer1_0Server
Data Type: REG_DWORD (DWORD Value)
Value Data: Number of Simultaneous Connections

>> Recommended Download - check, repair and optimize your registry now with Registry Mechanic <<

Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. We cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.

Last modified: October 12, 2002

http://www.microquill.com/index.html

SMP 환경에서 성능 좋은 Heap이라고 합니다.

회사 동료인 redscorpion님께서 추천해준 싸이트.. ㅎㅎ

근데.. 모.. 저는 아직 SMP 환경에서 개발 할 일이 없어서 써볼 수 없을 것 같습니다.

써보고 싶은데 좀 아쉽긴 하네요 ㅎㅎ


간단한 Object Pool 입니다

만든지 한 2년정도 된듯 한.. -_-;;

지금 보니 군더더기가 좀 있는 듯 하네요 ㅎㅎ

+ Recent posts