Commit 6de4ee54 authored by Hanno Schlichting's avatar Hanno Schlichting

Extend the query report with information about the resultset length

parent 3578c5d2
...@@ -520,7 +520,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -520,7 +520,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
r = _apply_index(query, rs) r = _apply_index(query, rs)
else: else:
r = _apply_index(query) r = _apply_index(query)
cr.split(i)
if r is not None: if r is not None:
r, u = r r, u = r
...@@ -529,10 +528,14 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -529,10 +528,14 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# once we don't need to support the "return everything" case # once we don't need to support the "return everything" case
# anymore # anymore
if r is not None and not r: if r is not None and not r:
cr.split(i, 0)
return LazyCat([]) return LazyCat([])
cr.split(i, len(r))
w, rs = weightedIntersection(rs, r) w, rs = weightedIntersection(rs, r)
if not rs: if not rs:
break break
else:
cr.split(i, 0)
cr.stop() cr.stop()
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="list-nav"> <div class="list-nav">
Recent duration&nbsp;[ms] Recent
</div> </div>
</td> </td>
</tr> </tr>
...@@ -53,11 +53,12 @@ ...@@ -53,11 +53,12 @@
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="list-item"> <div class="list-item">
<dtml-var expr="'%3.2f' % last['duration']"> <dtml-var expr="'%3.2f' % last['duration']">ms
[<dtml-in expr="last['details']" sort mapping> [<dtml-in expr="last['details']" sort mapping>
&dtml-id;:&nbsp;<dtml-var expr="'%3.2f' % duration"> &dtml-id;:
<dtml-var expr="'%3.2f' % duration">ms /
&dtml-length; objects,
</dtml-in>] </dtml-in>]
</div> </div>
</td> </td>
</tr> </tr>
......
...@@ -48,7 +48,7 @@ def determine_value_indexes(indexes): ...@@ -48,7 +48,7 @@ def determine_value_indexes(indexes):
for name, index in indexes.items(): for name, index in indexes.items():
if IUniqueValueIndex.providedBy(index): if IUniqueValueIndex.providedBy(index):
values = index.uniqueValues() values = index.uniqueValues()
if values and len(values) < MAX_DISTINCT_VALUES: if values and len(list(values)) < MAX_DISTINCT_VALUES:
# Only consider indexes which actually return a number # Only consider indexes which actually return a number
# greater than zero # greater than zero
new_value_indexes.add(name) new_value_indexes.add(name)
...@@ -117,7 +117,7 @@ class StopWatch(object): ...@@ -117,7 +117,7 @@ class StopWatch(object):
self.init() self.init()
self.start_time = time.time() self.start_time = time.time()
def split(self, label): def split(self, label, result_length=None):
current = time.time() current = time.time()
start_time, stop_time = self.interim.get(label, (None, None)) start_time, stop_time = self.interim.get(label, (None, None))
...@@ -126,7 +126,7 @@ class StopWatch(object): ...@@ -126,7 +126,7 @@ class StopWatch(object):
return return
self.interim[label] = (start_time, current) self.interim[label] = (start_time, current)
self.res.append((label, current - start_time)) self.res.append((label, current - start_time, result_length))
def stop(self): def stop(self):
self.end_time = time.time() self.end_time = time.time()
...@@ -210,6 +210,7 @@ class CatalogReport(StopWatch): ...@@ -210,6 +210,7 @@ class CatalogReport(StopWatch):
<duration of single indexes> := [{'id': <index_name1>, <duration of single indexes> := [{'id': <index_name1>,
'duration': <duration>, 'duration': <duration>,
'length': <resultset length>,
}, },
... ...
] ]
...@@ -224,7 +225,8 @@ class CatalogReport(StopWatch): ...@@ -224,7 +225,8 @@ class CatalogReport(StopWatch):
'duration': v[1] * 1000, 'duration': v[1] * 1000,
'last': {'duration': v[2][0] * 1000, 'last': {'duration': v[2][0] * 1000,
'details': [dict(id=i[0], 'details': [dict(id=i[0],
duration=i[1]*1000) duration=i[1]*1000,
length=i[2])
for i in v[2][1]], for i in v[2][1]],
}, },
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment