Pycharm step through
With the following code:
oDth = Dth.objects.filter(dth_field_label__istartswith=tSearch, dth_languange='1')
for j in oDth:
tResult = tResult+ j.dth_ref + '</br>'
When debugging and stepping through we get 3 hits to the database:
2011-11-03 09:50:48 MST: LOG: statement: SELECT "dth"."dth_key", "dth"."dth_ref", "dth"."dth_help_text", "dth"."dth_languange", "dth"."dth_field_label", "dth"."dth_sid", "dth"."dth_type" FROM "dth" WHERE ("dth"."dth_languange" = 1 AND UPPER("dth"."dth_field_label"::text) LIKE UPPER('hi%') ) LIMIT 21
2011-11-03 09:50:49 MST: LOG: statement: SELECT "dth"."dth_key", "dth"."dth_ref", "dth"."dth_help_text", "dth"."dth_languange", "dth"."dth_field_label", "dth"."dth_sid", "dth"."dth_type" FROM "dth" WHERE ("dth"."dth_languange" = 1 AND UPPER("dth"."dth_field_label"::text) LIKE UPPER('hi%') ) LIMIT 21
2011-11-03 09:50:49 MST: LOG: statement: SELECT "dth"."dth_key", "dth"."dth_ref", "dth"."dth_help_text", "dth"."dth_languange", "dth"."dth_field_label", "dth"."dth_sid", "dth"."dth_type" FROM "dth" WHERE ("dth"."dth_languange" = 1 AND UPPER("dth"."dth_field_label"::text) LIKE UPPER('hi%') )
But if we let it go at once we just get one:
2011-11-03 09:51:40 MST: LOG: statement: SELECT "dth"."dth_key", "dth"."dth_ref", "dth"."dth_help_text", "dth"."dth_languange", "dth"."dth_field_label", "dth"."dth_sid", "dth"."dth_type" FROM "dth" WHERE ("dth"."dth_languange" = 1 AND UPPER("dth"."dth_field_label"::text) LIKE UPPER('hi%') )
Can someone help us figure out why the hits to the database are not consistent while running the same code?
Please sign in to leave a comment.
Hello Juan,
PyCharm evaluates variables and properties of objects for displaying the
Watches view. It's likely that the extra database calls stem from this evaluation.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
The answer make sense and by testing we confirm what was said. It was helpful not to freak out too