'Study'에 해당되는 글 30건
- 2012.09.19 sendmail 로 메일 보낼때 CNAME 문제
- 2012.06.27 SQ2K8 Index 생성 관련 lock 관련 Guide 요청
- 2008.10.29 RGB 값을 생성하는 자바스크립트
- 2008.09.26 max server memory 사이즈 수정
- 2008.09.26 SQL Server 2005 Cluster Agent Service 실행실패
- 2008.09.22 IO 높은 쿼리
- 2008.09.22 인덱스 안타는 것들....
- 2008.09.12 isolation Level 보기 및 변경하기
- 2008.09.11 이미지 Resize 하기
- 2008.09.11 파이썬으로 로그 삭제하기
[제목]
Index 생성 관련 lock 관련 Guide 요청
[요약]
--문제
Index 생성 관련 lock 관련 Guide 요청
[진행 사항]
Step 1 ) A(Source) Table 에서 B Table로 Data 복사 (SELECT INTO or INSERT SELECT )
Step 2 ) B Table에 PK를 포함한 Index 생성
Step 3 ) A Table에 대해서 아래 Query를 이용해서 Access 여부 확인
Step 4 ) Step 3에서 A Table에 Access가 없는 경우 A Table을 A_Org로 Rename
Step 5 ) B Table을 A Table으로 Rename
SELECT * FROM
(
SELECT R.session_id, SUBSTRING(S.text, (R.statement_start_offset/2)+1,
((CASE R.statement_end_offset
WHEN -1 THEN DATALENGTH(S.text)
ELSE R.statement_end_offset
END - R.statement_start_offset)/2) + 1)
AS SQL
FROM sys.dm_exec_requests AS R
cross apply sys.dm_exec_sql_text(r.sql_handle) AS S
WHERE R.session_id > 50 AND R.session_id <> @@SPID
) AS S
WHERE S.SQL like '%table_name%'
function makeRGB(){
colors = new Array(14)
colors[0]="0"
colors[1]="1"
colors[2]="2"
colors[3]="3"
colors[4]="4"
colors[5]="5"
colors[5]="6"
colors[6]="7"
colors[7]="8"
colors[8]="9"
colors[9]="a"
colors[10]="b"
colors[11]="c"
colors[12]="d"
colors[13]="e"
colors[14]="f"
digit = new Array(5)
color=""
for (i=0;i<6;i++){
digit[i]=colors[Math.round(Math.random()*14)]
color = color+digit[i]
}
return color
}
SELECT TOP 50
(qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count as [Avg IO],
SUBSTRING(qt.text,qs.statement_start_offset/2,
(case when qs.statement_end_offset = -1
then len(convert(nvarchar(max), qt.text)) * 2
else qs.statement_end_offset end -qs.statement_start_offset)/2)
as query_text,
qt.dbid, dbname=db_name(qt.dbid),
qt.objectid,
qs.sql_handle,
qs.plan_handle
FROM sys.dm_exec_query_stats qs
cross apply sys.dm_exec_sql_text(qs.sql_handle) as qt
ORDER BY
[Avg IO] DESC
declare @dbid int
select @dbid = db_id()
select objectname=object_name(s.object_id), s.object_id
, indexname=i.name, i.index_id
, user_seeks, user_scans, user_lookups, user_updates
from sys.dm_db_index_usage_stats s,
sys.indexes i
where database_id = @dbid
and objectproperty(s.object_id,'IsUserTable') = 1
and i.object_id = s.object_id
and i.index_id = s.index_id
order by (user_seeks + user_scans + user_lookups + user_updates) asc
이미지 Resize 하기
이미지를 GDLib 이용해서 리사이징 하기로 함
find . -size +6k -type f -exec cp -r {} /tmp/image/ \;
( 우선 데이타를 한곳으로 몰고)
#!/usr/bin/php -q
// gd에 사용될 임시 변수들
$IsTrueColor = false;
$Extension = null;
// 이미지를 로딩하는 함수입니다.
function GDImageLoad($filename)
{
global $IsTrueColor, $Extension;
if( !file_exists($filename) ) return false;
$image_type = exif_imagetype($filename);
switch( $image_type )
{
case IMAGETYPE_JPEG: // JPEG일경우
$im = imagecreatefromjpeg($filename);
$Extension = "jpg";
break;
case IMAGETYPE_GIF: // GIF일 경우
$im = imagecreatefromgif($filename);
$Extension = "gif";
break;
case IMAGETYPE_PNG: // png일 경우
$im = imagecreatefrompng($filename);
$Extension = "png";
break;
default:
break;
}
$IsTrueColor = @imageistruecolor($im);
return $im;
}
// 이미지 크기를 줄입니다.
function GDImageResize($src_file, $dst_file, $width = NULL, $height = NULL, $type = NULL, $quality = 75)
{
global $IsTrueColor, $Extension;
$im = GDImageLoad($src_file);
if( !$im ) return false;
if( !$width ) $width = imagesx($im);
if( !$height ) $height = imagesy($im);
if( $IsTrueColor && $type != "gif" ) $im2 = imagecreatetruecolor($width, $height);
else $im2 = imagecreate($width, $height);
if( !$type ) $type = $Extension;
imagecopyresampled($im2, $im, 0, 0, 0, 0, $width, $height, imagesx($im), imagesy($im));
if( $type == "gif" )
{
imagegif($im2, $dst_file);
}
else if( $type == "jpg" || $type == "jpeg" )
{
imagejpeg($im2, $dst_file, $quality);
}
else if( $type == "png" )
{
imagepng($im2, $dst_file);
}
imagedestroy($im);
imagedestroy($im2);
return true;
}
GDImageResize('1631.jpg', '1631.jpg', '104', '104');
?>
위 소스를 이용 resizing 함... 냐하핫
파이썬으로 로그 삭제하기
import os
from datetime import *
tempPath = '/Log'
tempList = os.listdir(tempPath)
tempDate = datetime.today()
#tempTargetDate = tempDate - timedelta( days=14 )
tempTargetDate = tempDate - timedelta( weeks=5 )
##### START #####
print '\n'
###
for tempFolder in tempList :
tempList2 = os.listdir(tempPath + '/' + tempFolder)
print '\n##### ' + tempFolder + '\n'
for tempFile in tempList2 :
tempFileDate = datetime.fromtimestamp( os.path.getmtime( tempPath + '/' + tempFolder + '/' + tempFile ) )
if tempFileDate < tempTargetDate:
###
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
###
### os.remove(tempPath + '/' + tempFolder + '/' + tempFile)
###
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
### WARNING WARNING WARNING WARNING WARNING
###
print tempPath + '/' + tempFolder + '/' + tempFile + ' ----- is deleted.'
else:
print tempPath + '/' + tempFolder + '/' + tempFile
###
print '\n'
print 'today is\t\t', tempDate
print '\nand THE TARGET DATE is\t', tempTargetDate
###
print '\nhello, world. = )\n'
##### END OF POEM #####