-
Notifications
You must be signed in to change notification settings - Fork 158
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
Change: move GET iterator time conversion out of SQL #2112
Change: move GET iterator time conversion out of SQL #2112
Conversation
Conventional Commits Report
🚀 Conventional commits found. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good optimization but there is one thing I'd do differently:
I think it would be better to make the allocation of new strings that need to be freed by the caller more explicit.
My suggestion would be to return an int64 from the iterator function and pass that to a new function that does both the ISO date-time conversion and the allocation.
Good idea. I've started with 1e1e147. Will get back to it next week. |
I think the clang-format config should change to allow breaks after the return type of short definitions. |
Hmm, .clang-format already has AlwaysBreakAfterReturnType All. |
Due to a clang-format limitation, see llvm/llvm-project#76206 (comment). Worked around in cb983df. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! You may want to update report_configs as well after updating the branch.
Thanks for going through this big PR. Report configs part done in be66e2e. |
What
Move the ISO time calculations in the "GET" iterators from SQL to C.
This is for the columns
creation_time
andmodification_time
.Note that plain C
iso_time
works the same as SQLiso_time (creation_time, opts.user_zone)
because the C does a tzset before theiso_time
. To test this use GMP like:time o m m '<get_reports report_id="82f3531c-43cd-4453-8300-990dc423d96b" delta_report_id="ea5d9e94-4f48-4a16-b0b5-a63b637176d2" details="1" filter="rows=2 timezone=UTC"/>'
Also, removal of
opt.user_zone
is safe from a filtering perspective, because for the creation_time/created filter term is converted to an epoch.Why
Having the SQL do the time conversion is slower when there are many rows with a large offset, because Postgres still does the time conversion for every row.
time o m m '<get_info type="nvt" filter="sort-reverse=created rows=10 first=80000"/>' > /tmp/info
patch: 0.3, 0.3, 0.3
main: 3.2, 3.2, 3.3
This PR leads to faster SecInfo pages in GSA when paging to the end, CPEs in particular.
References
https://www.postgresql.org/docs/current/queries-limit.html 7.6 LIMIT and OFFSET:
The rows skipped by an OFFSET clause still have to be computed inside the server; therefore a large OFFSET might be inefficient.