Bug Description

When creating pages from a single query, currently data that is required for any parameter value is included in all the pages.

This causes multiple issues:

  • Each page can be very large when built, if you have a large number of parameterized routes, as each page ships with all the data. Users have reported page sizes of 5MB.
  • You cannot "sandbox" the parameterized page easily. You may wish to make certain routes only accessible to specific users. For example if you were creating one page per customer, and wished to give them access. In this case the customer would be able to see the data of others customers contained in the page
0

+1, I am working with a large database of country related data, and each page should show only a single country's data. As filtering is done only as a very last step on the client, the data is 200x larger than it could be. Any chance this will be tackled soon?

0

Hey @MoritzStefaner

An unlock for this we think is in #294, adding support for Frontmatter, as this at least gives users a place to define global filters they would want every query to be filtered by.

That issue is up in the next cycle for us, so we hope to have that done "soon".

Then we're in a good place to get this issue started! There are a couple of things we'd need to iron out, off the top of my head these are:

  • What's the syntax for the filter in the frontmatter
  • How do we inject this into the queries
    • It's effectively a WHERE clause - and these are applied post SELECT and FROM, but before GROUP, ORDER and LIMIT
    • Perhaps we can add a compile step: SELECT * FROM existing_query WHERE column = condition
0

Hi, interesting! Yes, that makes a lot of sense and would be quite convenient.

The simpler version I had in mind was to be able to use the page parameters also in the SQL queries, a la

select
  count(*) as num_events
from events
where country = {$page.params.country}

but probably that collides with when those clauses are rendered?

0

I can see why that would be convenient too.

As you say there are some implementation details that make this slightly tricky, but it's useful to know that's how you'd expect this to work.

I can also see scenarios where you wouldn't want to filter every query on a page by the condition. E.g. maybe one of the queries on the page shows a country in comparison to other countries, whereas the rest only contain country data

0

I can also see scenarios where you wouldn't want to filter every query on a page by the condition. E.g. maybe one of the queries on the page shows a country in comparison to other countries, whereas the rest only contain country data

Right!

0
© 2022 pullanswer.com - All rights reserved.