Query depth issue Cloudflare D1

I am encountering Expression tree is too large (maximum depth 20) issue mostly with relation queries while using Cloudflare D1. As explained in this issue https://github.com/cloudflare/workers-sdk/issues/4094, this issue is because of the query depth limit set by them which they are considering increasing. My question is, if for now, I were to refactor this query, what would be the most performant way?
1. Using batch
2. Using multiple queries with Promise.all

let result = await d1.query.products.findFirst({
            with: {
                category: true,
                mediaOnProducts: {
                    with: { media: true }
                },
                variants: {
                    with: {
                        items: true
                    }
                },
                variantCombinations: {
                    with: {
                        items: true,
                        media: true
                    }
                }
            },
            where: (products, { eq }) => eq(products.id, productId)
        });
GitHub
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - Issues · cloudflare/workers-sdk
Issues · cloudflare/workers-sdk
Was this page helpful?