我的查询如下, 在从顶部查询的“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后适用于某些人。