Generally, databases can make use of what indexes exist. It'll have to
do more work to traverse this index, than it would to traverse ones on
x, y, and z alone, or with x,y,z alone. And if you want it in sorted
order, it'll have to do a sort operation of some type, as the
traversal will be only partially ordered.

But, as you observed, it'll be faster than if the primary key did not
mention x,y,z!

And it costs time (at insert time) and space to maintain an index, so
whether or not to include a separate index for x,y,z or indexes for x,
y, and z is a pragmatic decision. It depends on your usage patterns.
Many inserts, unlikely searches -- you're probably better off without
an index, so long as those unlikely searches don't violate a hard
performance constraint (either on their own, or on their impact on
overall performance).

On Jan 15, 1:34 am, Menion <[email protected]> wrote:
> that's not true. As I wrote, I cannot change structure of database,
> but i did my own test and indexes as are
>
> PRIMARY KEY (x, y, z, s)
>
> are almost twice faster for query on single row by x, y, z values (for
> reading and mainly for writing), then classic ID
>
> INTEGER PRIMARY KEY
>
> I'm not database expert, but this are measured values!
>
> and finally, for me, in this case, speed is not primary! Problem is
> that I cannot use database bigger then 2GB.
> But, problem is solved as I wrote in my previous post.
>
> Thanks all very much for you time and if anyone of you is Locus user -
> Sorry, but more then 2GB bigger maps, aren't allowed now :)
>
> On Jan 15, 8:55 am, Frank Weiss <[email protected]> wrote:
>
>
>
>
>
>
>
> > As I recall, there were no indexes on the table. Without indexes I would
> > expect most every query on a very table to be very slow.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to