I have a table with different articles. The article has two states:
- new
- enabled
The user can only order articles, who are enabled. The user also can delete new articles. And here is the problem, it tooks too long the delete a 'new' article. It's about 10 minutes. The reason is, there are some foreign keys from other tables. There are about 10million orders, 15million bills and 5million returns.
I already created different indexes on the order, bill and return table. I also tried to disable all constraints, delete the article and enable the constraints again. If the constraints are disabled, it works really fast, but it took about 10 minutes the enable my constraints again.
Does anyone has an idea how I can solve this problem? The solution lives only two years and the tables will keep growing for the next few years, so I need a solution, who keeps working for a longer time. My best idea was to create a 'deleted' flag on the article table, but in that case, my article table will grow faster.
I could post an execution plan, but it will only say, that it took too long the check the order, bill and return table.