Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic Request: Caching (pre-loading) Layer with the duckDB #150

Closed
7 tasks done
kokokuo opened this issue Apr 6, 2023 · 0 comments
Closed
7 tasks done

Epic Request: Caching (pre-loading) Layer with the duckDB #150

kokokuo opened this issue Apr 6, 2023 · 0 comments
Assignees
Labels
needs-triage type/epic Epic feature request

Comments

@kokokuo
Copy link
Contributor

kokokuo commented Apr 6, 2023

What’s the problem you're trying to solve

In order to enhance our query performance after users send the API request to run our data endpoint to get the result from the data source. We need to provide a Caching (pre-loading) Layer with the duckDB to enhance query performance.

Describe the solution you’d like

Define the cache layer in YAML by cache field, and define each cacheTableName and its config. For example we define an sql select * from order query the result from data source pg and keep to duckDB by order table name.

Otherwise, the refreshTime and refreshExpression means when should we need to refresh the query and keep the new result in the cache table in duckDB. The index is a duckDB indexes feature to index like the original database and make query efficient.

# API schema YAML
cache:
  # "order" table keep in duckDB
  - cacheTableName: "order"
      sql: "select * from order",
      # optional
      profile: pg
      # optional
      refreshTime:
        every: "5m"	
      # optional
      refreshExpression:
        expression: "MAX(created_at)"
        every: "5m"
      # optional
      indexes:
        'idx_a': 'col_a'
        'idx_b': 'col_b'

  # "product" table  keep in duckDB
  - cacheTableName: "product"
       sql: "select * from product",

# used data source
profiles: pg

Here is our SQL file, which makes our query send to duckDB to get results. In the scop of {% cache %} ... {% endcache %} , when we send the query to duckDB, we will search the each table keep in duckDB or not, so if your YAML not defined the same cache table name, it will make the query failed.

-- The "cache" scope means the SQL statement will send the query to duckDB cache data source
{% cache %}
select * from order
  where type = {{ context.params.type }}
  and where exists (
    select * from product  where price >= {{ context.params.price }}
    and order.product_id = product.id
  )
{% endcache %}

Breakdown

The #157 not contains in the epic, we will arrange to develop it in the future.

@kokokuo kokokuo changed the title Caching (pre-loading) Layer with the duckDB - Parse “cache” setting from API Schema YAML Parse “cache” setting from API Schema YAML Apr 6, 2023
@kokokuo kokokuo changed the title Parse “cache” setting from API Schema YAML Caching (pre-loading) Layer with the duckDB - Parse “cache” setting from API Schema YAML Apr 6, 2023
@kokokuo kokokuo changed the title Caching (pre-loading) Layer with the duckDB - Parse “cache” setting from API Schema YAML Epic Request: Caching (pre-loading) Layer with the duckDB Apr 6, 2023
@kokokuo kokokuo changed the title Epic Request: Caching (pre-loading) Layer with the duckDB Epic Feature: Request: Caching (pre-loading) Layer with the duckDB Apr 6, 2023
@kokokuo kokokuo changed the title Epic Feature: Request: Caching (pre-loading) Layer with the duckDB Epic Request: Caching (pre-loading) Layer with the duckDB Apr 6, 2023
@kokokuo kokokuo added type/epic Epic feature request and removed type/enhancement Feature request labels Apr 6, 2023
@kokokuo kokokuo closed this as completed Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage type/epic Epic feature request
Projects
Status: No status
Development

No branches or pull requests

2 participants