What is your goal? If you have a unique key that does not contain the affinity key, and the primary key contains both fields, you can create an index on that unique key, so that you could have fast node local lookups using SqlQuery(). If you want to find an object only by that original unique key from a random node, then you must either search all nodes, or not append an affinity key. So if Ignite had done what you suggested, the cost of a single lookup by primary key would increase with node count, which would be at odds with it being declared a primary key.
On Tue, Mar 20, 2018 at 12:57 PM, Dmitriy Setrakyan <[email protected]> wrote: > > > On Tue, Mar 20, 2018 at 2:09 PM, Vladimir Ozerov <[email protected]> > wrote: > >> Internally Ignite is key-value storage. It use key to derive partition it >> belongs to. By default the whole key is used. Alternatively you can use >> @AffinityKey annotation in cache API or "affinityKey" option in CREATE >> TABLE to specify *part of the key* to be used for affinity calculation. >> Affinity column cannot belong to value because in this case single >> key-value pair could migrate between nodes during updates and >> IgniteCache.get(K) will not be able to locate the key in cluster. >> > > Vladimir, while it makes sense that the key must be composed of the ID and > Affinity Key, I still do not understand why we require that user declares > them both as PRIMARY KEY. Why do you need to enforce that explicitly? In my > view you can do it automatically, if you see that the table has both, > PRIMARY KEY and AFFINITY KEY declared. > > Disclaimer The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful. This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. Providing a safer and more useful place for your human generated data. Specializing in; Security, archiving and compliance. To find out more visit the Mimecast website.
