2010-03-01 2 views
0

http://framework.zend.com/manual/en/zend.db.profiler.html의 샘플 코드에 따라 Zend Framework 응용 프로그램의 db 프로파일 링을 설정했습니다.Zend_Db_Profiler가 db 연결 시간을 로깅하지 않습니까?

application.ini :

db.profiler.enabled = true 

보기 도우미 : 그것은 선택/삽입/업데이트를 위해 잘 작동

$totalTime = $profiler->getTotalElapsedSecs(); 
$queryCount = $profiler->getTotalNumQueries(); 
$longestTime = 0; 
$longestQuery = null; 

foreach ($profiler->getQueryProfiles() as $query) { 
    if ($query->getElapsedSecs() > $longestTime) { 
     $longestTime = $query->getElapsedSecs(); 
     $longestQuery = $query->getQuery(); 
    } 
} 

echo 'Executed ' . $queryCount . ' queries in ' . $totalTime . ' seconds' . "\n"; 
echo 'Average query length: ' . $totalTime/$queryCount . ' seconds' . "\n"; 
echo 'Queries per second: ' . $queryCount/$totalTime . "\n"; 
echo 'Longest query length: ' . $longestTime . "\n"; 
echo "Longest query: \n" . $longestQuery . "\n"; 

/쿼리를 삭제합니다.

그러나 프로파일 러가 이것을 기록한다는 암시에도 불구하고 프로파일 러가 실제 db 연결을 시작하는 데 걸리는 시간을 표시 할 수는 없습니다.

나는 Zend_Db가 단순히 프로파일 러를 사용하여 db에 대한 연결을 기록하지 않는다고 생각합니다.

여기에 무슨 일이 일어나는지 아는 사람이 있습니까?

내가 Oracle 데이터베이스 어댑터를 사용하고

및 ZF 1.10.1

업데이트 : 특정 쿼리가 표시됩니다 있도록, 프로파일 러 출력을 필터링 할 수 있습니다 이해

유형, 예 선택/삽입/업데이트. 또한 바로 연결 레코드를 필터링 할 수있는 옵션이 나타납니다 :

$profiler->setFilterQueryType(Zend_Db_Profiler::CONNECT); 

그러나, 내 문제는 프로파일 러가 로 시작하는 연결 로깅되지 않는 것입니다, 그래서이 필터는 아무것도 실시하지 않습니다.

내가 프로파일 개체를 인쇄하는 경우, 그것은 많은 다른 쿼리에 대한 데이터가 포함되어 있기 때문에 나는 사실이 알 -하지만 연결 쿼리에 대한 데이터 :

print_r($profiler); 
 
//output 
Zend_Db_Profiler Object 
(
    [_queryProfiles:protected] => Array 
     (
      [0] => Zend_Db_Profiler_Query Object 
       (
        [_query:protected] => select * from table1 
        [_queryType:protected] => 32 
        [_startedMicrotime:protected] => 1268104035.3465 
        [_endedMicrotime:protected] => 1268104035.3855 
        [_boundParams:protected] => Array 
         (
         ) 

       ) 

      [1] => Zend_Db_Profiler_Query Object 
       (
        [_query:protected] => select * from table2 
        [_queryType:protected] => 32 
        [_startedMicrotime:protected] => 1268104035.3882 
        [_endedMicrotime:protected] => 1268104035.419 
        [_boundParams:protected] => Array 
         (
         ) 

       ) 

     ) 

    [_enabled:protected] => 1 
    [_filterElapsedSecs:protected] => 
    [_filterTypes:protected] => 
) 

내가 뭔가 잘못하고없는 건가요 - 또는 아직 Zend Framework에 추가되지 않은 연결 로깅이 있습니까?

답변

0

프로파일 러 '번들'연결 및 일반 쿼리와 관련된 다른 작업.

$profiler->setFilterQueryType(**Zend_Db_Profiler::CONNECT**); 

그런 결과 프로파일 만 포함 '연결됩니다

  1. 설치 중에 프로파일에 필터를 설정합니다

    세 가지 방법이 특별히 연결을 검사 할 수있다 '운영.

    foreach($profiler->getQueryProfiles() as $query) { 
    if ($query->getQueryType() == Zend_Db_Profiler::CONNECT && 
        $query->getElapsedSecs() > $longestConnectionTime) { 
         $longestConnectionTime = $query->getElapsedSecs(); 
        } 
    } 
    
:

$profiles = $profiler->getQueryProfiles(**Zend_Db_Profiler::CONNECT**); 
  • 쿼리를 검사가 반복하는 동안 객체를 직접 : 쿼리 프로필 검색 할 때

  • 쿼리 유형을 지정

    당신은 거기에 훌륭한 세부 사항을 찾을 수 없을거야, 그것은 단지 '연결'작업으로 찍은 시간과 함께 기록됩니다.

  • +0

    그건 내 문제 야 - 이건 내게 효과가 없어! 기록 된 연결 레코드가 없으므로 필터링 할 내용이 없습니다. 이것에 대한 자세한 정보를 얻기 위해 제 질문을 업데이트하려고 노력할 것입니다. – asgeo1

    +1

    오라클 어댑터가 연결을 위해 프로파일 러에 관련 호출을하지 않는 것처럼 보입니다. 연결을 만들기 전에 Zend_Db_Adapter_Pdo_Abstract와 Zend_Db_Adapter_Oracle의 _connect() 메소드를 비교하면 이전의 메소드가 호출됩니다. $ q - $ this -> _ profiler-> queryStart ('connect', Zend_Db_Profiler :: CONNECT); 이상 : $ this -> _ profiler-> queryEnd ($ q); Oracle 어댑터에는 프로파일 러에 대한 참조가 없습니다 (최대 1.10.2 버전까지). 그러나 이것은 _connect() 메소드에서 동등한 호출을 추가하는 것처럼 간단 할 수도 있습니다. –