From 28f6b64f67a89250fdebbb3d9522c3a28e8d9790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 28 Nov 2020 13:24:25 +0100 Subject: [PATCH] Document the including(all:) caveat with compound foreign keys --- Documentation/AssociationsBasics.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Documentation/AssociationsBasics.md b/Documentation/AssociationsBasics.md index 310ff562a..31a6a67d6 100644 --- a/Documentation/AssociationsBasics.md +++ b/Documentation/AssociationsBasics.md @@ -941,7 +941,7 @@ The pattern is always the same: you start from a base request, that you extend w > > - You use the `including(all:)` method (say: `Parent.including(all: children)`). > - The association is based on a compound foreign key (made of two columns or more). -> - The request fetches a lot of parent records. The exact threshold depends on [SQLITE_LIMIT_EXPR_DEPTH](https://www.sqlite.org/limits.html), which you can get with: +> - The request fetches a lot of parent records. The exact threshold depends on [SQLITE_LIMIT_EXPR_DEPTH](https://www.sqlite.org/limits.html). It is around 1000 parents in recent iOS and macOS systems. To get an exact figure, run: > > ```swift > let limit = try dbQueue.read { db in @@ -949,14 +949,12 @@ The pattern is always the same: you start from a base request, that you extend w > } > ``` > -> This threshold is around 1000 parents in recent iOS and macOS systems. +> Possible workarounds are: +> +> - Refactor the database schema so that you do not depend on a compound foreign key. +> - Prefetch children with your own code, without using `including(all:)`. > -> Possible workarounds are: -> -> - Refactor the database schema so that you do not depend on a compound foreign key. Such a refactoring will likely bring performance improvements as well. -> - Prefetch children with your own code, without using `including(all:)`. -> -> For more information about this caveat, see [issue #871](https://github.com/groue/GRDB.swift/issues/871). +> For more information about this caveat, see [issue #871](https://github.com/groue/GRDB.swift/issues/871). ## Combining Associations