Delete Guests Task & Maintenance - Timeout Error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 9 ans
I manage 6 different stores with one NopCommerce 3.40 installation and each store has approximate 5000 products. I've added all my stores to be crawled by google and bing. So lots of action is happening and with that action there are a lot of guests records created. Way too many to delete in the maintenance section without crashing, and the task can't keep up. I run the task every 2 minutes, and still more records are created than the task can delete. When I look at the current online customers, I see that 70% are crawlers. Is there a way to exclude crawlers? Is there a better way to automate the deletion of guest records?

For now I use a sql file I've created and run it manually:

USE [database]
GO

--SELECT Count(*)
DELETE Customer
FROM Customer
INNER JOIN Customer_CustomerRole_Mapping
ON Customer.Id = Customer_CustomerRole_Mapping.Customer_Id
WHERE Customer_CustomerRole_Mapping.CustomerRole_Id = 4
AND Customer.CreatedOnUtc < DATEADD(Day, -1, GETDATE()) AND Customer.HasShoppingCartItems = 0

USE [database]
GO

--SELECT count(*) FROM [GenericAttribute]
DELETE TOP(1000000) FROM [GenericAttribute]
WHERE [EntityId] NOT IN (SELECT c.[Id] FROM [Customer] c WITH (NOLOCK))
AND [KeyGroup]=N'Customer'
GO

Il y a 9 ans
Instead of using nop scheduler i would write sql job in database level that would very faster and application independent

[url=
http://msdn.microsoft.com/en-us/library/ms187910.aspx]Create a Transact-SQL Job Step[/url]

Also, I do not think guest user should be created by  search engine crawler, nop already filter search engine I believe.
Il y a 9 ans
Thanks. I've just created a work item for this performance task
Il y a 9 ans
Done. Please see changeset d7bad94141ff
Il y a 9 ans
a.m. wrote:
Done. Please see changeset d7bad94141ff


Thx a.m. This is much faster than the LINQ implementation. Great work.
Il y a 7 ans
I know this post is old, but i would like to leave a warning.

Beware: Running the query in the first post will delete all orders where customers have been deleted because of cascading in the database.
Il y a 7 ans
If you end up here with the same problem:

I executed this using sql query.

declare @a datetime
set @a = CAST('02-21-2015 6:10:00 PM' AS DATETIME2)
exec dbo.DeleteGuests 1, @a, null

It will delete all guests after 21. 02. 2015. the parameter 1 is for OnlyWithoutShoppingCart.

Adjust as you want and do a query against your database.

Backup first!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.