Remove tag problem and the impossible number of queries

They say that the best way to solve the problem is to approach it several times and from different angles. This gives you more info about the issue, and it allows you to try new ways to make the software (in this case) work. This also reveals underlying aspects of the matter aka symptoms it presents when approached from an unexpected angle. One of the approaches showed the issue with queries and inability of the software to create enough queries to fix the problem.

Quantity as the solution for the query issue

One of our developers decided to try and approach the problem with a constant stream of queries. This was a promising attempt and here is a transcript of their research.

“There may be some indirect way to do this in a constant number of queries, but I’m pretty sure doing everything in one query would be impossible. Since tagging works on generic objects, I can’t know at query time what tables to perform the join on. Short of having all model objects extend from a base table containing a project column (which would bring problems of its own), I don’t see a way around it (but I’d like to be proven wrong). Every method I’ve come up with runs into the n+1 queries problem – the only thing that changes is what ‘n’ stands for (the number of tags, the number of model objects that use tags, etc.)”

As you can see this approach has its downside as well. But the conclusion is that the possibility of one single query is non-existent. But we can conclude that this method has a higher chance to succeed than single-query approach as it is impossible. The smartest way to proceed is to try and, through experimentation, come up with an exact number of queries that would do the trick.

The project and the necessity of collaboration

resolvedThe quest for the solution wasn’t reserved for one company, as the decision came to connect with others and find the answer to this problem. However, the efforts of a massive brainstorming effort also hit some obstacles before finally succeeding. You can read more in the following transcript.

“I’ve been discussing with my undergraduate chair whether or not I can do UCOSP a second time. Right now, the answer looks like no. I need to come up with course descriptions for this past term and the upcoming one and demonstrate that the ‘learning outcomes’ of the two would be sufficiently different to justify getting credits twice. Another tack I could try is a demonstration that enough material is covered to defend UCOSP as a two term course. Even in such a case, I would have to demonstrate that the second term would be more than the first one repeated”.