On 25 April 2015 at 16:41, Jean-Sebastien Lemay <
[email protected]> wrote:

> Hi there,
>

Hi Jean-Sebastien


>
> OK -- I'm a bit surprised, in a way; this is a straightforward SELECT
> statement.
>
> I decided to run another experiment. My scenario: determine which tags are
> a given user's favourite.
>
> My query in OrientDB:
> SELECT in.name AS name, COUNT(in.name) AS weight
> FROM UserUsedTag
> WHERE "john.doe" IN out.username
> AND timestamp < date()
> GROUP BY in.name
> ORDER BY weight DESC
> Query executed in 0.487 sec. Returned 2 record(s)
> soccer 5042
> baseball 4958
>

This is not the most efficient way to do that, because the index on
username wouldn't be used. With a Graph Database, you should lookup at the
stating vertex and then cross relationships. Try this:

select name, count(*) as weight
from (
  select expand( in() ) from User where username = "john.doe"
) group by name, order by weight

Assure to have an index on User.username. I'd suggest a Unique index of
type HASH_INDEX.

Lvc@

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to