bradmontgomery / django-querycount

Middleware that Prints the number of DB queries to the runserver console.
MIT License
392 stars 33 forks source link

"Repeated 1 times" #24

Open peterbe opened 5 years ago

peterbe commented 5 years ago

It prints this:

web_1            | Repeated 1 times.
web_1            | SELECT `django_session`.`session_key`,
web_1            | `django_session`.`session_data`, `django_session`.`expire_date` FROM
web_1            | `django_session` WHERE (`django_session`.`session_key` =
web_1            | 'cln2uzh2qk21qqb6sfg7nvsrqwg2crbm' AND `django_session`.`expire_date`
web_1            | > '2019-09-20 12:53:39.352699')

But I think it actually ever happens 1 time for that request. So, the logic for this inclusion should be something like [query for queries if query.times > 1].

peterbe commented 5 years ago

Also, fixing this would be we don't need to correct the excessive plural s on times.

peterbe commented 5 years ago

Perhaps here it could instead do:

    def _duplicate_queries(self, output):
        """Appends the most common duplicate queries to the given output."""
        if QC_SETTINGS['DISPLAY_DUPLICATES']:
            for query, count in self.queries.most_common(QC_SETTINGS['DISPLAY_DUPLICATES']):
                if count <= 1:
                    continue
                lines = ['\nRepeated {0} times.'.format(count)]
          ...
morlandi commented 4 years ago

Maybe "Executed" would be more appropriate than "Repeated", but please note that sometimes it is useful to dump all queries. With the current implementation, this can easily be achieved by setting a big value for the DISPLAY_DUPLICATES setting

kevinrenskers commented 3 years ago

I've just included this project into my Django app, and I was extremely surprised when I saw a whole bunch of queries show up saying they were repeated 1 time, when really the total count is 1. "Repeated 1 time" means that the query was executed twice, right? So maybe it's just a matter of improving the wording that's used, so don't say "repeated" but "executed" or something.

bradmontgomery commented 1 year ago

Agreed that there's some work to do here. I've added this to the next release milestone & hope to sprint on it over the next few weeks.