benles wrote:
This is more of a SQL Server question, but I was motivated to set up foreign key relationships so LLBLGen could detect the relationships. The problem is that it seems to make deletes extremely slow. Does anyone have suggestions? My database has millions of records and 'delete from table' is far slower than 'truncate table'.
That's because delete from table inserts for every row a rollback statement in the transaction log, so you can rollback the delete later on even when the transaction is committed
. Truncate table doesn't do that, it just throws away the data.
So with millions of rows, delete from table is pretty slow, as it has to store a lot of transaction log messages. if you don't need to rollback the action, just use truncate table, though when there might be a possibility you need it, use delete from table.