django-querycount icon indicating copy to clipboard operation
django-querycount copied to clipboard

"Repeated 1 times"

Open peterbe opened this issue 4 years ago • 5 comments

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 avatar Sep 20 '19 19:09 peterbe

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

peterbe avatar Sep 20 '19 19:09 peterbe

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)]
          ...

peterbe avatar Sep 20 '19 20:09 peterbe

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

morlandi avatar Mar 06 '20 11:03 morlandi

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.

kevinrenskers avatar Sep 11 '21 09:09 kevinrenskers

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.

bradmontgomery avatar Dec 12 '22 23:12 bradmontgomery