Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Strategies for reducing number of queries to a DB

$
0
0

This might not be a Julia question per se, but I didn’t know whether or not it should be here or Off-Topic.

Say I am writing a package for my company’s corporate reporting, and I have a large table in a database.
If I need to derive two different metrics from the same dataset and create a function to derive each metric, how could I avoid querying the database in each function call and thus having to wait for the query to return twice when compiling the report?

Right now I am doing something like this

module foo
__precompile__(false)

function querythedata()
# Wrap some sql
end

const data = querythedata()

function metric1()
# Create a metric from data
end

function metric2()
# Create another metric from data
end

end

This seems a bit clumsy to me but I can’t for the life of me think of a better way to do this.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles