Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello
i have a big problem with php and sql server on linux

i have build my app in windwos and php and sql server 2014

it's tow fast and i have no problem on localhost

after i upload to server i see too slow response i don't now why

my conection code is

PHP
$ServerN = 'tcp:localhost,1433';
$UserName = 'sa';
$Password = '1';
$DatabaseName = "BellaDataBase2020ELROWAN";
$baseurl = '/' . 'New';
sqlsrv_configure('ClientBufferMaxKBSize',1024*1024);

$connectionInfo = array("Database"=>$DatabaseName,"UID"=>$UserName,"PWD"=>$Password,'CharacterSet'=>'UTF-8',"ConnectionPooling" => "1","MultipleActiveResultSets"=>'0');
$conn = sqlsrv_connect($ServerN, $connectionInfo);


my php code to get table into json

PHP
    $sql102 = "
SET NOCOUNT ON
SET ARITHABORT OFF;
SET ARITHIGNORE ON;
SET ANSI_WARNINGS OFF;    
SELECT [ID],[ITemCode],[Item_Name] FROM Item WHERE [AccountType] = '3' AND [Item_Status] = 'True' ORDER BY [ITemCode] ASC";
    $ClientsASCA = sqlsrv_query($conn99,$sql102,array(),array("Scrollable"=>SQLSRV_CURSOR_CLIENT_BUFFERED,"QueryTimeout"=>0)) or die(print_r(sqlsrv_errors(),true));
    if (sqlsrv_has_rows($ClientsASCA)) {
    while ($fetchItemSST = sqlsrv_fetch_array($ClientsASCA,SQLSRV_FETCH_ASSOC)){
    $resultItemSST[] = $fetchItemSST;
    }
    echo json_encode($resultItemSST);
    }
    sqlsrv_free_stmt($ClientsASCA);
    sqlsrv_close($conn99);


my ajax code

JavaScript
    $.ajax({
        url: 'Static/CheckValue.php?Type=GetItemValue',
        type: "GET",
        dataType: "json",
        async: true,
        cache: true,
        processData: false,
        contentType: "application/json; charset=utf-8",
        error: function (data) {console.log(data);},
        complete: function(){$("#ItemNameValue1").append(ItemNameValueA);},
        success: function(data) {
        if(data.ID != ''){
            for (var i = 0; i " + Item_Name + "";
            }
            }else{
            $.each(data.err, function(k, v){
                console.log(data);
                bootbox.alert({message: "" + v + "",className: 'rubberBand animated',size: 'large'});
          });
        }
    }
});


What I have tried:

i don't know what the problem I'm try a lot of setting
i don't know the problem in php code or on sql server or on this server
remember on local host is to fast
Posted
Updated 30-Jul-20 2:46am
Comments
CHill60 30-Jul-20 3:45am    
Try running the sql query against the server using SQL Server Management Studio (it's free to download). Check the timing and execution plan. If that is fast then it's your PHP. If the SQL is slow then at least you know where to look
Mostafa Salama S 30-Jul-20 4:26am    
acutely i see slow time on SQL Server Management on the server but on local it's go fast
but i seed it's from SQLServer linux is this true ?

1 solution

There is nothing we can do other than suggest some things to look for. We can't run your code so we can't track down why it is slow. As Chill60 suggested, run the sql directly in SSMS and see how it performs. Put breakpoints and logging in your code and narrow down what is causing the issue. You might need more RAM or better CPU or indexes in SQL. You'll have to troubleshoot it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900