# Make it fast to answer lots of similar Entity questions

I've done a EntityPrefetch[EntityClass["ZIPCode"]] but I'm not at all sure it's helped.

I want to get every zip-code's address. The obvious way to do this is:

Entity["ZIPCode", IntegerString[#, 10, 5]]["ActualAddress"]& /@ Range[0, 99999]


But this is incredibly slow, and some Googling suggests that this is doing a network call every time.

Can I somehow get this data all at once?

### INTRO

I recommend taking a look at the following free videos at Wolfram-U:

Yes, it is a rule of thumb to make a single call for multiple entities instead of making a call for each. Mapping /@ violates the rule. I would do something like the following.

You can always get all entities via EntityList, no need to complicate things via /@ and IntegerString or other means of generating them -- simply get all relevant entities with a single call.

zips = EntityList["ZIPCode"];
Length[zips]


41702

Then make a single call for a property by placing all the entities inside EntityValue:

address = EntityValue[zips, "ActualAddress"]; // AbsoluteTiming


{96.8362, Null}

This will take some time but it will be much faster than mapping with a call per entity. I don't think you can win with the EntityPrefetch much in this case, because you need to get these data from servers anyways, and you cannot cheat the minimal required time of data download.

You can also get the property directly with another form of call:

address = EntityValue["ZIPCode", "ActualAddress"];


but the timings will be similar as I explained above. Also note, as you can see I am suppressing everywhere output display with ;. When you deal with a lot of entities you can save some small extra time on avoiding their rendering in the notebook.

Here is how the samples look:

In[]:= RandomSample[address,5]//Column
Out[]= {Commented[Bell, FL 32619,None]}
{Commented[Texarkana, TX 75503,None]}
{Commented[De Soto, WI 54624,None]}
{Commented[Springfield, IL 62739,None]}
{Commented[Bessemer, PA 16112,None]}