Skip to content

Commit b2db72d

Browse files
jf205shati-patel
andauthored
Apply suggestions from code review
Co-Authored-By: shati-patel <42641846+shati-patel@users.noreply.github.com>
1 parent 2ce1c2b commit b2db72d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/language/learn-ql/writing-queries/debugging-queries.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This topic offers some simple tips on how to avoid common problems that can affe
55
Before reading the tips below, it is worth reiterating a few important points about CodeQL and the QL language:
66

77
- CodeQL `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ and `classes <https://help.semmle.com/QL/ql-handbook/types.html#classes>`__ are evaluated to database `tables <https://en.wikipedia.org/wiki/Table_(database)>`__. Large predicates generate large tables with many rows, and are therefore expensive to compute.
8-
- The QL language is implemented using standard database operations and `relational algebra <https://en.wikipedia.org/wiki/Relational_algebra>`__ (such as join, projection, union, etc.). For further information about query languages and databases, see :doc:`About QL <../about-ql>`.
9-
- Queries are evaluated *bottom-up*, which means that a predicate is not evaluated until **all** of the predicates that it depends on are evaluated. For more information on query evaluation, see `Evaluation of QL programs <https://help.semmle.com/QL/ql-handbook/evaluation.html>`__ in the QL handbook.
8+
- The QL language is implemented using standard database operations and `relational algebra <https://en.wikipedia.org/wiki/Relational_algebra>`__ (such as join, projection, and union). For further information about query languages and databases, see :doc:`About QL <../about-ql>`.
9+
- Queries are evaluated *bottom-up*, which means that a predicate is not evaluated until *all* of the predicates that it depends on are evaluated. For more information on query evaluation, see `Evaluation of QL programs <https://help.semmle.com/QL/ql-handbook/evaluation.html>`__ in the QL handbook.
1010

1111
Performance tips
1212
----------------
1313

14-
Follow the guidelines below to ensure that you don't get get tripped up by the most common CodeQL performance pitfalls.
14+
Follow the guidelines below to ensure that you don't get tripped up by the most common CodeQL performance pitfalls.
1515

1616
Eliminate cartesian products
1717
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -20,7 +20,7 @@ The performance of a predicate can often be judged by considering roughly how ma
2020
One way of creating badly performing predicates is by using two variables without relating them in any way, or only relating them using a negation.
2121
This leads to computing the `Cartesian product <https://en.wikipedia.org/wiki/Cartesian_product>`__ between the sets of possible values for each variable, potentially generating a huge table of results.
2222

23-
This can occur whenever you inadvertently fail to specify restrictions on your variables.
23+
This can occur if you don't specify restrictions on your variables.
2424

2525
For instance, consider the following predicate that checks whether a Java method ``m`` may access a field ``f``::
2626

@@ -60,15 +60,15 @@ is preferred over::
6060

6161
predicate foo(Expr e)
6262

63-
From the type context, the query optimizer deduces that some parts of the program are redundant and removes them, or **specializes** them.
63+
From the type context, the query optimizer deduces that some parts of the program are redundant and removes them, or *specializes* them.
6464

6565
Avoid complex recursion
6666
~~~~~~~~~~~~~~~~~~~~~~~
6767

6868
`Recursion <https://help.semmle.com/QL/ql-handbook/recursion.html>`__ is about self-referencing definitions.
6969
It can be extremely powerful as long as it is used appropriately.
7070
On the whole, you should try to make recursive predicates as simple as possible.
71-
That is, you should define a **base case** that allows the predicate to *bottom out*, along with a single **recursive call**::
71+
That is, you should define a *base case* that allows the predicate to *bottom out*, along with a single *recursive call*::
7272

7373
int depth(Stmt s) {
7474
exists(Callable c | c.getBody() = s | result = 0) // base case

0 commit comments

Comments
 (0)