Comments (2)
Hi, the speed mostly depends on the machine's memory and the size of the data at hand.
From the specs you've sent the difference might be related to the memory size (32 vs 16 gb). However, q has one feature that might help with that - caching.
When activating caching (-C readwrite
), any file that is being accessed is processed in a regular manner. However, another file with a .qsql
postfix is being written. This file allows subsequent executions to be much much faster and take a much smaller amount of memory.
Using the qsql file can be done in two forms:
- Running again with
-C read
(or-C readwrite
) - q will autodetect the existence of the qsql file and use it. Notice that running without-C
means that the qsql file will be ignored. - Running the query directly on the
.qsql
file (e.g.q 'select ... from myfile.csv.qsql
). In that form, there no need for the original csv/tsv file.
I hope this will help you speed up things. Will be great if you can update here on the results.
Harel
from q.
Thanks for your reply.
The cache is enabled on both my local and production. The query is running on the same file, but it is running twice as slow in production, and that is why I wanted to know if there are any other configurations that need to be checked.
This is my query:
q -H -d ";" -e UTF-8 -Q UTF-8 -C readwrite "select *, iif(cs.adset_status = 'ARCHIVED' or cs.campaign_status = 'ARCHIVED', 'ARCHIVED', iif(cs.adset_status = 'DELETED' or cs.campaign_status = 'DELETED', 'DELETED', iif(cs.adset_status = 'PAUSED' or cs.campaign_status = 'PAUSED' , 'PAUSED', 'ACTIVE'))) as status, domain || '_' || lang || '_' || slug as url, sum(clicks) as r_clicks, ROUND(sum(spend), 1) as r_spend, ROUND(sum(ay_revenue), 1) as r_ay_revenue, ROUND(sum(ay_revenue) - sum(spend), 1) as r_profit, ROUND(avg(cpc), 3) as r_cpc, ROUND(avg(roas), 1) as r_roas, ROUND(avg(cpr), 2) as r_cpr, sum(impressions) as r_impressions, sum(ay_impressions) as r_ay_impressions, sum(ay_sessions) as r_ay_sessions, ROUND(COALESCE(sum(ay_impressions) / sum(ay_sessions), 0), 1) as r_ads_per_session, ROUND((COALESCE((sum(clicks) * 1.0) / sum(impressions), 0) * 100), 1) as r_ctr, ROUND((COALESCE((sum(ay_revenue) * 1.0) / sum(spend), 0) * 1000), 1) as r_ay_roas, ROUND((COALESCE((sum(ay_revenue) * 1.0) / sum(clicks), 0)), 3) as r_rpc, ROUND((COALESCE((sum(ay_revenue)-sum(spend) * 1.0)/sum(ay_revenue), 0) * 100), 1) as r_profit_margin from /var/www/fb-tool/public/storage/reports/campaigns/2023_09.csv as cr left join /var/www/fb-tool/public/storage/reports/adset-statuses/adset-statuses.csv as cs on cr.campaign_id = cs.c_id where date >= '2023-09-01' and date <= '2023-09-30' group by campaign_id order by r_profit desc limit 30 offset 0" -E UTF-8 -O
from q.
Related Issues (20)
- local install fails due to setup.py HOT 3
- Feature request: replace spaces in column names with underline
- HOT 1
- Cannot run WIndows build HOT 4
- How do I use it in GitHub Actions?
- Header -O problem with -b beautify and -f format HOT 1
- Using q inside Windows PowerShell causes encoding issues
- q can't be installed with home-brew anymore HOT 3
- Is entire file loaded into memory to be queried? would prefer read line by line, not whole file loaded in (10Gb file) HOT 2
- Warning about BOM suggest incorrect flag
- header mis-interpretation HOT 1
- Exception ignored in _io.TextIOWrapper when piping output to less HOT 1
- IS DISTINCT FROM not working HOT 1
- ENH: Would you consider making q available through conda? HOT 6
- Always getting "query error: near "~": syntax error" error HOT 4
- BUG: Packaging in broken
- Shall DuckDB be mentioned as "See also" or "Alternative"?
- Support json format ?
- DeprecationWarning: The default datetime adapter is deprecated as of Python 3.12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from q.