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
Quote:
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
2
Quote:
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
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 manually
i hope i'm clear with that and i hope i find a good solution here
USE SRO_VT_SHARD;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE SRO_VT_SHARD
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (SRO_VT_SHARD_Log, 1);
DBCC SHRINKDATABASE (SRO_VT_SHARD,0);
GO
USE SRO_VT_SHARD;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE SRO_VT_SHARD
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (SRO_VT_SHARD_Log, 1);
DBCC SHRINKDATABASE (SRO_VT_SHARD,0);
GO
i don't only want to reduce my database size
i want to delete some parameters from the tables so that i can use any recall query fast from large tables such as _Items
i don't only want to reduce my database size
i want to delete some parameters from the tables so that i can use any recall query fast from large tables such as _Items
Delete parameters! You OFC cannot do that or even change the parameter name since they're being used by the server executable files with their current name.
Delete parameters! You OFC cannot do that or even change the parameter name since they're being used by the server executable files with their current name.
I think you're mistaking "columns" for "parameters"
He meant Rows
USE [SRO_VT_SHARD]
GO
/****** Object: StoredProcedure [dbo].[_STRG_FREE_ITEM_NoTX] Script Date: 12/03/2011 04:26:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[_STRG_FREE_ITEM_NoTX]
@ItemToFree bigint
as
if (not exists(select ItemID from _ItemPool with (nolock) where ItemID = @ItemToFree))
return -1
DELETE FROM _ItemPool where ItemID = @ItemToFree
DELETE FROM _Items WHERE ID64 = @ItemToFree
return 1
sorry but u didn't get it again
i want to delete only old chars not the whole db
read my main post again
Quote:
Originally Posted by hoangphan7
Try this! Goodluck!
Quote:
USE [SRO_VT_SHARD]
GO
/****** Object: StoredProcedure [dbo].[_STRG_FREE_ITEM_NoTX] Script Date: 12/03/2011 04:26:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[_STRG_FREE_ITEM_NoTX]
@ItemToFree bigint
as
if (not exists(select ItemID from _ItemPool with (nolock) where ItemID = @ItemToFree))
return -1
DELETE FROM _ItemPool where ItemID = @ItemToFree
DELETE FROM _Items WHERE ID64 = @ItemToFree
return 1
This time you're the guy who misses-understand, the query I gave you cleans the database from any old characters/users/items/logs/guilds/unions..etc
Quote:
Originally Posted by Microsoft
TRUNCATE TABLE (Transact-SQL)
Removes all rows from a table or specified partitions of a table, without logging the individual row deletions. TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.
If you know that truncates deletes all entries in a table, then you should realize that your queries will delete the whole database.
Not just:
Nah buddy, truncate doesn't delete the entire table, it just deletes the rows and
Quote:
Originally Posted by Microsoft
without logging the individual row deletions. TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.
(You can test TRUNCATE TABLE command yourself before you try my query above)
[QUOTE=#HB;37195694]Nah buddy, truncate doesn't delete the entire table, it just deletes the rows and
WTF ?
it does delete the whole rows inside the table
guys again i don't want to delete all the rows from my tables i just want to delete some of them but this some are like 7 million rows and it took so long
my question was that i want to do that without taking this large time ?
[C++] Sockets - large data handling 03/08/2017 - C/C++ - 11 Replies Hi I would ask you for some help.
I already searched around on google but I always found bad examples or atleast I didn't understand them. (If I worked with sockets then mostly in Java and only chat stuff)
So I want to send large data over network, as I read send/recv has a max length and that I have to send data in chunks. Or don't I have to do that?
The large data is in my case a file, which I read in a char vector and want to send it. The files I want to send are between 100-500KB....
Questions] data Folder >> Create data.Pack 02/15/2012 - Dekaron Private Server - 8 Replies Questions] data Folder >> Create data.Pack
To make the data folder data.pak
Use repacker We've been able to run the update, but the game does not
You, packer and should think about doing anything else specifically that anyway?
Sorry... Bad english..
G Data G Data InternetSecurity 2010 KEY 12/23/2010 - elite*gold Trading - 6 Replies G Data IS 2011+ Backup KEY
Neben verbessertem Testsieger-Virenschutz und Optimierung der intuitiven Benutzerführung sichert G Data InternetSecurity zusätzlich alle Online-Aktivitäten durch eine „Silent“ Firewall. Die professionelle O&O-Vollbackupsoftware bietet zusätzlichen Schutz; selbst bei Totalausfall, Verlust oder Hardwarewechsel.
http://www.gdata.de/uploads/tx_commerce/GDISOB201 1_DE_Webshop_Detail.jpg
Einfach. Sicher. Ressourcenschonend.