harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
36 stars 30 forks source link

ContentNode.resource_type should be indexed #1934

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

It's common to filter on this string field (which is effectively an enum of a known set) but it's not indexed, so this operation can be very slow when run across casebooks.

This comes up in the Django admin especially: any time contentnode.resource_type is referenced as something to filter on, Django will automatically want to do select distinct resource_type from content_node and then need to iterate over 1,001,118 rows to retrieve 5 or so known values. This particular case can be mitigated by a custom filter.

Note that like #1767, adding the index now will probably take quite some time and might need to be done carefully as part of a migration.