[ mysql ] 튜닝 그누보드 - db접속횟수 줄이기 > gnuboard

본문 바로가기

사이트 내 전체검색

gnuboard

팁자료 [ mysql ] 튜닝 그누보드 - db접속횟수 줄이기

작성일 18-09-28 18:20

페이지 정보

작성자 웹지기 조회 2,242회 댓글 0건

본문

접속자가 증가하다 보면 튜닝을 하게되는데.. 

튜닝을 하는데 있어 db컨넥을 줄이고자 노력합니다. 

기본 설정 (g4_config), 게시판 설정 (g4_board), 그룹 설정 (g4_group) 을 파일로 만들어 컨넥을 줄일수도 있습니다. 

동접자는 10분간 현재접속자 기준 최대 1500명, 일일 방문자 3만명 남짓한 사이트에서 테스트 해본결과 서버가 해외에 있어 국내사정보다 못하지만, db접속오류가 현저히 낮아졌으며, 사이트 속도도 나름 쾌적해 졌습니다. 

먼저, 첨부파일을 다운받아 /adm/upgrade2.php 경로로 업로드후 실행하신 후 아래 방법대로 소스수정을 해주세요. 


기본설정 

g4_config adm/config_form_update.php 121줄 부근 

변경전

[code]

//sql_query(" OPTIMIZE TABLE `$g4[config_table]` ");

goto_url("./config_form.php", false); 

[/code]


변경후

[code]

//sql_query(" OPTIMIZE TABLE `$g4[config_table]` ");

$file = "$g4[path]/data/config/default.php";

$f = fopen($file, "w");

$row = sql_fetch(" select * from $g4[config_table] ");

fwrite($f, "<!--?\n");

foreach($row as $key =--> $value) {    

$value = str_replace("\"", "\\\"", $value);    

fwrite($f, "\$config['{$key}'] = \"{$value}\";\n");

}

fwrite($f, "?>");

fclose($f);

@chmod($file, 0606);

goto_url("./config_form.php", false); 

[/code]


common.php 294줄 부근 변경전

[code]

$config = sql_fetch(" select * from $g4[config_table] "); 

[/code]


변경후

[code]

include_once("$g4[path]/data/config/default.php");

if(!$config['cf_admin'])    

$config = sql_fetch(" select * from $g4[config_table] "); 

[/code]


그룹설정

[code]

g4_group adm/boardgroup_form_update.php 64줄부근 

변경전

else    

alert("제대로 된 값이 넘어오지 않았습니다.");


goto_url("./boardgroup_form.php?w=u&gr_id=$gr_id&$qstr"); 

[/code]


변경후

[code]

else    

alert("제대로 된 값이 넘어오지 않았습니다.");


$file = "$g4[path]/data/config/group_{$_POST[gr_id]}.php";

$f = fopen($file, "w");

$row = sql_fetch(" select * from $g4[group_table] where gr_id = '$_POST[gr_id]' ");

fwrite($f, "<!--?\n");

foreach($row as $key =--> $value) {    

$value = str_replace("\"", "\\\"", $value);   

fwrite($f, "\$group['{$key}'] = \"{$value}\";\n");

}

fwrite($f, "?>");

fclose($f);

@chmod($file, 0606);

goto_url("./boardgroup_form.php?w=u&gr_id=$gr_id&$qstr"); 

[/code]


adm/boardgroup_list_update.php 23줄 부근 변경전

[code]

sql_query($sql);

[/code]


변경후 

[code]

sql_query($sql);    

$file = "$g4[path]/data/config/group_{$_POST[gr_id][$k]}.php";    

$f = fopen($file, "w");    

$row = sql_fetch(" select * from $g4[group_table] where gr_id = '{$_POST[gr_id][$k]}' ");    

fwrite($f, "<!--?\n");    

foreach($row as $key =--> $value) {   

$value = str_replace("\"", "\\\"", $value);   

fwrite($f, "\$group['{$key}'] = \"{$value}\";\n");    

}    

fwrite($f, "?>");    

fclose($f);    

@chmod($file, 0606);

[/code]


common.php 462줄 부근 변경전

[code]

if (isset($gr_id))    

$group = sql_fetch(" select * from {$g4['group_table']} where gr_id = '$gr_id' "); 

[/code]


변경후

[code]

if (isset($gr_id)) {    

include_once("$g4[path]/data/config/group_{$gr_id}.php");    

if(!$group['gr_id'])   

$group = sql_fetch(" select * from {$g4['group_table']} where gr_id = '$gr_id' ");

[/code]


게시판설정

g4_board adm/board_form_update.php 309줄 부근 변경전

[code]

if ($s) {   

    $sql = " update $g4[board_table]

                set bo_table = bo_table 

                    {$s} 

                where gr_id = '$gr_id' ";   

    sql_query($sql);

[/code]


변경후

[code]

if ($s) {

$sql = " update $g4[board_table] 

set bo_table = bo_table 

{$s} 

where gr_id = '$gr_id' ";    

sql_query($sql);    

$que = sql_query(" select * from $g4[board_table] where gr_id = '$gr_id' ");    

for($i=0; $row=sql_fetch_array($que); $i++) {  

$file = "$g4[path]/data/config/board_{$row[bo_table]}.php";  

$f = fopen($file, "w"); 

fwrite($f, "<!--?\n"); 

foreach($row as $key =--> $value) {

$value = str_replace("\"", "\\\"", $value);   

fwrite($f, "\$board['{$key}'] = \"{$value}\";\n");

}  

fwrite($f, "?>");  

fclose($f);    

@chmod($file, 0606);   

}   

} else { 

$file = "$g4[path]/data/config/board_{$bo_table}.php"; 

$f = fopen($file, "w");

$row = sql_fetch(" select * from $g4[board_table] where bo_table = '$bo_table' ");

fwrite($f, "<!--?\n");   

foreach($row as $key =--> $value) {  

$value = str_replace("\"", "\\\"", $value);    

fwrite($f, "\$board['{$key}'] = \"{$value}\";\n"); 

}    

fwrite($f, "?>");   

fclose($f);  

@chmod($file, 0606);   

[/code]


adm/board_list_update.php 39줄 부근 변경전

[code]

sql_query($sql);

[/code]


변경후

[code]

sql_query($sql);    

$file = "$g4[path]/data/config/board_{$_POST['board_table'][$k]}.php";

$f = fopen($file, "w");

$row = sql_fetch(" select * from $g4[board_table] where bo_table = '{$_POST['board_table'][$k]}' ");  

fwrite($f, "<!--?\n");    

foreach($row as $key =--> $value) { 

$value = str_replace("\"", "\\\"", $value);  

fwrite($f, "\$board['{$key}'] = \"{$value}\";\n");

}    fwrite($f, "?>"); 

fclose($f); 

@chmod($file, 0606);    

[/code]


bbs/write_update.php 618줄 부근 변경전

[code]

@include_once("$board_skin_path/write_update.tail.skin.php");   

if ($g4[https_url]) 

[/code]


변경후

[code]

@include_once("$board_skin_path/write_update.tail.skin.php"); 

if($is_admin) { 

$file = "$g4[path]/data/config/board_{$bo_table}.php";    

$f = fopen($file, "w");   

$row = sql_fetch(" select * from $g4[board_table] where bo_table = '$bo_table' ");   

fwrite($f, "<!--?\n");    

foreach($row as $key =--> $value) {  

$value = str_replace("\"", "\\\"", $value);  

fwrite($f, "\$board['{$key}'] = \"{$value}\";\n"); 

}   

fwrite($f, "?>");    

fclose($f);

@chmod($file, 0606);  

}

[/code]


if ($g4[https_url]) common.php 452줄 부근 변경전

[code]

$board = sql_fetch(" select * from {$g4['board_table']} where bo_table = '$bo_table' ");

[/code]


변경후

[code]

include_once("$g4[path]/data/config/board_{$bo_table}.php");    

if(!$board['bo_table']) 

$board = sql_fetch(" select * from {$g4['board_table']} where bo_table = '$bo_table' ");

[/code]


추천0

비추천 0

댓글목록

등록된 댓글이 없습니다.

전체 37건 2 페이지

이미지 목록

게시물 검색
Copyright © 즐거운 코딩 생활 ( funyphp ). All rights reserved.
PC 버전으로 보기