[Mulgara-dev] More TQL questions - performance issues with MINUS

Paul Gearon gearon at ieee.org
Tue Jul 28 17:02:21 UTC 2009


This should work OK, but it's doing much more work than it needs to.

You're asking for people ($p) who hold an account ($id) that is in a
particular state, and you want to see their email address.

Then you say you want to remove people who have a display name, a
given name and a surname. However, you've also said that the people
you want to exclude must also hold an account (that is the same as the
one identified), the account must be in a particular state (the same
state already identified), and the person must have an email (again,
the same as already identified). This is creating a lot of
unnecessary work.

You're entitled to find more people on the RHS of the minus than exist
on the LHS, so you don't need to constrain it so tightly. The account
is not related to the foaf properties of the person, so you can remove
the account details from the RHS (this means that the RHS will
identify all people with FOAF details, including those without
accounts, but that OK, since there's no effect if you "remove" people
who aren't there). You also don't need to worry about specifying the
email, because if they don't have one, then they won't appear on the
LHS to be removed anyway.

So change the query to this:

select $id $accstate $email
from <local:///topazproject#profiles>
where $id <rdf:type> <http://xmlns.com/foaf/0.1/OnlineAccount> in
<local:///topazproject#users>
  and $p <http://xmlns.com/foaf/0.1/holdsAccount> $id
  and $p <http://xmlns.com/foaf/0.1/mbox> $email
  and $id <topaz:accountState> $accstate in <local:///topazproject#users>
  minus (
    $p <topaz:displayName> $username
    and $p <http://xmlns.com/foaf/0.1/givenname> $firstname
    and $p <http://xmlns.com/foaf/0.1/surname> $lastname
  );

Read out aloud, this says (slightly re-ordered):
"Show the account IDs, the state of the account, and the email address
of everyone with an account, except for those with a display name a
first name, and a last name"

Regards,
Paul

On Tue, Jul 28, 2009 at 11:36 AM, Dragisa
Krsmanovic<dkrsmanovic at plos.org> wrote:
> I am trying to find difference between result of two queries using
> MINUS. This query takes long time (haven't waited for it to finish yet).
>
> select $id $accstate $email
> from <local:///topazproject#profiles>
> where $id <rdf:type> <http://xmlns.com/foaf/0.1/OnlineAccount> in
> <local:///topazproject#users>
> and $p <http://xmlns.com/foaf/0.1/holdsAccount> $id
> and $p <http://xmlns.com/foaf/0.1/mbox> $email
> and $id <topaz:accountState> $accstate in <local:///topazproject#users>
> minus (
> $id <rdf:type> <http://xmlns.com/foaf/0.1/OnlineAccount> in
> <local:///topazproject#users>
> and $p <http://xmlns.com/foaf/0.1/holdsAccount> $id
> and $p <topaz:displayName> $username
> and $p <http://xmlns.com/foaf/0.1/mbox> $email
> and $p <http://xmlns.com/foaf/0.1/givenname> $firstname
> and $p <http://xmlns.com/foaf/0.1/surname> $lastname
> and $id <topaz:accountState> $accstate in
> <local:///topazproject#users>);
>
> Separately, left and right side of MINUS return results in less than
> 30sec (~50k and ~20k rows). Am I using MINUS correctly here ?
>
> Thanks,
> Dragisa
>
> _______________________________________________
> Mulgara-dev mailing list
> Mulgara-dev at mulgara.org
> http://mulgara.org/mailman/listinfo/mulgara-dev
>



More information about the Mulgara-dev mailing list