我的查询如下,这在删除与顶级查询的“DISTINCT permissionid”子句不同后完美运行。
SELECT modulename,
Group_concat(DISTINCT permissionid) Permissions FROM licensedproductpermission
JOIN vw_licensedproduct USING (licensedproductid)
JOIN modulepermission USING (permissionid)
JOIN module USING (moduleid) WHERE ( permissionid IN (SELECT permissionid
FROM rolepermission
WHERE roleid IN (SELECT roleid
FROM userrole
WHERE userid = 14)) ) GROUP BY modulename UNION SELECT modulename,
permissionid FROM modulepermission
JOIN module USING (moduleid) WHERE permissionid IN ( 159 )
AND ( permissionid IN (SELECT permissionid FROM rolepermission
WHERE roleid IN(SELECT roleid
FROM userrole
WHERE userid = 14)) ) UNION SELECT modulename,
permissionid FROM modulepermission
JOIN module USING (moduleid) WHERE moduleid IN ( 160, 98 ) UNION SELECT modulename,
permissionid FROM licensedproductpermission
JOIN vw_licensedproduct USING (licensedproductid)
JOIN modulepermission USING (permissionid)
JOIN module USING (moduleid) WHERE permissionid = 1
但是使用 DISTINCT permissionid 这会在一段时间后开始抛出异常。在 mySQL 重新启动后,它会再次工作一段时间。在打开连接时,我们正在设置服务器变量,例如;
'Open Connection
<System.Runtime.CompilerServices.Extension()> _
Public Function OpenConn(conn As MySqlConnection) As MySqlConnection
If conn.State <> ConnectionState.Open Then conn.Open()
Dim sSetSql As String = _
"SET SESSION tmp_table_size = 1024 * 1024 * 1024 * 2; " & _
"SET SESSION max_heap_table_size = 1024 * 1024 * 1024 * 2; " & _
"SET SQL_BIG_SELECTS=1; " & _
"SET SESSION GROUP_CONCAT_MAX_LEN=1048576; " & _
"SET NET_WRITE_TIMEOUT=99999; " & _
"SET NET_READ_TIMEOUT=99999; " & _
"SET SESSION WAIT_TIMEOUT=99999;"
clsDBAccess.cmdExecuteQueryWithoutLog(conn, sSetSql, Nothing)
Return conn
End Function
在连接关闭时..
<System.Runtime.CompilerServices.Extension()> _
Public Sub CloseConn(conn As MySqlConnection)
If Not IsNothing(conn) AndAlso conn.State = ConnectionState.Open Then conn.Close()
conn = Nothing
GC.Collect(0, GCCollectionMode.Forced)
GC.Collect(0, GCCollectionMode.Forced)
End Sub
请求建议我们在哪里泄漏内存,因为这在重新启动 MySQL 后对某些人有效。