Debian Codegraph @

docs/record-queries.rst

raw
1 Recording Query Information
2 ===========================
3
4 .. warning::
5 This feature is intended for debugging only.
6
7 Flask-SQLAlchemy can record some information about every query that executes during a
8 request. This information can then be retrieved to aid in debugging performance. For
9 example, it can reveal that a relationship performed too many individual selects, or
10 reveal a query that took a long time.
11
12 To enable this feature, set :data:`.SQLALCHEMY_RECORD_QUERIES` to ``True`` in the Flask
13 app config. Use :func:`.get_recorded_queries` to get a list of query info objects. Each
14 object has the following attributes:
15
16 ``statement``
17 The string of SQL generated by SQLAlchemy with parameter placeholders.
18 ``parameters``
19 The parameters sent with the SQL statement.
20 ``start_time`` / ``end_time``
21 Timing info about when the query started execution and when the results where
22 returned. Accuracy and value depends on the operating system.
23 ``duration``
24 The time the query took in seconds.
25 ``location``
26 A string description of where in your application code the query was executed. This
27 may be unknown in certain cases.