0
votes

I have to make a query on an Azure table storage where I have the following setup: RowKey, PartitionKey, ThirdColumn

The RowKey is unique, and the Partitionkey corelates with ThirdColumn, meaning all third columns with the value "Y", will have the partition key "X".

I have to get all entities with partition key X, by using the ThirdColumn value. This will not be performant because Y is neither PartitionKey or RowKey.

Question is: Does it make sense to do a .FirstOrDefault() on the third column, in order to get an entity (any entity), and then do a query using the PartitionKey ? I think it would be better because then it doesn't have to search on different machines for the data.

Regards,

2
It will be and also you can think about to make third column as a partion key.Erkan Demirel

2 Answers

1
votes

Why not make the PartitionKey a combined value of X and Y? Like "MyValueofX_MyValueofY"?

Or if you don't have the value of X when you query, just duplicate the information with a different order, for example:

PK: X RK: Z Column: Y

PK: Y RK: Z Column: X

That way, you can query the record when you have X and when you have Y.

Check Designing a Scalable Partition Strategy.

0
votes

I think you can look at the articles below:

https://msdn.microsoft.com/en-us/library/azure/dd894039.aspx

and try this code to get the first 1 entity:

var query = (from entity in context.CreateQuery<Customer>("Top1Customers")
                 select entity).Take(1);

Then you can write it into a method called First()