eevee/spline-pokedex — Issue #9: More eagerloading
Author: encukou
Created: 2012-01-26 21:51:42+00:00
State: open
Labels: feature

**Reported by [Eevee](http://github.com/eevee) on 2010/04/13 20:32:30 +0000 · Migrated from [Redmine issue 148](http://bugs.veekun.com/issues/148)**

---

Some eagerloading has been done already, which is fantastic. However, there are some possible improvements:

* When reasonable, a many-to-one should be preloaded *by default*. For example, there’s no reason a PokemonStat wouldn’t want to eagerload the corresponding Stat row. (Be sure to use lazy=‘subquery’ for one-to-many, to avoid awful unnecessary cross-joining.)
\* Use `subqueryload()` where there are currently shenanigans to avoid cross-joins; it automatically fires off the second query. The trickery in Pokémon search needs this, too.
\* Relations can be told to always innerjoin, which is apparently much faster in Postgres (and maybe others). Do this where it’s appropriate.

Less important now that there’s a page cache, but would be nice.

Redmine metadata:
Updated on: 2010/10/08 08:01:01 +0000
Start date: 2010/04/13

---

**Comment by [magical](http://github.com/magical) from 2010/05/23 18:13:41 +0000**

> By tricking the unique object cache, it’s possible to do multiple one-to-many eagerloads in separate steps. Just query for the same objects again and eagerload a different set of tables.

This is pretty much what the recently-added `subqueryload` does.

---

**Comment by [Eevee](http://github.com/eevee) from 2010/05/23 18:31:19 +0000**

Updated the desc to match the cool stuff 0.6 does.

---

**Comment by [Eevee](http://github.com/eevee) from 2010/10/08 08:01:01 +0000**

Assignee ⇨ —