client:connect reference to DB or storage in RAM (loss in performance?)

Friday, 17 June 2016 · 5 messages · last reply 20 Jun 2016
KS
Kapoor, Sumit17 Jun 2016 15:15 #
Hello, the Question is: If I open a connection, send a query and close the connection: What do I get? Just a Copy of the Database which will be stored in the core/main memory or a reference to the DB? Here a Code Example:
let $cid := client:connect("localhost",port,"user","password")

let $query := 'collection("BIG-DB")/*:node'

let $req := client:query($cid,$query)

let $close := client:close($cid)
return $req If it's just a copy in the main memory than (depends on the size oft he DB) it will cost a lot of performance. We have to use such a workaround with "client:connect" because if we try to access directly the DB more than once it will be blocked. So do you have any experience with the return value of "$req" ? Is it still a reference of the DB or is it stored in the main memory? Regards, Sumit Kapoor
Quoted text · 2 lines
------------------------------------------------------- >>> business. people. technology. <<<
------------------------------------------------------- adesso AG mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663
A
Asxetos17 Jun 2016 15:34 #
I found it is much easier to use the REST API[0] to do anything with the DB data. HTTP module[1] might also come handy. Especially modifying documents is done by GETting the document, doing all the work locally and then PUTting it back, atomically replacing the old document. IMO, constructing queries using strings is ugly and error prone. Also, maybe it is better to let us know what you're trying to achieve in order to be able to offer you more specific answers. [0]: http://docs.basex.org/wiki/REST [1]: http://docs.basex.org/wiki/HTTP_Module
Quoted text · Sumit · 54 lines
On 17 June 2016 at 16:15, Kapoor, Sumit <Sumit.Kapoor at adesso.de> wrote: > Hello, > > > > the Question is: > > > > If I open a connection, send a query and close the connection: What do I > get? Just a Copy of the Database which will be stored in the core/main > memory or a reference to the DB? Here a Code Example: > > > > let $cid := client:connect("localhost",port,"user","password") > > let $query := 'collection("BIG-DB")/*:node' > > let $req := client:query($cid,$query) > > let $close := client:close($cid) > > return $req > > > > If it’s just a copy in the main memory than (depends on the size oft he DB) > it will cost a lot of performance. > > We have to use such a workaround with „client:connect“ because if we try to > access directly the DB more than once it will be blocked. > > So do you have any experience with the return value of „$req“ ? Is it still > a reference of the DB or is it stored in the main memory? > > > > Regards, > > > > Sumit Kapoor > > > > ------------------------------------------------------- > >>> business. people. technology. <<< > ------------------------------------------------------- > > adesso AG mit Sitz in Dortmund > Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis > Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn > Amtsgericht Dortmund HRB 20663
CG
Christian Grünin reply to Kapoor, Sumit, 17 Jun 2016, 15:1518 Jun 2016 14:39 #
Quoted text · Kapoor, Sumit · 3 lines
> If I open a connection, send a query and close the connection: What do I > get? Just a Copy of the Database which will be stored in the core/main > memory or a reference to the DB? Here a Code Example:
You will always get a copy of the database node. As you may have seen in the documentation of the Client Module, you should never use it to address the same BaseX instance, as this can cause deadlocks.
Quoted text · Kapoor, Sumit · 2 lines
> We have to use such a workaround with „client:connect“ because if we try to > access directly the DB more than once it will be blocked.
Do you have more details? Christian
KS
Kapoor, Sumit20 Jun 2016 11:53 #
I mean if we try to access the DB without "client:connect" e.g. :
if (collection("BIG-DB")/*:node[*:id=3/*:status = 'true')
                                                    then _:todoFunc("")
                                                    else ()
That would be an access to the DB without "client:connect" if I code it like that more than once I always get the error: "The Database is already in use". Because they block each other. For example if I add this to it:
let $anotherquery := collection("BIG-DB")/*:node
Regards, Sumit
Quoted text · Christian Grün · 21 lines
-----Ursprüngliche Nachricht----- Von: Christian Grün [mailto:christian.gruen at gmail.com] Gesendet: Samstag, 18. Juni 2016 14:40 An: Kapoor, Sumit <Sumit.Kapoor at adesso.de> Cc: basex-talk at mailman.uni-konstanz.de Betreff: Re: [basex-talk] client:connect reference to DB or storage in RAM (loss in performance?) > If I open a connection, send a query and close the connection: What do > I get? Just a Copy of the Database which will be stored in the > core/main memory or a reference to the DB? Here a Code Example: You will always get a copy of the database node. As you may have seen in the documentation of the Client Module, you should never use it to address the same BaseX instance, as this can cause deadlocks. > We have to use such a workaround with „client:connect“ because if we > try to access directly the DB more than once it will be blocked. Do you have more details? Christian ------------------------------------------------------- >>> business. people. technology. <<< ------------------------------------------------------- adesso AG mit Sitz in Dortmund Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn Amtsgericht Dortmund HRB 20663
CG
Christian Grün20 Jun 2016 12:15 #
We need more information. Could you please provide us with a full example that demonstrates the problem?
Quoted text · Kapoor, Sumit · 41 lines
> I mean if we try to access the DB without "client:connect" e.g. : > > if (collection("BIG-DB")/*:node[*:id=3/*:status = 'true') > then _:todoFunc("") > else () > > That would be an access to the DB without "client:connect" if I code it like that more than once I always get the error: "The Database is already in use". Because they block each other. For example if I add this to it: > > let $anotherquery := collection("BIG-DB")/*:node > > > Regards, > Sumit > > -----Ursprüngliche Nachricht----- > Von: Christian Grün [mailto:christian.gruen at gmail.com] > Gesendet: Samstag, 18. Juni 2016 14:40 > An: Kapoor, Sumit <Sumit.Kapoor at adesso.de> > Cc: basex-talk at mailman.uni-konstanz.de > Betreff: Re: [basex-talk] client:connect reference to DB or storage in RAM (loss in performance?) > >> If I open a connection, send a query and close the connection: What do >> I get? Just a Copy of the Database which will be stored in the >> core/main memory or a reference to the DB? Here a Code Example: > > You will always get a copy of the database node. As you may have seen in the documentation of the Client Module, you should never use it to address the same BaseX instance, as this can cause deadlocks. > >> We have to use such a workaround with „client:connect“ because if we >> try to access directly the DB more than once it will be blocked. > > Do you have more details? > Christian > > ------------------------------------------------------- > >>> business. people. technology. <<< > ------------------------------------------------------- > > adesso AG mit Sitz in Dortmund > Vorstand: Michael Kenfenheuer (Vors.), Christoph Junge, Andreas Prenneis > Vorsitzender des Aufsichtsrates: Prof. Dr. Volker Gruhn > Amtsgericht Dortmund HRB 20663

⚡Generated with XQuery