If I have those queries:

   - SELECT FROM Chunk WHERE begin > 0 AND end < 1000
   - SELECT FROM Chunk ODER BY begin

Do you suggest me a composite index ON Chunk(begin, end) or two indexes ON
Chunk(begin) and ON Chunk(end)?

Thank you,
   Riccardo


2014-02-17 12:04 GMT+01:00 Andrey Lomakin <[email protected]>:

> Hi Riccardo,
> Do not think that last strategy will be more efficient, your complexity in
> last case can be huge, but index request always has logarithmic complexity
> multiplied by amount of ORs.
>
>
>
>
>
>
> On Mon, Feb 17, 2014 at 10:19 AM, Riccardo Tasso <[email protected]
> > wrote:
>
>> Hi all,
>>    I have to represent a domain with OrientDB and I'm thinking about two
>> ways. The domain is as follows:
>>
>>    - a very big text is fragmented in Chunks of equal size (let's say 5
>>    characters for each Chunk)
>>    - Chunk is a class with <begin, end, text> attributes
>>
>> For example, the text: "Hello World!" becomes:
>>
>>    1. 0, 5, "Hello"
>>    2. 5, 10, " Worl"
>>    3. 10, 12, "d!"
>>
>> The user can ask for an arbitrary span of text, for example: getText(6,
>> 11) should return "World".
>>
>> Currently I collect all the interesting chunks with the following query:
>> SELECT begin, end, text
>> FROM Chunk
>> WHERE
>>    (begin <= 6 AND end >= 6) OR // the first interesting chunk
>>    (begin >= 6 AND end <= 11) OR // all the other chunks
>>    (begin <= 11 AND end >= 11) // the last interesting chunk
>> ORDER BY begin
>> Obviously such a query can be optimized with an index over begin, end
>> fields.
>>
>> I was thinking about another option, which is to link each Chunk with its
>> follower, for example: 1. -- next --> 2. -- next --> 3.
>> In this case the previous query could be implemented as a traversal:
>> TRAVERSE all() FROM (SELECT FROM Chunk WHERE begin <= 6 AND end > 6)WHILE
>> end <= 11
>>
>> Considering that each Chunk has only one follower, do you think this
>> strategy would be more efficient?
>>
>> Cheers,
>>    Riccardo
>>
>>  --
>>
>> ---
>> 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/groups/opt_out.
>>
>
>
>
> --
> Best regards,
> Andrey Lomakin.
>
> Orient Technologies
> the Company behind OrientDB
>
>  --
>
> ---
> 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/groups/opt_out.
>

-- 

--- 
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/groups/opt_out.

Reply via email to