question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slow "update schema" part of the build process

See original GitHub issue

Description

The “update schema” part of the build process is very slow - close to 20 minutes for only 850 pages. From what I’ve read it seems that the build process should be much faster than this and considering you’re currently looking for projects with 50k+ pages which would take close to 20 hours at this pace.

Every part of the build process seems reasonably fast, only the “update schema” takes very long and “run queries” also being slower than I would expect.

Steps to reproduce

Github repo https://github.com/MartinMikusat/gatsby-reproduce

I’ve made it create only 50 pages so it doesn’t do more work than necessary to make the point and added some instructions in README for making it create all ~850 pages if you want to test it like that as well. It takes too long even with 50 pages.

Just run npm install and gatsby develop

Expected result

Running the initial build should be fast

Actual result

Running the initial build is slow

Environment

System: OS: Windows 10 10.0.18362 CPU: (4) x64 Intel® Core™ i5-7200U CPU @ 2.50GHz Binaries: Node: 12.14.0 - C:\Program Files\nodejs\node.EXE npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD Languages: Python: 2.7.17 Browsers: Edge: 44.18362.449.0 npmPackages: gatsby: ^2.18.12 => 2.18.12 gatsby-image: ^2.2.38 => 2.2.38 gatsby-plugin-eslint: ^2.0.8 => 2.0.8 gatsby-plugin-material-ui: ^2.1.6 => 2.1.6 gatsby-plugin-postcss: ^2.0.7 => 2.1.19 gatsby-source-sanity: ^5.0.5 => 5.0.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vladarcommented, Jan 17, 2020

@MartinMikusat thanks for bringing this up!

It looks like you put too much data into the page context. You put your whole data set into it: https://github.com/MartinMikusat/gatsby-reproduce/blob/master/gatsby-node.esm.js#L83

Page context is not meant for passing data to pages. It is meant to pass simple parameters that could be later passed to the GraphQL query of the page as variables.

There is an overhead associated with context - Gatsby has to visit every field of every object in context to infer SitePageContext type.

You have pages for 850 nodes (SanityLens in your example) and each page context has all the nodes in it. Also, each node has about 30 fields. It means that Gatsby has to visit 850 * 850 * 30 fields (which is approx. 21,7 million).

We could do better by showing a warning in cases like this (when the context is not used appropriately) and we have an issue exactly for this problem: #14213

Sorry if it is a bit confusing and thanks for using Gatsby 💜

0reactions
MartinMikusatcommented, Feb 11, 2020

Thanks for the reply. I figured out something similar myself at the end but I have since redesigned the whole website completely, so unfortunately I can’t show a working example of this for others. I guess I can close this issue now. Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What causes pt-online-schema-change to slow down the ...
This feeds back to slowing down the processing, which pt-online-schema-change smartly turns into smaller chunk sizes. It is sometimes better to rebuild indexes ......
Read more >
Loading schema into a new, empty database is slow (prodict/l
One problem I've noticed in the automatic build operations is that the creation of an empty database is a bit slow.
Read more >
Pt online schema change is very slow on prod server
i have a mysql server which is always having 1000+ connections and runing threads >100 when i tries to execute the pt-osc on...
Read more >
Improving Build Performance Guide - Gatsby
Improving build performance is an iterative process: locate key problem areas, identify potential changes, test the impact of those changes on build speed, ......
Read more >
Can't update with schema compare - sql server - Stack Overflow
Check the bottom of the screen after a compare it shows status messages there. I've seen this issue if there is a compile...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found