Fork me on GitHub
#datomic
<
2015-06-20
>
bhagany17:06:41

It looks like one of my previous questions in this room resulted in an improvement to the REST API docs, so I'm posting again here, even though I've already figured it out. The current description of the args parameter to /api/query reads thus:

bhagany17:06:43

> args - Vector of maps of arguments to query. Each map is a database descriptor that corresponds to a database argument to query. Each descriptor must include a value for :db/alias.

bhagany17:06:09

This, however, is misleading. The items in the vector aren't always maps. For references to data sources, maps are needed, but for parameterized queries, they should just be the parameters you want bound.

bhagany17:06:13

here's an example POST body, in case that's not abundantly clear: {:q [:find (pull ?layout [*]) :in $ ?layout] :args [{:db/alias "dev/stores"} 277076930200641]}

max22:06:06

I am having trouble grokking partitions. Right now, my whole data set is in :db.part/user. The docs say to not do this in production, but I haven’t had much guidance on how to organize partitions.

max22:06:45

Should I create several? How do I know how to split things?

max22:06:08

I have paths that pass through every type of entity, which makes me think multiple partitions will be bad?

arohner22:06:42

@max partitions are just about cache locality of index segments

arohner22:06:17

things in the same partition are stored next to each other, which optimizes locality of fetching data

arohner22:06:38

I haven’t heard much guidance about using them, but I typically create a new partition for each ‘table'

max22:06:09

@arohner: even if they are linked? i.e. entity of type A has a key that points to entities of type B?

arohner22:06:26

@max AIUI, partitions only deal with the entity id

arohner22:06:20

entity A will be in the partition you specified when you created it, and entity B will be in the partition you specified, when you created it

arohner22:06:30

refs don’t affect their location

max22:06:49

right, so if they are in different partitions will searching across that ref be slower then if they are in the same?

arohner22:06:08

unless both segments are hot

arohner22:06:32

remember that datomic fetches datoms by segment, which is ~5kB-50kB

arohner22:06:06

partitioning is to keep entities ‘nearby’, so hopefully they’ll come from storage in the same segment

arohner22:06:01

but this is mainly a thing to worry about when your data is much larger than ram, and your queries have to pull a lot of datoms from storage

max22:06:36

I suspect that my data will fit in ram for a long time.

max22:06:01

and when it doesn’t ram will be even cheaper simple_smile

max22:06:29

so to not think about it, I want to keep things in one partition. Is there any disadvantage to keeping things in :user?

arohner22:06:52

probably not

max22:06:23

thanks Allen!