1

queryScenario.php ファイルの読み込みが遅すぎます (平均 28 秒)。クエリとループでこれを減らすにはどうすればよいですか? PHP の最適化についてほとんど何も知らないので、対処方法がわかりません。

ありがとう。

これは私の queryScenario.php ファイルです:

<?php
        include("database.php");
        include("dataModel.php");

        if(!isset($_SESSION))
            session_start();

        //$userId = 1; // This variable will be obtained from the session
        $userId = $_SESSION['userIdNumber'];
        //$selectedUserLandId = $_GET['id']; // This variable may be defined as a session variable
        $selectedUserLandId = $_SESSION['selectedUserLandId'];

        // load the related user based model tables (dynamic data)
        $landLiteral = dbGetUserLandByLandId($userId, $selectedUserLandId); 
        if (count($landLiteral)< 1){
            // TODO: Throw an exception here          
        }
        $landLiteralSelected = $landLiteral[0];
        $userLand = new Land();
        $userLand->id = $landLiteralSelected["id"];
        $userLand->name = $landLiteralSelected["name"];
        $userLand->desc = $landLiteralSelected["description"];
        $landmap = dbGetLandmapById($landLiteralSelected["id"]);
        $userLand->mapimage = $landmap[0]["mapimage"];
        $geopos = dbGetGeoposById($landLiteralSelected["geopos_id"]);
        $userLand->lat = $geopos[0]["lat"];
        $userLand->lng = $geopos[0]["lng"] ;
        $userLand->type = $landLiteralSelected["landenum_id"];
        $sectorsLiteral = dbGetSectorsByLandId($userLand->id);
        foreach ($sectorsLiteral as $sectorLiteral){
           $sector = new Sector();
            $sector->id = $sectorLiteral["id"];
            $sector->name = $sectorLiteral["name"];
            $sector->desc = $sectorLiteral["description"];
            $geoposSector = dbGetGeoposById($sectorLiteral["geopos_id"]);
            $sector->lat = $geoposSector[0]["lat"];
            $sector->lng = $geoposSector[0]["lng"] ;
            $userLand->sectionList[] = $sector;

            $devicesLiteral = dbGetDevicesBySectorId($sector->id);
            foreach ($devicesLiteral as $deviceLiteral){
                $device = new Device();
                $device->id = $deviceLiteral["id"];
                $device->sceneName = $deviceLiteral["scenename"];
                $device->sceneDesc = $deviceLiteral["scenedescription"];
                $mapinfoDevice = dbGetMapInfoById($deviceLiteral["mapitem_id"]);
                $device->mapInfo[] = $mapinfoDevice[0];
                $geoposDevice = dbGetGeoposById($deviceLiteral["geopos_id"]);
                $device->lat = $geoposDevice[0]["lat"];
                $device->lng = $geoposDevice[0]["lng"];
                $device->type = $deviceLiteral["deviceenum_id"];
                $device->serialNo = $deviceLiteral["serialNo"];
                $sector->deviceList[] = $device;

                // NOW THE MODULES
                $modulesLiteral = dbGetDeviceModulesByDeviceType($device->type);

                foreach($modulesLiteral as $moduleLiteralList){
                    foreach ($moduleLiteralList as $moduleLiteral){
                        $module = new Module();
                        $module->id = $moduleLiteral["id"];
                        $module->type = $moduleLiteral["moduleenum_id"];
                        $module->unit = $moduleLiteral["unit"];
                        $module->subid = dbGetSubIdOfModule($module->id);
                        $deviceStateLiteral=dbGetDeviceStates($device->id);

                        if (count($deviceStateLiteral) > 0){
                            $moduleState=new ModuleState();
                            $moduleState->pendingState=$deviceStateLiteral[0]["pending_state"];
                            $moduleState->desiredState=$deviceStateLiteral[0]["desired_state"];
                            $moduleState->currentState=$deviceStateLiteral[0]["current_state"];
                            $module->moduleState=$moduleState;
                        }
                        $moduleDataLiteral=dbGetLastDeviceModuleData($device->id,$module->id);
                        $moduleData=new ModuleData();
                        if (count($moduleDataLiteral) > 0){
                            $moduleData->data=$moduleDataLiteral[0]["value"]." ".$module->unit;
                            $moduleData->timeStamp=$moduleDataLiteral[0]["timestamp"];
                        }else{
                               $moduleData->data="Veri Yok";
                               $moduleData->timeStamp="Veri Yok";
                        }
                              $module->moduleData=$moduleData;

                        $device->moduleList[] = $module;

                        // NOW THE MODULE SPECS
                        // First, get the default specs
                        $specsLiteral = dbGetDefaultSpecsByModuleId($module->id);

                        foreach($specsLiteral as $specLiteral){
                            $spec = new Spec();
                            $spec->type = $specLiteral["specenum_id"];
                            $spec->editable = $specLiteral["editable"];
                            $spec->value = $specLiteral["default"];

                            // NOW LOOK FOR UPDATED SPEC FOR THIS DEVICE MODULE AND SPEC
                            $updatedSpecLiteral = dbGetUpdatedDeviceSpec($device->id, $module->id, $spec->type);

                            if ($updatedSpecLiteral){
                               $spec->value = $updatedSpecLiteral[0]["specvalue"];
                            }

                            $module->specList[] = $spec;
                        }
                    }           
                }
            }
        }
        if(!(isset($_GET["nonEcho"]) && $_GET["nonEcho"]=="yes"))
            echo json_encode($userLand);

?>

これらはデータ モデルです。

<?php
class Node {
    public $id;
}

class SpatialNode extends Node {
    public $lat = 0;
    public $lng = 0;
}

class Land extends SpatialNode{
    public $name;
    public $desc = "";
    public $type;
    public $sectionList = array();
    public $mapimage;
}

class Sector extends SpatialNode{
    public $name;
    public $desc = "";
    public $deviceList = array();
}

class Device extends SpatialNode{
    public $sceneName;
    public $sceneDesc;
    public $type;
    public $desc = "";
    public $serialNo;
    public $installationDate = "";
    public $moduleList = array();
    public $mapInfo = array();
}

class Module extends Node{
    public $type;
    public $unit = "";
    public $subid;
    public $specList = array();
    public $moduleData;
    public $moduleState;
}

class ModuleData{
    public $data;
    public $timeStamp;
}
class ModuleState{
    public $pendingState;
    public $desiredState;
    public $currentState;
}
class Spec{
    public $type;
    public $value;
    public $editable;
}


class DeviceStatus{
    public $name;
    public $address;
    public $pendingState;
    public $desiredState;
}

?>

これらはクエリです:

<?php
//include("dataModel.php");

function dbConnect() {
    $dbhost = 'XXXXXXXX';
    $dbuser = 'XXXXX';
    $dbpass = 'XXXXXXXXX';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if (!$conn) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('XXXXXXXXX', $conn);
    mysql_query("SET NAMES UTF8");
    return $conn;
}

function executeSQL($sql) {
    $conn = dbConnect();

    $values = array();
    $retval = mysql_query($sql, $conn);

    if (!$retval) {
        die('Could not get data: ' . mysql_error());
    }

    while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
        array_push($values, $row);
    }

    return $values;
}

function executeSQLForPersist($sql){
    $conn = dbConnect();


    $retval = mysql_query($sql, $conn);

    return $retval;
}

function dbGetLandsByUserId($userId){
    $sql  = "SELECT * FROM land WHERE user_id=$userId or user_id=1 ";
    return executeSQL($sql);
}

function dbGetUserLandByLandId($userId, $landId){
    $sql = "SELECT * FROM land WHERE user_id=$userId AND id=$landId UNION SELECT * FROM land WHERE user_id=1 AND id=1";
    return executeSQL($sql);
}

function dbGetGeoposById($geoId){
    $sql  = "SELECT * FROM geoposition WHERE id=$geoId";
    return executeSQL($sql);
}
function dbGetLandmapById($id){
    $sql  = "SELECT * FROM landimages WHERE land_id=$id";
    return executeSQL($sql);
}
function dbGetMapInfoById($id) {
    $sql  = "SELECT * FROM mapitems WHERE id=$id";
    return executeSQL($sql);
}

function dbGetEnums(){
    $sql = "SELECT * FROM enums";
    return executeSQL($sql);
}

function dbGetSceneDevices(){
    $sql = "SELECT * FROM scenedevices";
    return executeSQL($sql);
}


function dbGetSectorsByLandId($landId){
    $sql = "SELECT * FROM sector WHERE land_id=$landId";
    return executeSQL($sql);
}

function dbGetDevicesBySectorId($sectorId){
    $sql = "SELECT * FROM scenedevices WHERE sector_id=$sectorId";
    return executeSQL($sql);
}

function dbGetDeviceModulesByDeviceType($deviceTypeId){
     $sql = "SELECT module_id FROM devicedef WHERE deviceenum_id=$deviceTypeId";
     $moduleIdsLiteral = executeSQL($sql);

     $modulesLiteralList = array();
     foreach ($moduleIdsLiteral as $moduleIdLiteral){
         $moduleId = $moduleIdLiteral["module_id"];
         $sqlModuleQuery = "SELECT * FROM module WHERE id=$moduleId";
         $modulesLiteralList[] = executeSQL($sqlModuleQuery);

     }
     return $modulesLiteralList;
}

function dbGetDefaultSpecsByModuleId($moduleId){
    $sql = "SELECT * FROM module_specs WHERE module_id=$moduleId";
    return executeSQL($sql);
}

function dbGetUpdatedDeviceSpec($deviceId, $moduleId, $specId){
    $sql = "SELECT * FROM deviceprefs WHERE scenedevice_id=$deviceId AND module_id=$moduleId AND specenum_id=$specId";
    return executeSQL($sql);
}

function dbGetProfileLandImageByLandId($landId){
    $sql = "SELECT * FROM landimages WHERE land_id=$landId AND profile=1";
    return executeSQL($sql);
}


function dbGetSubIdOfModule($moduleId){
    $sql = "SELECT * FROM devicedef WHERE module_id='$moduleId'";
    $idLiteral = executeSQL($sql);
    if(count($idLiteral) != 0) {
        return $idLiteral[0]["subid"];
    }
    else {
        return -1;
    }
}

function dbGetModuleIdByModuleEnumId($moduleEnumId){
    $sql = "SELECT * FROM module WHERE moduleenum_id=$moduleEnumId";
    $idLiteral = executeSQL($sql);
    if (count($idLiteral) == 1){
        return $idLiteral[0]['id'];
    }else{
        return -1;
    }
}

function dbGetAllDeviceModuleData($devId, $modId){
    $sql = "SELECT * FROM realtimedevicedata WHERE scenedevice_id=$devId AND module_id=$modId ORDER BY timestamp LIMIT 0, 500"; //TODO.
    return executeSQL($sql);
}
function dbGetLastDeviceModuleData($devId, $modId){
    $sql = "SELECT * FROM realtimedevicedata WHERE scenedevice_id=$devId AND module_id=$modId ORDER BY timestamp desc limit 1";
    return executeSQL($sql);   
}

function dbGetLastDayDeviceModuleData($devId, $modId){
    $sql = "SELECT * FROM realtimedevicedata WHERE scenedevice_id=$devId AND module_id=$modId AND timestamp>=SYSDATE()-INTERVAL 1 DAY ORDER BY timestamp";
    return executeSQL($sql);   
}

function dbGetIntervalDeviceModuleData($devId, $modId, $startDate, $endDate){
    $sql = "SELECT * FROM realtimedevicedata WHERE scenedevice_id=$devId AND module_id=$modId AND timestamp>='$startDate' AND timestamp<='$endDate' ORDER BY timestamp";
    return executeSQL($sql);   
}

function dbGetDeviceStates($devId) {
    $sql = "SELECT * FROM deviceprefs WHERE scenedevice_id=$devId";
    return executeSQL($sql);   
}

function dbGetAllDeviceStates($imei) {
    $sql  = "SELECT  scenedevices.scenename, scenedevices.serialNo, deviceprefs.pending_state, ".
            "deviceprefs.desired_state FROM  scenedevices, deviceprefs ". 
        "WHERE  scenedevices.parentId = '".$imei."' AND scenedevices.id = deviceprefs.scenedevice_id ";
    return executeSQL($sql);
}


?>
4

2 に答える 2

2

このトピックに関する私の一般的な考えは、コードを2つの主要な部分に分割する必要があるということです。

  1. データ抽出
  2. データの準備

foreach()現在の実装では、ループごとにDBに対して1つのクエリがあります。これを試してみてください:

$sectorsLiteral = dbGetSectorsByLandId($userLand->id);
$sectorsLiteralIds = array();
foreach ($sectorsLiteral as $sectorLiteral) {
    $sectorsLiteralIds[] = $sectorLiteral["id"]
}

$devicesLiteral = dbGetDevicesBySectorId($sectorsLiteralIds);

等々。

もちろん、引数の配列を受け入れるようにDB「クラス」を調整する必要があります。

次に、3〜5クエリ内ですべてのデータをフェッチする場合は、配列を操作する必要があります。これもforeachesでforeachesですが、各ループサイクル内でデータを抽出する必要がないため、高速で動作します。

それ以降のすべての準備を処理する抽象的な方法は、次のようになります。

$response = array();
foreach($sectorsLiteral as $sectorLiteral) {
    foreach($devicesLiteral as $deviceLiteral) {
        if ($deviceLiteral['sectorId'] == $sectorLiteral['id']) {
            ...do what you need
        }
    }
}

はい、コードはより複雑になりますが、はるかに高速に動作します。

編集

コードの重要な改善点の$connection1つは、クエリが送信されるたびに新しい変数を開かないように、グローバル変数を設定する必要があります。

$conn = false;

function dbConnect() {
    ...
    global $conn;

    if (!$conn) {
        $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    }
    ...

}

唯一のこと-接続ステータスをチェックする別の方法を見つける必要があります:)

乾杯 ;)

于 2012-07-27T12:06:39.490 に答える
0

私のコードの実行速度が遅い理由は、realtimedevicedata テーブルが大きすぎる (約 120MB で 50K のレコードがある) ためであることに気付き、レコードを選択しない前にこのテーブルを注文しようとしました。これを避けるために、テーブルから最初の 500 レコードを取得してからテーブルを並べ替えるようにコードを変更します。これで鎖が切れます。

協力してくださったすべての方々に感謝します。また、時間を空けて申し訳ありません。良い一日を過ごしてください。

SQL の変更:

古いもの :

$sql = "SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=$devId AND module_id=$modId ORDER BY timestamp desc limit 0,1";

新しいもの:

$sql = "SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=$devId AND K.module_id=$modId LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1";

realtimedevicedata の証明は悪い子です:

0.02 secs : SELECT * FROM land WHERE user_id=2 AND id=1 UNION SELECT * FROM land WHERE user_id=1 AND id=1
0.11 secs : SELECT mapimage FROM landimages WHERE land_id=1 LIMIT 0,1
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=1 LIMIT 0,1
0.06 secs : SELECT id, name, description, geopos_id FROM sector WHERE land_id=1
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=2 LIMIT 0,1
0.03 secs : SELECT id,scenename,scenedescription,mapitem_id,geopos_id,deviceenum_id,serialNo FROM scenedevices WHERE sector_id=1
0.00 secs : SELECT * FROM mapitems WHERE id=1
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=47 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=6
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=11
0.00 secs : SELECT subid FROM devicedef WHERE module_id='11'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=1
0.15 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=1 AND module_id=11 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=11
0.00 secs : SELECT * FROM mapitems WHERE id=3
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=2 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=4
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=1
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=2
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=3
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='1'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
9.41 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=2 AND module_id=1 ORDER BY timestamp desc limit 0,1
0.01 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=1
0.02 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=1 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=1 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=1 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='2'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
6.84 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=2 AND module_id=2 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=2
0.01 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=2 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=2 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=2 AND specenum_id=18
0.02 secs : SELECT subid FROM devicedef WHERE module_id='3'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
4.44 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=2 AND module_id=3 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=3
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=3 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=3 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=3 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
9.27 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=2 AND module_id=10 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
0.01 secs : SELECT * FROM mapitems WHERE id=5
0.01 secs : SELECT lat,lng FROM geoposition WHERE id=44 LIMIT 0,1
0.02 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=5
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=4
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='4'
0.02 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=4
0.01 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=4 AND module_id=4 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=4
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=4
0.00 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=4 AND module_id=10 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
0.00 secs : SELECT * FROM mapitems WHERE id=6
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=45 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=31
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=4
0.00 secs : SELECT subid FROM devicedef WHERE module_id='4'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=5
0.00 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=5 AND module_id=4 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=4
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=3 LIMIT 0,1
0.00 secs : SELECT id,scenename,scenedescription,mapitem_id,geopos_id,deviceenum_id,serialNo FROM scenedevices WHERE sector_id=2
0.00 secs : SELECT * FROM mapitems WHERE id=4
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=3 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=29
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=1
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=2
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=9
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='1'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
4.34 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=3 AND module_id=1 ORDER BY timestamp desc limit 0,1
0.01 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=1
0.03 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=1 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=1 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=1 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='2'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
11.86 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=3 AND module_id=2 ORDER BY timestamp desc limit 0,1
0.02 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=2
0.05 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=2 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=2 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=2 AND specenum_id=18
0.04 secs : SELECT subid FROM devicedef WHERE module_id='9'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
4.25 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=3 AND module_id=9 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=9
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
2.71 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=3 AND module_id=10 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
0.00 secs : SELECT * FROM mapitems WHERE id=7
0.05 secs : SELECT lat,lng FROM geoposition WHERE id=46 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=5
0.01 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=4
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='4'
0.01 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=6
0.00 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=6 AND module_id=4 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=4
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=6
0.00 secs : SELECT value, timestamp FROM realtimedevicedata WHERE scenedevice_id=6 AND module_id=10 ORDER BY timestamp desc limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10

今、彼女は私が素敵な女の子になることを約束します:)

0.00 secs : SELECT * FROM land WHERE user_id=2 AND id=1 UNION SELECT * FROM land WHERE user_id=1 AND id=1
0.00 secs : SELECT mapimage FROM landimages WHERE land_id=1 LIMIT 0,1
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=1 LIMIT 0,1
0.00 secs : SELECT id, name, description, geopos_id FROM sector WHERE land_id=1
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=2 LIMIT 0,1
0.00 secs : SELECT id,scenename,scenedescription,mapitem_id,geopos_id,deviceenum_id,serialNo FROM scenedevices WHERE sector_id=1
0.00 secs : SELECT * FROM mapitems WHERE id=1
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=47 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=6
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=11
0.00 secs : SELECT subid FROM devicedef WHERE module_id='11'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=1
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=1 AND K.module_id=11 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=11
0.00 secs : SELECT * FROM mapitems WHERE id=3
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=2 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=4
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=1
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=2
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=3
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='1'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=2 AND K.module_id=1 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=1
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=1 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=1 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=1 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='2'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=2 AND K.module_id=2 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=2
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=2 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=2 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=2 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='3'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=2 AND K.module_id=3 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=3
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=3 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=3 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=2 AND module_id=3 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=2
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=2 AND K.module_id=10 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
0.00 secs : SELECT * FROM mapitems WHERE id=5
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=44 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=5
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=4
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='4'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=4
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=4 AND K.module_id=4 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=4
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=4
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=4 AND K.module_id=10 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
0.00 secs : SELECT * FROM mapitems WHERE id=6
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=45 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=31
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=4
0.00 secs : SELECT subid FROM devicedef WHERE module_id='4'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=5
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=5 AND K.module_id=4 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=4
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=3 LIMIT 0,1
0.00 secs : SELECT id,scenename,scenedescription,mapitem_id,geopos_id,deviceenum_id,serialNo FROM scenedevices WHERE sector_id=2
0.00 secs : SELECT * FROM mapitems WHERE id=4
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=3 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=29
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=1
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=2
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=9
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='1'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=3 AND K.module_id=1 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=1
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=1 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=1 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=1 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='2'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=3 AND K.module_id=2 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=2
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=2 AND specenum_id=14
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=2 AND specenum_id=15
0.00 secs : SELECT specvalue FROM deviceprefs WHERE scenedevice_id=3 AND module_id=2 AND specenum_id=18
0.00 secs : SELECT subid FROM devicedef WHERE module_id='9'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=3 AND K.module_id=9 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=9
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=3
0.20 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=3 AND K.module_id=10 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
0.00 secs : SELECT * FROM mapitems WHERE id=7
0.00 secs : SELECT lat,lng FROM geoposition WHERE id=46 LIMIT 0,1
0.00 secs : SELECT module_id FROM devicedef WHERE deviceenum_id=5
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=4
0.00 secs : SELECT id, moduleenum_id, unit FROM module WHERE id=10
0.00 secs : SELECT subid FROM devicedef WHERE module_id='4'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=6
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=6 AND K.module_id=4 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=4
0.00 secs : SELECT subid FROM devicedef WHERE module_id='10'
0.00 secs : SELECT pending_state, desired_state, current_state FROM deviceprefs WHERE scenedevice_id=6
0.00 secs : SELECT value, timestamp FROM (SELECT DISTINCT scenedevice_id, value, timestamp FROM realtimedevicedata AS K WHERE K.scenedevice_id=6 AND K.module_id=10 LIMIT 0,100) AS M ORDER BY M.timestamp desc Limit 0,1
0.00 secs : SELECT `specenum_id`, `editable`, `default` FROM module_specs WHERE module_id=10
于 2012-07-27T12:21:12.280 に答える