Simple select by RID

2,755 views
Skip to first unread message

Greg T

unread,
Feb 13, 2012, 9:14:04 AM2/13/12
to OrientDB
Hi
I am new to OrientDb and already impressed (missing only .NET
integration)
But I am having problem with something very simple: what is the syntax
for selecting by RID, eg:

SELECT * FROM ORole WHERE RID = #3:0

I've tried every possible combination but have no idea how to pass the
RID (single and multiple)

Thanks

Alessandro Nadalin

unread,
Feb 13, 2012, 9:18:38 AM2/13/12
to orient-...@googlegroups.com
On Mon, Feb 13, 2012 at 3:14 PM, Greg T <gtrz...@gmail.com> wrote:
> Hi
> I am new to OrientDb and already impressed (missing only .NET
> integration)
> But I am having problem with something very simple: what is the syntax
> for selecting by RID, eg:
>
> SELECT * FROM ORole WHERE RID = #3:0

SELECT * FROM #3:0

or

SELECT * FROM ORole WHERE @rid = #3:0


>
> I've tried every possible combination but have no idea how to pass the
> RID (single and multiple)
>
> Thanks

--
Nadalin Alessandro
www.odino.org
www.twitter.com/_odino_

Greg T

unread,
Feb 13, 2012, 9:48:16 AM2/13/12
to OrientDB
Thanks Alessandro, that's exactly what I needed!

The multiple (in list) also works nicely now with "@rid":
SELECT * FROM ORole WHERE @rid in [#3:0,#3:1]


On Feb 13, 2:18 pm, Alessandro Nadalin <alessandro.nada...@gmail.com>
wrote:

Luca Garulli

unread,
Feb 13, 2012, 10:19:12 AM2/13/12
to orient-...@googlegroups.com
Alessandro is right,
just note that this

SELECT FROM  [#3:0,#3:1]

it's much faster than

SELECT * FROM ORole WHERE @rid in [#3:0,#3:1] 

Lvc@

Elad

unread,
Feb 9, 2016, 8:21:14 AM2/9/16
to OrientDB
Hi Luca,

Can you please explain why the first one is much faster?
Intuitive it looks the same, and it might be a trap for developers ( like us ;) )

scott molinari

unread,
Feb 9, 2016, 9:06:30 AM2/9/16
to orient-...@googlegroups.com
I'd say it is because the rids are physical locations, so it is easy for ODB to just go directly to the records and get them with the FROM [#rid, #rid] clause. Whereas, the WHERE clause is a filter, which means there needs to be a separation of the records from a complete list (scan) of all the records. One would think the system would be smart enough to reduce the WHERE/IN when using @rid to the simpler SELECT/FROM form, but I am sure there are technical reasons why this isn't directly possible.  

Scott 

Luca Garulli

unread,
Feb 9, 2016, 10:59:28 AM2/9/16
to OrientDB
Hi guys,

OrientDB SQL engine should be smart enough on this simple query to rewrite it with the optimized version, but if you start adding conditions, parenthesis, etc. it couldn't be that smart.

Best Regards,

Luca Garulli
Founder & CEO


On 9 February 2016 at 15:06, scott molinari <scottam...@googlemail.com> wrote:
I'd say it is because the rids are physical locations, so it is easy for ODB to just go directly to the records and get them with the FROM clause. Whereas, the WHERE clause is a filter, which means there needs to be a separation of the records from a complete list (scan) of all the records. One would think the system would be smart enough to reduce the WHERE/IN when using @rid to the simple SELECT/FROM form, but I am sure there are technical reasons why this isn't directly possible.  

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-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

scott molinari

unread,
Feb 10, 2016, 5:28:33 AM2/10/16
to OrientDB
Thanks Luca. 

Was my assumption about the difference between the two queries actually correct? 

And please don't take my comment as a slant or anything close. I love ODB and fight for it, where and when I can. You know that. :-)

Scott
Reply all
Reply to author
Forward
0 new messages