# Identified another slow query during backup

**URL:** <https://forum.duplicati.com/t/identified-another-slow-query-during-backup/14005>\
**Category:** Support\
**Created:** [February 24, 2022, 6:54pm UTC](https://forum.duplicati.com/t/identified-another-slow-query-during-backup/14005 "2022-02-24T18:54:50Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tarianjed](https://forum.duplicati.com/user_avatar/forum.duplicati.com/tarianjed/32/6894_2.png) [@tarianjed](https://forum.duplicati.com/u/tarianjed)\
**Post date:** [February 24, 2022, 6:54pm UTC](https://forum.duplicati.com/t/identified-another-slow-query-during-backup/14005/1 "2022-02-24T18:54:50Z")

</div>

So I just started testing out Duplicati and ran into some major issues with query performance causing major delays in my backup successfully completing.

They are running on a ~300GB dataset that is a subset of the almost 40TB I will be eventually backing up. (more info here: [Poor performance on TrueNAS](https://forum.duplicati.com/t/poor-performance-on-truenas/13986))

Luckily I am good with databases so I will be following up with some proposed solutions after this backup successfully completes.

Problem queries:

Runtime - 3:42:24.304 - Location LocalDatabase.cs Line 756

```nohighlight
SELECT "CalcLen", "Length", "A"."BlocksetID", "File"."Path"
FROM ( 
    SELECT "A"."ID" AS "BlocksetID", IFNULL("B"."CalcLen", 0) AS "CalcLen", "A"."Length"
    FROM "Blockset" A 
    LEFT OUTER JOIN ( 
        SELECT "BlocksetEntry"."BlocksetID", SUM("Block"."Size") AS "CalcLen"
        FROM "BlocksetEntry" 
        LEFT OUTER JOIN "Block" 
            ON "Block"."ID" = "BlocksetEntry"."BlockID"
        GROUP BY "BlocksetEntry"."BlocksetID" 
    ) B 
    ON "A"."ID" = "B"."BlocksetID" 
) A, "File"
WHERE "A"."BlocksetID" = "File"."BlocksetID" 
    AND "A"."CalcLen" != "A"."Length"

```

Runtime - 0:12:47:47.152 (currently running multiple times, backup stuck running these 13hr long queries) - Location LocalBackupDatabase.cs Line 586

```nohighlight
SELECT COUNT(*)
FROM "File" 
INNER JOIN "FilesetEntry" ON "File"."ID" = "FilesetEntry"."FileID"
WHERE "FilesetEntry"."FilesetID" = 2 
    AND "File"."BlocksetID" = -200 
    AND NOT "File"."Path" IN (
        SELECT "Path"
        FROM "File" 
        INNER JOIN "FilesetEntry" 
            ON "File"."ID" = "FilesetEntry"."FileID"
        WHERE "FilesetEntry"."FilesetID" = 1
    )

```

I am going to have to monitor this backup until it successfully completes (probably in a week based on current query performance) then do some tests to see what can be done.

---

_[View the full topic](https://forum.duplicati.com/t/identified-another-slow-query-during-backup/14005)._
