question

Mikael B avatar image
0 Likes"
Mikael B asked Ben Wilson commented

Accessing indexed item label with querySlots()

I wonder if its possible to use indexed item labels with the querySlots command. I use this line of code to check if each zone already contains a SKU, to more evenly distribute SKUs across the zones.

  1. Array skusInZone;
  2. for (int i=1; i<=18; i++) {
  3.             int Zone = i;
  4.             Array slots = Storage.system.querySlots("WHERE zone = $2 AND slot.slotItems.length >= 1 AND slot.slotItems[1].item.SKU = $1 LIMIT 5", 0, SKU, Zone);
  5.             skusInZone.push(slots.length);
  6.         }

There are a total of 18 zones, and each zone consists of about 4000 slots, so I would like to make the query faster. zone is an indexed slot label. I would prefer to avoid painting slots with a SKU label. I have already indexed the item label SKU in the storage system. Is it possible to use the indexed item label in a querySlots() command?

FlexSim 20.0.10
querystorage systemflexsim 20.0.10indexingqueryslots
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Lars Jacobsen avatar image
0 Likes"
Lars Jacobsen answered Mikael B commented

If possible, please provide a sample model. For the storage system query to use an index, you need to specify a label directly, otherwise it is evaluated as FlexScript and will not use an index. Thus instead of writing "slot.slotItems[1].item.SKU", try just writing the label "SKU" in your query.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.