Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

mysql-connector-net-6.9.12 Performance Issue when Calling Procedure (no replies)

$
0
0
I found mysql connetor/NET using a inefficient way when running procedures.

1. Reproduce:
Here is C# snippt where calling procedure:

MySqlConnection conn = new MySqlConnection();
conn.ConnectionString = "server=localhost;user=root;database=test;port=3306;password=******";
MySqlCommand cmd = new MySqlCommand();
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "test_proc";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@param_1", "test");
cmd.Parameters["@param_1"].Direction = ParameterDirection.Input;
cmd.ExecuteNonQuery();


2. Problem:
Connector/NET went with a SQL below
SELECT *
FROM mysql.proc
WHERE 1 = 1
AND db LIKE 'xxxx'
AND NAME LIKE 'xxxxx'

This SQL uses range scanning and most of rows in mysql.proc are scanned.


3. Suggestion:

Can we just use SQL below instead?
SELECT *
FROM mysql.proc
WHERE 1 = 1
AND db = 'xxxx'
AND NAME = 'xxxxx'

This SQL uses ref scanning and the only matched row is scanned. In my test, it's 10 times faster than using 'Like'.

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>