When Initalising the persistence broker on a MySQL database, I found it to be very slow. I changed the function getTableSchema in AF_MySQL to add a clause "WHERE 0 = 1" so that no rows are returned.
Is this likely to cause problems elsewhere? and is it something that can be added to a later release?
Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements IConnection.getTableSchema
Dim statement As String
Dim cmd As MySqlCommand
Dim dr As MySqlDataReader
Dim dt As DataTable
statement = "select * from " & tName & " WHERE 0 = 1"
Try
cmd = New MySqlCommand(statement, Me.Connection)
dr = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
dt = dr.GetSchemaTable
Catch ex As Exception
dt = Nothing
Throw ex
End Try
Return dt
End Function
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The reader is only getting the schema of the tables, and should not actually return any records.
It seems like the statement is still getting executed which is why it's slow for you. I don't know if thats a behaviour just with the MySql ADO.NET provider or if it's consistent across all providers - I'll have to check.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
When Initalising the persistence broker on a MySQL database, I found it to be very slow. I changed the function getTableSchema in AF_MySQL to add a clause "WHERE 0 = 1" so that no rows are returned.
Is this likely to cause problems elsewhere? and is it something that can be added to a later release?
Public Function getTableSchema(ByVal tName As String) As System.Data.DataTable Implements IConnection.getTableSchema
Dim statement As String
Dim cmd As MySqlCommand
Dim dr As MySqlDataReader
Dim dt As DataTable
statement = "select * from " & tName & " WHERE 0 = 1"
Try
cmd = New MySqlCommand(statement, Me.Connection)
dr = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
dt = dr.GetSchemaTable
Catch ex As Exception
dt = Nothing
Throw ex
End Try
Return dt
End Function
It should cause no problems.
The reader is only getting the schema of the tables, and should not actually return any records.
It seems like the statement is still getting executed which is why it's slow for you. I don't know if thats a behaviour just with the MySql ADO.NET provider or if it's consistent across all providers - I'll have to check.
- Richard.