-1
I created a method that updates to oracle. However, it is absurdly slow when it does. When I do other operations like "INSERT and SELECT" in this same table, the response time is very fast. Could you help me, please?
Follow the code below:
public void UpdateUsuario(string usuario, string novosetor)
{
string sql = @"UPDATE cda_f_usuasetor USUASETOR SET CDA_N_SETOR = '" + novosetor + "' WHERE CDA_X_USUARIO = '" + usuario + "'";
OpenConnection();
using (Cmd = new OracleCommand(sql, Con))
{
Cmd.CommandType = System.Data.CommandType.Text;
OracleDataReader dr = Cmd.ExecuteReader();
dr.Close();
}
CloseConnection();
}
Thank you!
This same operation performs quickly when executed directly in your database?
– Bruno Warmling
See if there is an index in the "CDA_X_USUARIO" field, also do not pass values directly to your command because you are subject to SQL Injection.
– Leonardo Buta
Bruno, yes. When I run direct on Oracle . Run quickly
– Rafael Veloso
Leonardo, it contains no index. As you would recommend it to do?
– Rafael Veloso
Thus: "CREATE INDEX IX_CDA_X_USUARIO ON cda_f_usuasetor (CDA_X_USUARIO)". Also, in your code as you are running a query where there is no return, switch to "Cmd.Executenonquery" and remove the Oracledatareader variable.
– Leonardo Buta