The Notes/History tab under the Account will really slow down a user if they open an Account that has thousands of records in the History table. So I watched the SQL that runs when a user does that and the SQL seems silly to me. Is there a way to change the SQL that runs?
The first thing it does is goes to the History table and gets all the HistoryId's for this AccountId that are not a type of "DBCHANGE" or they are "Personal" to the user.
SELECT A1.HISTORYID FROM HISTORY A1 INNER JOIN PICKLIST A2 ON (A1.TYPE=A2.ID) WHERE ((A1.TYPE<>262162) OR (A1.USERID='ADMIN')) AND (A1.ACCOUNTID = :1) AND (A1.TYPE <> 262156)
Then it takes all these ID's and throws then into an IN-Clause for the next SQL statement:
SELECT A1.HISTORYID, A2.TEXT A2_TEXT, A1.COMPLETEDDATE, A1.USERNAME, A1.USERID, A1.CONTACTNAME, A1.RESULT, A1.DESCRIPTION FROM HISTORY A1 INNER JOIN PICKLIST A2 ON (A1.TYPE=A2.ID) WHERE A1.HISTORYID IN ('H6UJ9A002JPB','H6UJ9A001XAO','H6UJ9A001F2G' ,'H6UJ9A001CYT' ,'H6UJ9A001C4U','H6UJ9A001ARE' ,'H6UJ9A0019Q4' ,'H6UJ9A0018HD','H6UJ9A000C7Y','H6UJ9A000B5U', 'H6UJ9A0009YI','H6UJ9A0009A3' ,'H6UJ9A0007W0','H6UJ9A0007HZ','H6UJ9A0007AA', 'H6UJ9A0006Y4','H6UJ9A000637','H6UJ9A0005S0','H6UJ9A0005C2','H6UJ9A0002X4','H6UJ9A00022Q')
That is just an Account with 20 History records. I can't even imagine what it looks like when there are 10,000 History records.
Is there a way to just get all the data in the first SQL and not even do the second SQL? It maks no sense why it even makes the second SQL when they have everything they need in the first one. They just need to return more columns. They're already getting the same records.
Can you change anything in Architect? Can you make a DB view so it won't try to compile a second SQL that is a half-million characters long?
My System:
Oracle database 11.2.0.3.0
SLX 8.0
Windows 2003 Server
One of our Accounts has 26,000 History records. We have 100 Accounts with over 1,000. There are almost 500,000 records in the History table.
No one wants to delete or "archive" any of the History.
When we upgraded our database to a new server, we got the time from 7 minutes on that one large account to 40 seconds, but 40 seconds is still a long time to sit on the phone and wait for your SLX to unlock.
The database indexes are all working correctly. But it takes forever when you throw the SQL with thousands of history ID's in the IN-Clause. |