SQLObjectResultSet.__nonzero__() implementation does not strip result ordering.

Bug #246200 reported by Celso Providelo on 2008-07-07
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Undecided
Unassigned
Storm
Low
Jamu Kakar

Bug Description

The current implementation of SelectResultSet.__nonzero__ (used in bool(result_set)) is inefficient because it doesn't remove the ordering bits.

A lot of time is spent ordering the result set that will not affect the result of the operation, for instance bool(IArchive.getPublishedSources()).

The original implementation of __nonzero__ in SQLObject does remove the ordering part correctly and this is the fastest alternative, it's faster then count(), any() or first();

Related branches

Celso Providelo (cprov) wrote :

See query #19 on OOPS-919EB43

While that query is taking quite a while, it isn't clear that removing the ORDER BY would stop that page from timing out. There is a 19 second gap between statement #32 and the one where the TimeoutError was raised.

That should be investigated as well as fixing Storm to remove the ORDER BY clause.

Celso Providelo (cprov) wrote :

Thanks for replying, James.

Yes, of course, there are other serious issues that needs to be sorted in order to eliminate the timeouts we are experiencing.

The initial report mentions the inefficient __nonzero__ implementation, specifically, because it surely has implications that go beyond that page.

James Henstridge (jamesh) wrote :

We should definitely improve the SQLObjectResultSet.__nonzero__ implementation.

That said, if __nonzero__() returns True, do you go ahead and repeat the full query? If so, then it'd be better to restructure your page to just go ahead and do the query once and handle zero rows case appropriately.

There is no __nonzero__() in the native Storm ResultSet class as its use usually involves repeating queries for no good reason.

Celso Providelo (cprov) wrote :

If the __nonzero__ is True we issue a similar query, but at that time its restricted to the package-search form (default) values.

We issue that query because it was supposed to be the simplest/quickest way to figure out when a PPA is inactive (zero source publications) and then easily modify the layout to avoid issues other empty or pointless queries. However, I admit it's a little cumbersome for active PPAs.

Curtis Hovey (sinzui) on 2009-10-09
tags: added: tech-debt
Changed in soyuz:
status: New → Invalid
Jamu Kakar (jkakar) on 2010-07-22
Changed in storm:
milestone: none → 0.17
assignee: nobody → Jamu Kakar (jkakar)
importance: Undecided → Low
status: New → In Progress
Jamu Kakar (jkakar) on 2010-07-22
Changed in storm:
status: In Progress → Fix Committed
Jamu Kakar (jkakar) on 2010-08-13
Changed in storm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers