-
Hi all - I've been following #245 and #1523 and have just implemented some pages with parameterized routes. I am however having a persistent issue with page loading speed. Using the example of product sales from the docs, suppose I have a
SELECT
DATE(sale_date) AS sale_day,
SUM(quantity) AS total_quantity_sold,
SUM(total_amount) AS total_sales_amount
FROM product_sales
WHERE product_id = ${observable.params.product}
GROUP BY DATE(sale_date)
ORDER BY sale_day However, if the number of products in
Otherwise, how do you suggest working with SQL in parameterized pages? I'm pretty sure I can do everything I need with data loaders, but it is very nice to work with the sql blocks inside the page, particularly as I've got multiple charts that rely on slightly different slices of the same data. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The first option is that you can use a relative path. So if your page is at A second option is to use ```js
const sql = DuckDBClient.sql({
product_sales: FileAttachment(`./data/product_sales_${observable.params.product}.csv`)
});
``` A third option is that you can use a page loader. In this case your page loader is at |
Beta Was this translation helpful? Give feedback.
The first option is that you can use a relative path. So if your page is at
/products/[product]/index.md
, you can have a data loader at/products/[product]/sales.csv.js
that generates the sales data for that particular product, and then you can load the data as./sales.csv
. Because this is within the/products/[product]/
directory, the relative path to the data will be resolved to use the same parameter value.A second option is to use
DuckDBClient.sql
to register the sources in JavaScript. This gives you a bit more flexibility since you can reference parameters.