Owlready2 sends queries as soon as something is modified:
organization = cids.Organization() # This sends a query
organization.hasName = 'some name' # This sends a query
organizatiion.address = ... # This sends a query
This could slow down performance when using SPARQL backend.
Proposed optimizations
Option 1
- Combine consecutive
INSERT DATA queries into one.
- Debounce the insertions, i.e. 5ms, or send the query as soon as other types of queries are requested.
- Involves multi-threading. A separate thread to schedule the query.
Option 2
- Change the logic of when queries are sent. (Can be turned off)
- Introduce a
save() method for individuals:
default_world.set_autosave(false) # Turn off real time modification
organization = cids.Organization()
organization.hasName = 'some name'
organizatiion.address = ...
organizatiion.save() # This sends some optimized queries.
Option 3
- Implement Option1 and Option 2
Owlready2 sends queries as soon as something is modified:
This could slow down performance when using SPARQL backend.
Proposed optimizations
Option 1
INSERT DATAqueries into one.Option 2
save()method for individuals:Option 3