Slowness from PSU instead of direct powershell

Hi guy !

I have an issue with endpoint.
I created an endpoint in order to launch a mysql query to retrieve some datas.
I have a psm1 file who contains the function to launch the query :slight_smile:

like this : function Set-MYSQL {
param([string]$requete
)

$mysqlId = $secret:MysqlID 
$mysqlPassword = $secret:MysqlPassword
$mysqlport = $secret:MysqlPort

$ConnStr = 'server=' + '127.0.0.1' + ';uid=' + $mysqlid + ';password="' + $mysqlPassword + '";database=Jarvis;Port=' + $mysqlport

$ObjMysql = New-Object MySql.Data.MySqlClient.MySqlConnection($ConnStr)
 
$ObjMysql.Open()

$SQLCommand = New-Object MySql.Data.MySqlClient.MySqlCommand($requete, $ObjMysql)

$MySQLDataAdaptater = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($SQLCommand)

$MySQLDataSet = New-Object System.Data.DataSet

$RecordCount = $MySQLDataAdaptater.Fill($MySQLDataSet)

$MySQLDataAdaptater.Dispose()
$SQLCommand.Dispose()
$ObjMysql.close()
$ObjMysql.Dispose()

return $MySQLDataSet.Tables

}

I added this psm1 in module on my Windows PowerShell 5.1 environnement in PSU

when i launching this from a powershell script i take less than 1 sec BUT with PSU in endpoint it’s more than 1 sec and i don’t understand why.

Do you have a clue or something else in order to reduce time from PSU ?

Hi,

Do you have some clue on that ?

thanks

Can you try to enable Persistent Runspaces for your environment? I’m wondering if something is being cleaned up between runs.

Also, how much data are you returning from this query? Is it an issue with the serialization to JSON? You could verify this by trapping the output with Out-Null.

Hello,

it works really better.

thanks