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

Confused about the query time #17022

Open
icy17 opened this issue Jul 19, 2024 · 1 comment
Open

Confused about the query time #17022

icy17 opened this issue Jul 19, 2024 · 1 comment
Labels
question Further information is requested

Comments

@icy17
Copy link

icy17 commented Jul 19, 2024

Hi! I'm using a query like:

from FunctionCall target
 where
 predicate1(target)
 and predicate2(target)
 and predicate3(target)
 and predicate4(target)
 select target, target.getLocation().toString()

I found that if I query one predicate at a time, the time is very short, if I query 4 times separately, will the intersection of the results be the result of querying all the predicates at once?
If so, why is the sum of the time for the separate query so much shorter than the time for the one-time query?

@icy17 icy17 added the question Further information is requested label Jul 19, 2024
@aibaars
Copy link
Contributor

aibaars commented Jul 19, 2024

I'm not sure I fully understand your question. I assume you are using the CodeQL for VSCode extension's quick-evaluation feature to evaluate the 4 predicates in isolation and to run the query as a whole. Measuring runtime like that is quite tricky, because CodeQL caches intermediate results, so if you ran the whole query, the individual predicates are likely to be fast because their results are in the cache. There is a command CodeQL: Clear Cache that might help a bit.

Another difference is that the whole query calculates the locations and their toString values. This probably doesn't cost much time, but if there are a lot of locations it might be noticeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants