I'm loading multiple files into the database using the
LOAD DATA LOCAL INFILE command combined with Golang
database/sql driver like this:
mysql.RegisterLocalFile(fileName) _, err = dbConnection.Exec(loadDataCommand)
This works as expected after the load has finished I run some SELECT queries (I'm reusing
dbConnection for those SELECT queries and all other queries) on newly loaded data and this is where the problem occurs. The above mentioned SELECT queries are unusually slow (due to high CPU usage).
While running LOAD DATA database CPU usage spikes which is expected but after the LOAD DATA finishes CPU usage should drop but it doesn't unless I close and reopen
dbConnection CPU usage stays high.
This is how I'm "reseting" the database connection:
_ = dbConnection.Close() dbConnection, err = sql.Open(databaseDriver, databaseUser+":"+databasePassword+"@tcp("+databaseAddress+":3306)/"+databaseName+"?multiStatements=true")
This is the database configuration.
Why is this happening? The above code is running on a development database so there are no other connections to it.