Hi Henrik,

> (class +ArFeLink +Entity)
> (rel article   (+Aux +Ref +Link) (feed) NIL (+Article))
> (rel feed      (+Ref +Link) NIL (+Feed))
> 
> (collect 'feed '+ArFeLink Obj Obj 'article) takes forever (2 mins) I need it
> to take something like maximum 2 seconds...
> 
> Can this be fixed by adding some index or key or do I need make this part of
> the DB distributed and chopped up so I can run this in parallel?

This is already the proper index. Is it perhaps the case that there are
simply too many articles fetched at once? How may articles does the
above 'collect' return? And are these articles all needed at that time?

If you talk about 2 seconds, I assume you don't want the user having to
wait, so it is a GUI interaction. In such cases it is typical not to
fetch all data from the DB, but only the first chunk e.g. to display
them in the GUI. It would be better then to use a Pilog query, returning
the results one by one (as done in +QueryChart).

To get results analog to the above 'collect', you could create a query
like

   (let Q
      (goal
         (quote
            @Obj Obj
            (db feed +ArFeLink @Obj @Feed)
            (val @Article @Feed article) ) )
      ...
      (do 20   # Then fetch the first 20 articles
         (NIL (prove Q))  # More?
         (bind @   # Bind the result values
            (println @Article)  # Use the article
            ...

Instead of 'bind' you could also simply use 'get' to extract the
@Article: (get @ '@Article).

Before doing so, I would test it interactively, e.g.

: (? (db feed +ArFeLink {ART} @Feed) (val @Article @Feed article))

if '{ART}' is an article.

Not that the above is not tested.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to