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

[snowflake] Cache information schema queries on snowflake #1092

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

iskakaushik
Copy link
Contributor

In cases there are thousands of tables, PeerDB runs A LOT of INFORMATION_SCHEMA queries to Snowflake’s INFORMATION_SCHEMA which counts as Cloud Service usage. This results in very high credit consumption w/ ~1:25 ratio of regular credit consumed to cloud services credits consumed (see screenshot) — so even if an XSMALL or SMALL warehouse is used (1, 2 credits/hour respectively) we still end up consuming ~50 credits an hour.

image

In cases there are thousands of tables, PeerDB runs A LOT of INFORMATION_SCHEMA queries to Snowflake’s INFORMATION_SCHEMA which counts as Cloud Service usage. This results in very high credit consumption w/ ~1:25 ratio of regular credit consumed to cloud services credits consumed (see screenshot) — so even if an XSMALL or SMALL warehouse is used (1, 2 credits/hour respectively) we still end up consuming ~50 credits an hour.
func (c *SnowflakeInformationSchemaCache) SchemaExists(schemaName string) (bool, error) {
schemaName = strings.ToUpper(schemaName)

if cachedExists, ok := cache.schemaExistsCache.Get(schemaName); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit unfortunate that they made an LRU expirable cache without an atomic GetOrUpsert method

@serprex
Copy link
Contributor

serprex commented Jan 17, 2024

should probably generalize this for bigquery

@iskakaushik iskakaushik merged commit 53bec30 into main Jan 17, 2024
7 checks passed
@serprex serprex deleted the snowflake-is-cache branch July 19, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants