Archivo del blog
Entradas populares
-
Aquí os pongo una lista de los faros más altos del mundo: Faro Jeddah : este es el mayor favor que se ha construido nunca, está localizado e...
-
En el Reino Unido, han desvelado una maquina que tiene mas de 2000 años de antiguedad. Segun comentan empleando calculos matematicos babilo...
-
El cañón en cuestión (llamada DORA ) fue creado por la empresa Krupp durante la II Guerra Mundial. Hitler quería un arma capaz de "atra...
CRM 4.0: Update Rollup 9 for Microsoft Dynamics CRM 4.0
Para todos aquellos, que tenéis el CRM 4.0 comentaros que ha salido un nuevo rollup el 9, y es conveniente instalarlo. Aquí os dejo los links del articulo en la KB de Microsoft y el de la descarga:
Yo como consejo particular os recomiendo esperar un poco antes de realizar la actualización, para ver si esta actualización ha generado algún problema grave o inesperado, entre aquellos que hicieron la actualización...., llamadlo prudencia si queréis pero es que ya las he visto de todos los colores
- Microsoft Download Center:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=5869f2b3-d1a0-4f71-8be3-fde6e8053a2e - Microsoft Knowledge Base Article:
http://support.microsoft.com/?kbid=977650
Yo como consejo particular os recomiendo esperar un poco antes de realizar la actualización, para ver si esta actualización ha generado algún problema grave o inesperado, entre aquellos que hicieron la actualización...., llamadlo prudencia si queréis pero es que ya las he visto de todos los colores
Frase del día
El arte de vencer las grandes dificultades se estudia y adquiere con la costumbre de afrontar las pequeñas.
Cristina Trivulzio di Belgioioso (1808-1871)
Cristina Trivulzio di Belgioioso (1808-1871)
Frase del día
John Ernest Steinbeck (Escritor Estadounidense) 1902 - 19068
CRM 4.0, Worflowlogbase y AsynOperationbase very large
I am really sure, if you are working with Microsoft CRM 4.0 for few time, or you are fighting with it... and you open the database, with a name similar to Your-ORG_MSCRM, and you check this tables:
- AsyncOperationBase
- WorkflowLogBase
Look the properties, number of lines and also MB of these tables, sure you will have a fright.... I am sure they have a lot of lines, and also an important size in MB, I bet they do... The reasons for this:
- The CRM 4.0 by default doesn´t delete the finished workflows, due to this in the Workflowlogbase table, a lot of unnecessary information is stored.
- The Asyncoperationbase table, is used to save information of Microsoft CRM Asynchronous Processing Service (MSCRMAsyncService), which lead again in a lot of unnecessary information is stored.
The steps we will follow to solve the problem are the following:
- The first step is ESSENTIAL, make a complete backup of CRM DATABASES
- We will modify or add some keys in the register, to avoid finished Workflows to be stored in the database
- We will run some scripts in the database that will empty Worflowlogbase and Asyncoperationbase tables
Well, lets work...
1-Backup
Well..., I think all of you Know how to make a SQLSERVER backup.... so I will jump this step... If you don´t know how to make a backup... I am not sure if you should continue readinf this article.... (well anyway if you google you will find how to make a backup easyly)
2-Windows Register Modification:
- Go to this branch of the register Windows HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM
- Check if the following key exists AsyncRemoveCompletedWorkflows, in case that exist change the value of this key to 1
- In the case that this value doesn´t exist, we will create a DWORD key with the next name AsyncRemoveCompletedWorkflows and set the value of this register in 1
- We wil execute an IISRESET in a MSDOS window, this will restart IIS services.
¿What are we doing setting the value of this register in 1 or adding the key AsyncRemoveCompletedWorkflows in the Windows register? By Default CRM 4.0 save in the databse all workflows, even those which had finished, for the majority of us this information is unusable, setting this register AsyncRemoveCompletedWorkflows to 1 no more finished workflows will be stored in the CRM database.
3-Running scripts to empty the lines of the Workflowlogbase and Asyncoperationbase.
Now in the CRM 4.0, no more finished workflows will be stored. But... how we should proceed to delete the information of those finished workflows that has been saved previously in Workflowlobase and Asyncoperationbase tables? , sure that there are hundreds, thousands, or probably millions of lines... don´t worry we have a solution for this... Remember that these scripts must be executed in the database which name is similar to this Your-ORG_MSCRM
- Stop "Microsoft CRM Asynchronous Processing Service"
- Second step we will create indexes to optimize the script execution:
GO
CREATE NONCLUSTERED INDEX CRM_DuplicateRecord_AsyncOperationID ON [dbo].[DuplicateRecordBase] ([AsyncOperationID])
GO
CREATE NONCLUSTERED INDEX CRM_BulkDeleteOperation_AsyncOperationID ON [dbo].[BulkDeleteOperationBase] (AsyncOperationID)
GO
- Third step, update and rebuild the following indexes:
ALTER INDEX ALL ON AsyncOperationBase REBUILD WITH (FILLFACTOR = 80, ONLINE = OFF,SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = OFF)
GO
ALTER INDEX ALL ON WorkflowLogBase REBUILD WITH (FILLFACTOR = 80, ONLINE = OFF,SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = OFF)
GO
- Fourth step, update all statystics involved in the queries...
UPDATE STATISTICS [dbo].[DuplicateRecordBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[BulkDeleteOperationBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[WorkflowCompletedScopeBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[WorkflowLogBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[WorkflowWaitSubscriptionBase] WITH FULLSCAN
- Last step, this is the script that will delete the unusable information from this two tables:
IF EXISTS (SELECT name from sys.indexes
WHERE name = N'CRM_AsyncOperation_CleanupCompleted')
DROP Index AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted
GO
CREATE NONCLUSTERED INDEX CRM_AsyncOperation_CleanupCompleted
ON [dbo].[AsyncOperationBase] ([StatusCode],[StateCode],[OperationType])
GO
declare @DeleteRowCount int
Select @DeleteRowCount = 2000
declare @DeletedAsyncRowsTable table (AsyncOperationId uniqueidentifier not null primary key)
declare @continue int, @rowCount int
select @continue = 1
while (@continue = 1)
begin
begin tran
insert into @DeletedAsyncRowsTable(AsyncOperationId)
Select top (@DeleteRowCount) AsyncOperationId
from AsyncOperationBase
where OperationType in (1, 9, 12, 25, 27, 10) AND StateCode = 3 AND StatusCode in (30, 32)
Select @rowCount = 0
Select @rowCount = count(*) from @DeletedAsyncRowsTable
select @continue = case when @rowCount <= 0 then 0 else 1 end
if (@continue = 1)
begin
delete WorkflowLogBase from WorkflowLogBase W, @DeletedAsyncRowsTable d
where W.AsyncOperationId = d.AsyncOperationId
delete BulkDeleteFailureBase From BulkDeleteFailureBase B, @DeletedAsyncRowsTable d
where B.AsyncOperationId = d.AsyncOperationId
delete AsyncOperationBase From AsyncOperationBase A, @DeletedAsyncRowsTable d
where A.AsyncOperationId = d.AsyncOperationId
delete @DeletedAsyncRowsTable
end
commit
end
--Drop the Index on AsyncOperationBase
DROP INDEX AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted
Una vez hecho esto ir a mirar el tamaño de estas dos tablas y veréis el resultado.....
Comentaros:
- It is essential, follow the previous steps, before running the delete script. The create indixes, update statystics etc... if not, it will take a hundred years before finish the delete of the line... (I am talking for my own exprience, had to stop the script after more than some hours running)
- Do Not execute the scripts during peak hours.
That´s it.... hurry up executing scripts, and deleting unuseful information from your CRM database
Source:
CRM 4.0, tablas Worflowlogbase y AsynOperationbase muy grandes
Seguro que los que trabajáis con el CRM 4.0 de Microsoft, hace poco que os estáis peleando con el y abrís la base de datos vais a la base de datos que se llama _MSCRM, y vais a revisar estas dos tablas:
- AsyncOperationBase
- WorkflowLogBase
En las propiedades de las tablas mirad, en tamaño y número de filas de estas tablas, seguro que os lleváis una sorpresa.... ¿A que tienen un montón de registros y ocupan muchos MB? Los motivos que provocan esto:
- El CRM 4.0 por defecto no elimina los flujos de trabajo (workflows) que han finalizado por lo que en la tabla workflowlogbase, se almacena mucha información innecesaria
- La tabla Asyncoperationbase, se emplea para guardar información del servicio asincrónico del CRM (prometo que así lo llama microsoft) MSCRMAsyncService, lo que vuelve a provocar que se guarde mucha información innecesaria.
Los pasos que seguiremos serán los siguientes:
- El primer paso e IMPRESCINDIBLE, HACED UNA COPIA COMPLETA DE LAS BASES DE DATOS DEL CRM
- Modificaremos unas claves del registro, para evitar que los workflows finalizados se guarden en la base de datos
- Ejecutaremos unos unos scripts en la base de datos que vaciarán las tablas Worflowlogbase y Asyncoperationbase.
Bueno pues al lio...
1-Copia de seguridad
Esto..., me imagino que ya sois mayorcitos, y además si estáis leyendo este articulo voy a presuponer que ya sabeis como hacerla..., asi que me saltaré este paso...
2-Modificación del registro de Windows:
- iremos a la siguiente rama del registro de Windows HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM
- Revisaremos si existe la siguiente clave AsyncRemoveCompletedWorkflows en el caso de que exista pondremos el valor de esta clave a 1
- En el caso de que no exista crearemos un registro de tipo DWORD con el nombre AsyncRemoveCompletedWorkflows con el valor de este registro a 1
- Ejecutaremos desde la linea de comandos un iisreset, que reinicirá los servicios del IIS
¿Que hacemos al añadir o poner a uno la clave del registro AsyncRemoveCompletedWorkflows? Por defecto el CRM 4.0 guarda en la BBDD los flujos de trabajo o Workflows, que han finalizado, para la mayoría de nosotros esta información que se guarda en la base de datos no es necesaria, al poner este registro AsyncRemoveCompletedWorkflows con valor 1, a partir de ese momento los workflows finalizados no se guardarán en la BBDD
3-Ejecución de scripts para vaciar de información las tablas Worflowlogbase y Asyncoperationbase.
Ahora el CRM 4.0 ya no guardará más workflows que hayan finalizado, pero que hacemos con los registros de las tablas Workflowlobase y Asyncoperationbase, que seguro que son cientos, miles o con toda seguridad varios millones... bien no preocuparos... Comentaros que todos estos scripts los debeis ejecutar en la base de datos cuyo nombre será algo similar a esto _MSCRM
- Debeis para el "servicio de Procesamiento asincrónico de Microsoft CRM"
- Paso Segundo vamos a crear unos indices para optimizar la ejecución del script:
GO
CREATE NONCLUSTERED INDEX CRM_DuplicateRecord_AsyncOperationID ON [dbo].[DuplicateRecordBase] ([AsyncOperationID])
GO
CREATE NONCLUSTERED INDEX CRM_BulkDeleteOperation_AsyncOperationID ON [dbo].[BulkDeleteOperationBase] (AsyncOperationID)
GO
- Paso tercero, reconstruir y actualizar los siguiente indices:
ALTER INDEX ALL ON AsyncOperationBase REBUILD WITH (FILLFACTOR = 80, ONLINE = OFF,SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = OFF)
GO
ALTER INDEX ALL ON WorkflowLogBase REBUILD WITH (FILLFACTOR = 80, ONLINE = OFF,SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = OFF)
GO
- Paso cuarto actualizar todas las estadísticas que se verán involucradas en las queries...
UPDATE STATISTICS [dbo].[DuplicateRecordBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[BulkDeleteOperationBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[WorkflowCompletedScopeBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[WorkflowLogBase] WITH FULLSCAN
UPDATE STATISTICS [dbo].[WorkflowWaitSubscriptionBase] WITH FULLSCAN
- Paso quinto y último es la ejecución del script que realmente borrar la información superflua de estas dos tablas:
IF EXISTS (SELECT name from sys.indexes
WHERE name = N'CRM_AsyncOperation_CleanupCompleted')
DROP Index AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted
GO
CREATE NONCLUSTERED INDEX CRM_AsyncOperation_CleanupCompleted
ON [dbo].[AsyncOperationBase] ([StatusCode],[StateCode],[OperationType])
GO
declare @DeleteRowCount int
Select @DeleteRowCount = 2000
declare @DeletedAsyncRowsTable table (AsyncOperationId uniqueidentifier not null primary key)
declare @continue int, @rowCount int
select @continue = 1
while (@continue = 1)
begin
begin tran
insert into @DeletedAsyncRowsTable(AsyncOperationId)
Select top (@DeleteRowCount) AsyncOperationId
from AsyncOperationBase
where OperationType in (1, 9, 12, 25, 27, 10) AND StateCode = 3 AND StatusCode in (30, 32)
Select @rowCount = 0
Select @rowCount = count(*) from @DeletedAsyncRowsTable
select @continue = case when @rowCount <= 0 then 0 else 1 end
if (@continue = 1)
begin
delete WorkflowLogBase from WorkflowLogBase W, @DeletedAsyncRowsTable d
where W.AsyncOperationId = d.AsyncOperationId
delete BulkDeleteFailureBase From BulkDeleteFailureBase B, @DeletedAsyncRowsTable d
where B.AsyncOperationId = d.AsyncOperationId
delete AsyncOperationBase From AsyncOperationBase A, @DeletedAsyncRowsTable d
where A.AsyncOperationId = d.AsyncOperationId
delete @DeletedAsyncRowsTable
end
commit
end
--Drop the Index on AsyncOperationBase
DROP INDEX AsyncOperationBase.CRM_AsyncOperation_CleanupCompleted
Una vez hecho esto ir a mirar el tamaño de estas dos tablas y veréis el resultado.....
Comentaros:
- Que es imprescindible realizar los pasos previos de creación de indices, actualizar estadísticas etc... porque sino, va a tardar un mas de un siglo en acabar... (por experiencia propia lo digo, tuve que parar el script a la mitad de ejecución
- No ejecutar estos scripts durante horas puntas de trabajo
Bueno pues ya está, ale ale, a ejecutar scripts y borrar información innecesaria de la base de datos....
Fuente:
Frase del día
Albert Einstein Científico alemán nacionalizado estadounidense
Suscribirse a:
Entradas (Atom)