removing query attributes from gloda - which are allowed now? (refer to Jonathan's anouncement of 2011)

Andrew Sutherland asutherland at asutherland.org
Tue Mar 7 05:03:48 UTC 2017


On Mon, Mar 6, 2017, at 05:49 PM, opto at optosolar.com wrote:
> That post was an announcement to remove some of the possible queries for
> optimisation of database. Was this done? What can be queried now?

Yes, the bug it referenced
https://bugzilla.mozilla.org/show_bug.cgi?id=678405 landed.  The diff at
https://hg.mozilla.org/comm-central/rev/87b0510db268 is the most
authoritative thing to check.

The net result is that attributes for which one of the following are
true are indexed:
- `canQuery` is true
- `canQuery` is not specified and `facet` is truthy.

As a result, `starred` can be queried on, but`read` cannot be queried
on.

As discussed in the bug you should be able to manually filter the result
of your query using JS code.  For the `read` case, the obvious JS logic
for this is probably easiest.  If you want to perform more advanced
filtering, either the faceting logic in
https://dxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/facet.js
can be used or a dynamic query can be constructed and its test()
function used.  (Note that canQuery both disables the in-memory helpers
as well as preventing database items from being created.  If there's
something complex you want, it might be good to contribute a patch to
add `canQuery: "memory"` to whatever it is.

Note that as an extension you can also add custom attributes that will
get added to the database. 

> Trying to get starred queries (query.starred(true)) always gives item
> count 0.

Are you waiting for the async onQueryComplete event?  In my database I
see the expected attributes are in the database and the counts seem to
check out. 

> So what is the current status? What can be queried, what not?  Or is my
> query malformed?

Please check out the defineAttribute calls against the rules I specified
above:
https://dxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/fundattr.js#80
https://dxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/explattr.js#65
 
The following DXR query also helps sanity check that those 2 files cover
all the message attributes:
https://dxr.mozilla.org/comm-central/search?q=%2Bref%3A%22Gloda%23defineAttribute%22

Andrew


More information about the tb-planning mailing list