Sure! For example, let me give you more details about my structure. Each user has an "Account" vertex. Each Account vertex is linked to one "Social Profile" vertex. And from that "Social Profile" vertex we have all the edges to the user's friends. Each "Account" is identified by a unique "accountId", which is a STRING (it's actually a UUID string). "accountId" has a UNIQUE_HASH_INDEX.
[Account] --> (1 to 1) --> [Social Profile] --> (1 to many) friends --> [Social Profile] [Account] --> (1 to 1) --> [Public Profile] When the page loads, I'm loading the user's Social Profile, and then loading each friend's Public Profile details. Currently this seems to take almost 100ms although my account only has 6 friends! Here's how I create a connection to the database. First I create a single connection pool: this.graphFactory = new OrientGraphFactory( parsedConfig.connString, parsedConfig.username, parsedConfig.password) .setupPool( parsedConfig.minConnPoolSize, parsedConfig.maxConnPoolSize); And then I create a transaction: this.oTx = this.graphFactory.getTx(); Here's how I get the user's Account vertex: // Get Account vertex return (OrientVertex)db.getVertices( "Account.accountId", accountId) .iterator().next(); And then I traverse to the linked Social Profile vertex (via edge) // Get linked Social Profile vertex return (OrientVertex)accountVtx.getVertices( Direction.OUT, EDGE_ACCOUNT_SOCIAL_PROFILE) .iterator().next(); And finally I get all the friends' account IDs and friendship status. // Retrieve account IDs of all friends, determine friendship status for (Direction direction : new Direction[]{ Direction.IN, Direction.OUT }) { // Retrieve the iterator for the current direction Iterator<Edge> friendshipEdgeIterator = vtx.getEdges( direction, EDGE_SOCIAL_PROFILE_FRIENDSHIP) .iterator(); // For each result... while (friendshipEdgeIterator.hasNext()) { Edge friendshipEdge = friendshipEdgeIterator.next(); // Retrieve other social profile vertex Vertex otherSocialProfileVtx = friendshipEdge.getVertex( (direction == Direction.IN ? Direction.OUT : Direction.IN )); // Retrieve other account vertex Vertex otherAccountVtx = this.traverseVertex( otherSocialProfileVtx, Direction.IN, OrientDbPersistence.EDGE_ACCOUNT_SOCIAL_PROFILE); String otherAccountId = otherAccountVtx.getProperty(PROP_ACCOUNT_ID); // Is the friendship confirmed? if (friendshipEdge.getPropertyKeys().contains(PROP_CONFIRMED) && (boolean)friendshipEdge.getProperty(PROP_CONFIRMED)) { // Yes -- confirmed friendship. socialProfile.getFriendshipMap() .addConfirmedFriendship(otherAccountId); } else { // No -- pending friendship. if (direction == Direction.IN) { // Pending incoming friendship socialProfile.getFriendshipMap() .addPendingIncomingFriendship(otherAccountId); } else { // Pending outgoing friendship socialProfile.getFriendshipMap() .addPendingOutgoingFriendship(otherAccountId); } } } } And finally, once I have all these IDs, I load each friend's public profile. I get their Account vertex (same way as above, by accountId key), and traverse to their Public Profile vertex. // Get linked Public Profile vertex return (OrientVertex)accountVtx.getVertices( Direction.OUT, EDGE_ACCOUNT_PUBLIC_PROFILE) .iterator().next(); Again, this seems to be taking way too long for a few lookups by key and edge traversals. This is compounded by the fact that my website is a single-page application (SPA), so I'm essentially loading all the user's friends and his/her channels in one go. All the 100ms delays add up to many seconds, etc. Can you find anything wrong with my implementation? On Saturday, April 30, 2016 at 1:48:09 PM UTC+8, scott molinari wrote: > > Can you give us some code examples of queries that are slow? > > Scott > -- --- 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 orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.