Appengine backreferences - need a composite index?

I have a query that is running quite recently:

"The built-in indices are not efficient enough for this query and your data. Please add a composite index for this query."

      

I have checked the line this exception is being thrown on and the issue request is as follows:

count = self.vote_set.filter("direction =", 1).count()

      

This is literally a single filter operation using the appengine's built-in backlinks. I have no idea how to optimize this query ... anyone have any suggestions? I tried to add this index:

 - kind: Vote
   properties:
   - name: direction
     direction: desc

 - kind: Vote
   properties:
   - name: direction

      

And I got a message (obviously) saying this is an unnecessary index.

Thanks for your help in advance.

+2


source to share


2 answers


If you run all relevant queries in your local SDK, it should generate all required indexes (in index.yaml

), and the recommended policy is not to edit index.yaml

yourself, but rather let the local SDK do it for you. If the SDK does not generate all the required indexes, as you of course use all relevant code paths in local testing !, you should open a bug for it in the App Engine tracker here (after checking that there is no bug report already for this issue).



+3


source


In fact, backlinks are just building the query filtered by the referenced property, so by adding another filter, you have a query with 2 filters.

Your compsite index will look something like this:



- kind: Vote
  properties:
  - name: your_reference_property_name
  - name: direction
    direction: desc

      

+3


source







All Articles