Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

improve db query performance, using between instead of strftime - #84

Merged
skx merged 1 commit into
skx:masterfrom
yorks:master
Aug 1, 2021
Merged

skx merged 1 commit into
skx:masterfrom
yorks:master

Conversation

@yorks

@yorks yorks commented Jul 29, 2021 •

Copy link
Copy Markdown
Contributor

the different performance like this:

sqlite> SELECT distinct state, COUNT(state) AS CountOf FROM reports WHERE strftime('%d/%m/%Y', DATE(executed_at, 'unixepoch', 'localtime'))='15/04/2021' GROUP by state;
state|CountOf
changed|154
failed|6532
CPU Time: user 2.118060 sys 0.109253
sqlite> SELECT distinct state, COUNT(state) AS CountOf FROM reports WHERE executed_at between 1618416000 and 1618502399 GROUP by state;
state|CountOf
changed|154
failed|6532
CPU Time: user 0.316440 sys 0.113149

@skx

skx commented Aug 1, 2021

Copy link
Copy Markdown
Owner

That looks good, thank-you for your contribution :)

@skx
skx merged commit 7f81ccd into skx:master Aug 1, 2021
@corporate-gadfly

Copy link
Copy Markdown
Contributor

@yorks: could you tell me which screen(s) is this query used on?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址