Attempting some database indexing magic