hello guys i have a question about what if large servers want to clean their databases so they reduce the maximum size of it
i have a very large database which have more than 44gb data files
and i want to reduce its size by deleting all inactive chars , items and to do that i used a condition that LastLogout must be < 2016 year
but the query is very slow and i found that it will need more than 14 days to finish ! "i calculated it" so anyone have a solution ?
PS : i made it on 2 steps
1
i hope i'm clear with that and i hope i find a good solution here :)
i have a very large database which have more than 44gb data files
and i want to reduce its size by deleting all inactive chars , items and to do that i used a condition that LastLogout must be < 2016 year
but the query is very slow and i found that it will need more than 14 days to finish ! "i calculated it" so anyone have a solution ?
PS : i made it on 2 steps
1
2Quote:
USE SHARD
GO
DECLARE @CharID int
declare @CharName varchar(max) = (select CharName16 FROM _Char where CharID = @CharID)
DECLARE item_cur CURSOR FOR
SELECT DISTINCT CharID FROM _Char where LastLogout < '2016-01-01 00:00:00' ORDER BY CharID
OPEN item_cur
FETCH NEXT FROM item_cur INTO @CharID
WHILE @@FETCH_STATUS = 0
BEGIN
delete from _BindingOptionWithItem where nitemdbid in (select ItemID from _Inventory where charid = @charid )
delete From _ItemPool where itemid in (select ID64 FROM _Items where ID64 in ( select ItemID FROM _Inventory where CharID = @CharID))
delete From _ItemPool where itemid in (select ID64 FROM _Items where ID64 in ( select ItemID FROM _InventoryForAvatar where CharID = @CharID))
delete FROM _Items where ID64 in ( select ItemID FROM _Inventory where CharID = @CharID)
delete FROM _Items where ID64 in ( select ItemID FROM _InventoryForAvatar where CharID = @CharID)
delete from _TrainingCamp where ID IN (SELECT CampID FROM _TrainingCampMember where CharID = @CharID )
delete from _CharNameList where CharID = @CharID
delete from _CharNickNameList where CharID = @CharID
delete from _BlackNameList where BlacklistName = @CharName
delete from _CharCollectionBook where CharID = @CharID
FETCH NEXT FROM item_cur INTO @CharID
END
CLOSE item_cur
DEALLOCATE item_cur
the reason why i used those 2 that the built in proc _DeleteCharPermanently_NoTX doesn't delete the items from _Items table and other staff that i had to make it manuallyQuote:
USE SHARD_VICTOR
GO
DECLARE item_cur CURSOR FOR
SELECT DISTINCT CharID FROM _Char where LastLogout < '2016-01-01 00:00:00' ORDER BY CharID
OPEN item_cur
FETCH NEXT FROM item_cur INTO @CharID
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC _DeleteCharPermanently_NoTX @UserJID, @CharID
FETCH NEXT FROM item_cur INTO @CharID
END
CLOSE item_cur
DEALLOCATE item_cur
i hope i'm clear with that and i hope i find a good solution here :)