PyCharm debugger runs extra queries to gather data for Variable Watcher?

Answered

We are tracing the SQL queries on Django's backend logging similar to this online example, with the snippet in the file `settings.py`.

However, with the same source code and testing environment, we noticed different system behaviours with or without a breakpoint near a QuerySet object.

Tentatively, we suspect the breakpoint triggered IDE's debugger sending extra SQL queries to gather data for the Variable Watcher because, without the breakpoint, the program runs straight through, and the extra SQL queries do not appear in logging.

We are analyzing a system performance issue, and the backend logging indicates the algorithm's computing complexity. So, we want to avoid the extra queries and reduce the noise.

So, we wonder if there is a way to disable the debugger's data fetching explicitly.

The code snippet in the file `settings.py`:

  1. LOGGING = {  
  2.     'version': 1,  
  3.     'filters': {  
  4.         'require_debug_true': {  
  5.             '()': 'django.utils.log.RequireDebugTrue',  
  6.         }  
  7.     },  
  8.     'handlers': {  
  9.         'console': {  
  10.             'level': 'DEBUG',  
  11.             'filters': ['require_debug_true'],  
  12.             'class': 'logging.StreamHandler',  
  13.         }  
  14.     },  
  15.     'loggers': {  
  16.         'django.db.backends': {  
  17.             'level': 'DEBUG',  
  18.             'handlers': ['console'],  
  19.         }  
  20.     }  
  21. }  

 

 

2 comments
Comment actions Permalink

Does changing the Variables Loading Policy to On demand in the debugger window help?

1
Comment actions Permalink

Thank you for the help, and setting "Variables Loading Policy" to "On demand" resolved the issue.

0

Please sign in to leave a comment.