Query slow via PHP
Wednesday, 5 December 2012 · 14 messages · last reply 11 Jan 2013
MJ
Mayer, Jonathan5 Dec 2012 12:08 #
Hi,
Hope you can help a very novice basex/xquery user!
I have the following query to get the complete XML of the "Links.xml" document in the "project" collection.
for $doc in collection('project') where matches(document-uri($doc), '^Links.xml') return $docWhen running this command in basex on linux it completes in around 2.5 seconds (acceptable speed given the size of the XML file) but when I run it via PHP using the client from the website, it takes around 15 seconds:
$session = new Session("localhost", $host, $username, $password);
$input = "for \$doc in collection('project') where matches(document-uri(\$doc), '^Links.xml') return \$doc";
$query = $session->query($input);
$xml = $query->execute();Any idea why it might take so long, or whether rewriting my query in a different way would speed up the response?
Thanks,
Jon.
AW
Andreas Weiler5 Dec 2012 12:12 #
Hi,
you can try the following:
Quoted text · Mayer, Jonathan · 3 lines
> $session = new Session("localhost", $host, $username, $password); > $input = "for \$doc in collection('project') where matches(document-uri(\$doc), '^Links.xml') return \$doc"; > $xml = $session->execute("xquery ".$input);
-- Andreas
Quoted text · Mayer, Jonathan · 24 lines
Am 05.12.2012 um 12:08 schrieb Mayer, Jonathan: > Hi, > > Hope you can help a very novice basex/xquery user! > > I have the following query to get the complete XML of the “Links.xml” document in the “project” collection. > > for $doc in collection(‘project’) where matches(document-uri($doc), '^Links.xml') return $doc > > When running this command in basex on linux it completes in around 2.5 seconds (acceptable speed given the size of the XML file) but when I run it via PHP using the client from the website, it takes around 15 seconds: > > $session = new Session("localhost", $host, $username, $password); > $input = "for \$doc in collection('project') where matches(document-uri(\$doc), '^Links.xml') return \$doc"; > $query = $session->query($input); > $xml = $query->execute(); > > Any idea why it might take so long, or whether rewriting my query in a different way would speed up the response? > > Thanks, > Jon. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Quoted text · Mayer, Jonathan · 3 lines
> When running this command in basex on linux it completes in around 2.5 > seconds (acceptable speed given the size of the XML file) but when I run it > via PHP using the client from the website, it takes around 15 seconds:
There should be no considerable difference reg. the APIs you are using, so.. could you do some more profiling to find out which step of your PHP query takes so long?
Quoted text · Mayer, Jonathan · 2 lines
> $input = "for \$doc in collection('project') where > matches(document-uri(\$doc), '^Links.xml') return \$doc";
Btw, the following may be faster in boh cases:
db:open('project', 'Links.xml')Best,
Christian
MJ
Mayer, Jonathan5 Dec 2012 12:33 #
Thanks to both responders, although neither change has made a difference to the speed (it was useful to learn the shortened way of opening the xml document though!)
Some PHP profiling suggests it's specifically the...
$xml = $query->execute();...line with is bottleneck.
An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware.
Thanks,
Jon.
Quoted text · Christian Grün · 16 lines
-----Original Message----- From: Christian Grün [mailto:christian.gruen at gmail.com] Sent: 05 December 2012 11:19 To: Mayer, Jonathan Cc: basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] Query slow via PHP > When running this command in basex on linux it completes in around 2.5 > seconds (acceptable speed given the size of the XML file) but when I > run it via PHP using the client from the website, it takes around 15 seconds: There should be no considerable difference reg. the APIs you are using, so.. could you do some more profiling to find out which step of your PHP query takes so long? > $input = "for \$doc in collection('project') where > matches(document-uri(\$doc), '^Links.xml') return \$doc"; Btw, the following may be faster in boh cases: db:open('project', 'Links.xml') Best, Christian
CG
Christian Grün5 Dec 2012 12:44 #
Quoted text · Mayer, Jonathan · 1 line
> An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware.
Good to know; so it seems that the PHP API isn’t very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ?
count( db:open('project', 'Links.xml') )I’m no PHP expert, but I looked into the PHP client, and I
saw/remember it uses some buffering:
https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php
Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay?
Christian
IL
Imsieke, Gerrit, le-tex5 Dec 2012 12:52 #
Quoted text · Christian Grün · 4 lines
On 2012-12-05 12:44, Christian Grün wrote: > https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php > > Maybe someone else on the list has some idea how the API could be
Not using PHP in the first place has improved life for many people.
Sorry, simply couldn’t resist trolling ;)
Quoted text · Christian Grün · 8 lines
> improved, or if there's any other reason for the delay? > > Christian > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MJ
FWIW, the query is indeed evaluated very quickly when using count() but of course it only returns an int.
Quoted text · Christian Grün · 13 lines
-----Original Message----- From: Christian Grün [mailto:christian.gruen at gmail.com] Sent: 05 December 2012 11:45 To: Mayer, Jonathan Cc: basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] Query slow via PHP > An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware. Good to know; so it seems that the PHP API isn't very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ? count( db:open('project', 'Links.xml') ) I'm no PHP expert, but I looked into the PHP client, and I saw/remember it uses some buffering: https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay? Christian
BB
Bill Beck5 Dec 2012 14:02 #
FWIW:
I've been using php for connecting to Java services over CURL for years, usually with very fast results. Does the BaseX API use CURL? One thing I've noticed, back on a Centos 5 setup was that the connection between PHP and the db (this was eXist), both on the same machine, was actual slower on localhost because the machine was giving higher priority to GUI processes. We moved to a server and it much faster.
We're using php with Basex and getting millisecond response times, albeit with collections of a few dozen files that are only around 30KB each.
-bb
Quoted text · Jonathan · 27 lines
On Dec 5, 2012, at 6:53 AM, Mayer, Jonathan wrote: > FWIW, the query is indeed evaluated very quickly when using count() but of course it only returns an int. > > -----Original Message----- > From: Christian Grün [mailto:christian.gruen at gmail.com] > Sent: 05 December 2012 11:45 > To: Mayer, Jonathan > Cc: basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Query slow via PHP > >> An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware. > > Good to know; so it seems that the PHP API isn't very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ? > > count( db:open('project', 'Links.xml') ) > > I'm no PHP expert, but I looked into the PHP client, and I saw/remember it uses some buffering: > > https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php > > Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay? > > Christian > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
--
Bill Beck, Web Development Specialist
Massachusetts Historical Society
1154 Boylston Street, Boston, MA 02215
Tel: 617-646-0505, Fax: 617-859-0074
www.masshist.org - America's Oldest Historical Society - Founded 1791
In Death Lamented: The Tradition of Anglo-American Mourning Jewelry opens on 28 September 2012 and runs through 31 January 2013. The exhibition will be on display Monday through Saturday from 10 AM to 4 PM. More information is available at www.masshist.org/events/.
MJ
Mayer, Jonathan5 Dec 2012 15:31 #
Thought you may like to know that I have reduced the speed of the call from 15 seconds to 5 by not running the xdebug extension in PHP. I'm guessing there may be further improvements that can be made in the PHP config.
Thanks for your help guys.
Jon.
Quoted text · Bill Beck · 45 lines
-----Original Message----- From: Bill Beck [mailto:bbeck at masshist.org] Sent: 05 December 2012 13:03 To: Mayer, Jonathan Cc: Christian Grün; basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] Query slow via PHP FWIW: I've been using php for connecting to Java services over CURL for years, usually with very fast results. Does the BaseX API use CURL? One thing I've noticed, back on a Centos 5 setup was that the connection between PHP and the db (this was eXist), both on the same machine, was actual slower on localhost because the machine was giving higher priority to GUI processes. We moved to a server and it much faster. We're using php with Basex and getting millisecond response times, albeit with collections of a few dozen files that are only around 30KB each. -bb On Dec 5, 2012, at 6:53 AM, Mayer, Jonathan wrote: > FWIW, the query is indeed evaluated very quickly when using count() but of course it only returns an int. > > -----Original Message----- > From: Christian Grün [mailto:christian.gruen at gmail.com] > Sent: 05 December 2012 11:45 > To: Mayer, Jonathan > Cc: basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Query slow via PHP > >> An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware. > > Good to know; so it seems that the PHP API isn't very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ? > > count( db:open('project', 'Links.xml') ) > > I'm no PHP expert, but I looked into the PHP client, and I saw/remember it uses some buffering: > > https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php > > Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay? > > Christian > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk -- Bill Beck, Web Development Specialist Massachusetts Historical Society 1154 Boylston Street, Boston, MA 02215 Tel: 617-646-0505, Fax: 617-859-0074 www.masshist.org - America's Oldest Historical Society - Founded 1791 In Death Lamented: The Tradition of Anglo-American Mourning Jewelry opens on 28 September 2012 and runs through 31 January 2013. The exhibition will be on display Monday through Saturday from 10 AM to 4 PM. More information is available at www.masshist.org/events/.
CG
Christian Grün5 Dec 2012 16:29 #
Quoted text · Mayer, Jonathan · 1 line
> Thought you may like to know that I have reduced the speed of the call from 15 seconds to 5 by not running the xdebug extension in PHP. I'm guessing there may be further improvements that can be made in the PHP config.
Good to hear; keep us updated,
Christian
Quoted text · Mayer, Jonathan · 53 lines
> -----Original Message----- > From: Bill Beck [mailto:bbeck at masshist.org] > Sent: 05 December 2012 13:03 > To: Mayer, Jonathan > Cc: Christian Grün; basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Query slow via PHP > > FWIW: > I've been using php for connecting to Java services over CURL for years, usually with very fast results. Does the BaseX API use CURL? > One thing I've noticed, back on a Centos 5 setup was that the connection between PHP and the db (this was eXist), both on the same machine, was actual slower on localhost because the machine was giving higher priority to GUI processes. We moved to a server and it much faster. > > We're using php with Basex and getting millisecond response times, albeit with collections of a few dozen files that are only around 30KB each. > > -bb > > On Dec 5, 2012, at 6:53 AM, Mayer, Jonathan wrote: > >> FWIW, the query is indeed evaluated very quickly when using count() but of course it only returns an int. >> >> -----Original Message----- >> From: Christian Grün [mailto:christian.gruen at gmail.com] >> Sent: 05 December 2012 11:45 >> To: Mayer, Jonathan >> Cc: basex-talk at mailman.uni-konstanz.de >> Subject: Re: [basex-talk] Query slow via PHP >> >>> An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware. >> >> Good to know; so it seems that the PHP API isn't very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ? >> >> count( db:open('project', 'Links.xml') ) >> >> I'm no PHP expert, but I looked into the PHP client, and I saw/remember it uses some buffering: >> >> https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php >> >> Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay? >> >> Christian >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > -- > Bill Beck, Web Development Specialist > Massachusetts Historical Society > 1154 Boylston Street, Boston, MA 02215 > Tel: 617-646-0505, Fax: 617-859-0074 > www.masshist.org - America's Oldest Historical Society - Founded 1791 > > > In Death Lamented: The Tradition of Anglo-American Mourning Jewelry opens on 28 September 2012 and runs through 31 January 2013. The exhibition will be on display Monday through Saturday from 10 AM to 4 PM. More information is available at www.masshist.org/events/.
MJ
Mayer, Jonathan10 Jan 2013 17:13 #
Hi all,
Sorry to dig up this old topic but despite the speed gain from not running PHP extensions, I'm continuing to have problems with the speed of opening my XML files.
I have a document which has around 30,000 rows (and slowly growing)
Running:
XQUERY db:open('project', 'Links.xml')
From the command line displays the file in 4.5 seconds
Running it in PHP takes about 9 seconds.
Both seem very slow. I know it's a large document but does this sound slow to you?
Any ideas for improving gratefully received!
Jon.
Quoted text · Christian Grün · 62 lines
-----Original Message----- From: Christian Grün [mailto:christian.gruen at gmail.com] Sent: 05 December 2012 15:29 To: Mayer, Jonathan Cc: Bill Beck; basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] Query slow via PHP > Thought you may like to know that I have reduced the speed of the call from 15 seconds to 5 by not running the xdebug extension in PHP. I'm guessing there may be further improvements that can be made in the PHP config. Good to hear; keep us updated, Christian > -----Original Message----- > From: Bill Beck [mailto:bbeck at masshist.org] > Sent: 05 December 2012 13:03 > To: Mayer, Jonathan > Cc: Christian Grün; basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Query slow via PHP > > FWIW: > I've been using php for connecting to Java services over CURL for years, usually with very fast results. Does the BaseX API use CURL? > One thing I've noticed, back on a Centos 5 setup was that the connection between PHP and the db (this was eXist), both on the same machine, was actual slower on localhost because the machine was giving higher priority to GUI processes. We moved to a server and it much faster. > > We're using php with Basex and getting millisecond response times, albeit with collections of a few dozen files that are only around 30KB each. > > -bb > > On Dec 5, 2012, at 6:53 AM, Mayer, Jonathan wrote: > >> FWIW, the query is indeed evaluated very quickly when using count() but of course it only returns an int. >> >> -----Original Message----- >> From: Christian Grün [mailto:christian.gruen at gmail.com] >> Sent: 05 December 2012 11:45 >> To: Mayer, Jonathan >> Cc: basex-talk at mailman.uni-konstanz.de >> Subject: Re: [basex-talk] Query slow via PHP >> >>> An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware. >> >> Good to know; so it seems that the PHP API isn't very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ? >> >> count( db:open('project', 'Links.xml') ) >> >> I'm no PHP expert, but I looked into the PHP client, and I saw/remember it uses some buffering: >> >> https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php >> >> Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay? >> >> Christian >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > -- > Bill Beck, Web Development Specialist > Massachusetts Historical Society > 1154 Boylston Street, Boston, MA 02215 > Tel: 617-646-0505, Fax: 617-859-0074 > www.masshist.org - America's Oldest Historical Society - Founded 1791 > > > In Death Lamented: The Tradition of Anglo-American Mourning Jewelry opens on 28 September 2012 and runs through 31 January 2013. The exhibition will be on display Monday through Saturday from 10 AM to 4 PM. More information is available at www.masshist.org/events/.
CG
Christian Grün10 Jan 2013 19:44 #
Hi Jonathan,
Quoted text · Mayer, Jonathan · 1 line
> From the command line displays the file in 4.5 seconds
using the console is probably not the best idea when it comes to benchmarking. How long does it take if you redirect the output to a file? Eg via..
basex -o output -v query.xq
Quoted text · Mayer, Jonathan · 70 lines
> -----Original Message----- > From: Christian Grün [mailto:christian.gruen at gmail.com] > Sent: 05 December 2012 15:29 > To: Mayer, Jonathan > Cc: Bill Beck; basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Query slow via PHP > >> Thought you may like to know that I have reduced the speed of the call from 15 seconds to 5 by not running the xdebug extension in PHP. I'm guessing there may be further improvements that can be made in the PHP config. > > Good to hear; keep us updated, > Christian > > >> -----Original Message----- >> From: Bill Beck [mailto:bbeck at masshist.org] >> Sent: 05 December 2012 13:03 >> To: Mayer, Jonathan >> Cc: Christian Grün; basex-talk at mailman.uni-konstanz.de >> Subject: Re: [basex-talk] Query slow via PHP >> >> FWIW: >> I've been using php for connecting to Java services over CURL for years, usually with very fast results. Does the BaseX API use CURL? >> One thing I've noticed, back on a Centos 5 setup was that the connection between PHP and the db (this was eXist), both on the same machine, was actual slower on localhost because the machine was giving higher priority to GUI processes. We moved to a server and it much faster. >> >> We're using php with Basex and getting millisecond response times, albeit with collections of a few dozen files that are only around 30KB each. >> >> -bb >> >> On Dec 5, 2012, at 6:53 AM, Mayer, Jonathan wrote: >> >>> FWIW, the query is indeed evaluated very quickly when using count() but of course it only returns an int. >>> >>> -----Original Message----- >>> From: Christian Grün [mailto:christian.gruen at gmail.com] >>> Sent: 05 December 2012 11:45 >>> To: Mayer, Jonathan >>> Cc: basex-talk at mailman.uni-konstanz.de >>> Subject: Re: [basex-talk] Query slow via PHP >>> >>>> An export of the Links.xml, by the way, shows that it's a 4.4meg file, so it's not small, but it's all localhost so it's not a network issue as far as I'm aware. >>> >>> Good to know; so it seems that the PHP API isn't very good at retrieving data (and I was too careless claiming that the API to be used does not matter). Out of interest: I guess that your query will be evaluated much faster when wrapping it with "count(...)" ? >>> >>> count( db:open('project', 'Links.xml') ) >>> >>> I'm no PHP expert, but I looked into the PHP client, and I saw/remember it uses some buffering: >>> >>> https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php >>> >>> Maybe someone else on the list has some idea how the API could be improved, or if there's any other reason for the delay? >>> >>> Christian >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> -- >> Bill Beck, Web Development Specialist >> Massachusetts Historical Society >> 1154 Boylston Street, Boston, MA 02215 >> Tel: 617-646-0505, Fax: 617-859-0074 >> www.masshist.org - America's Oldest Historical Society - Founded 1791 >> >> >> In Death Lamented: The Tradition of Anglo-American Mourning Jewelry opens on 28 September 2012 and runs through 31 January 2013. The exhibition will be on display Monday through Saturday from 10 AM to 4 PM. More information is available at www.masshist.org/events/. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
LQ
Quoted text · Jonathan · 6 lines
On Thu, 2013-01-10 at 16:13 +0000, Mayer, Jonathan wrote: > Running: > > XQUERY db:open('project', 'Links.xml') > > From the command line displays the file in 4.5 seconds
Is this on a 1MHz 286? :D
How many megabytes is the file?
The usual trick is to put the document in the database so you don't need to read it off disk each time.
http://www.fromoldbooks.org/ connects to a local basex server for the keyword "tag cloud" and it's fast enough that I have not bothered to use memcached to speed it up. The XML file is a little under 6 megabytes, though, so not very large. Here's the code I use. The element and attribute indexes are properly titillated, er, turned on, but I have not measured whether that makes a difference.
include("Search/BaseXClient.php");
try {
$session = new Session("localhost", 1994, "socks", "black");
$session->execute("open rdf");
$session->execute("set SERIALIZER
method=xhtml,omit-xml-declaration=yes,indent=no");
echo $session->execute('xquery
<div class="tagcloud">{
let $kw := /cache/kwlist/kw,
$max := math:sqrt(max(
for $e in $kw return xs:integer($e/@count)
))
return
for $i in /cache/kwlist/kw
let $freq :=
xs:integer(10 * math:sqrt($i/@count) div $max)
where xs:integer($i/@count) ge 10
order by $i/@what
return (
<a
class="tag freq{$freq}"
title="items: {$i/@count}"
href="/Search/?kw={translate($i/@what, " ",
"+")};fp=1"Quoted text · Mayer, Jonathan · 1 line
>
{replace(xs:string($i/@what), "^letter([a-z])$", "letter
$1")}
</a>,
"
"
)
}</div>
');
// close session
$session->close();
} catch (Exception $e) {
// print exception
print $e->getMessage();
}--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
YM
Hi,
Regarding PHP access (we use it in our product www.mysimplegrid.com) I know we've had some issues at one point because of a setup on Apache. I'll try to find out what was the issue and I'll get back to you.
*Cordialement / Best Regards,
*
*Yoann Maingon*
CEO - Minerva France
*+33 6 64 32 49 66*
Download Aras Innovator - Téléchargez Aras
Innovator<http://www.aras.com/support/downloads/downloadInnovator.aspx>
2013/1/10 Mayer, Jonathan <JMayer at t-tales.com>
Quoted text · Mayer, Jonathan · 114 lines
> Hi all, > > Sorry to dig up this old topic but despite the speed gain from not running > PHP extensions, I'm continuing to have problems with the speed of opening > my XML files. > > I have a document which has around 30,000 rows (and slowly growing) > > Running: > > XQUERY db:open('project', 'Links.xml') > > From the command line displays the file in 4.5 seconds > > Running it in PHP takes about 9 seconds. > > Both seem very slow. I know it's a large document but does this sound slow > to you? > > Any ideas for improving gratefully received! > > Jon. > > -----Original Message----- > From: Christian Grün [mailto:christian.gruen at gmail.com] > Sent: 05 December 2012 15:29 > To: Mayer, Jonathan > Cc: Bill Beck; basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Query slow via PHP > > > Thought you may like to know that I have reduced the speed of the call > from 15 seconds to 5 by not running the xdebug extension in PHP. I'm > guessing there may be further improvements that can be made in the PHP > config. > > Good to hear; keep us updated, > Christian > > > > -----Original Message----- > > From: Bill Beck [mailto:bbeck at masshist.org] > > Sent: 05 December 2012 13:03 > > To: Mayer, Jonathan > > Cc: Christian Grün; basex-talk at mailman.uni-konstanz.de > > Subject: Re: [basex-talk] Query slow via PHP > > > > FWIW: > > I've been using php for connecting to Java services over CURL for years, > usually with very fast results. Does the BaseX API use CURL? > > One thing I've noticed, back on a Centos 5 setup was that the connection > between PHP and the db (this was eXist), both on the same machine, was > actual slower on localhost because the machine was giving higher priority > to GUI processes. We moved to a server and it much faster. > > > > We're using php with Basex and getting millisecond response times, > albeit with collections of a few dozen files that are only around 30KB each. > > > > -bb > > > > On Dec 5, 2012, at 6:53 AM, Mayer, Jonathan wrote: > > > >> FWIW, the query is indeed evaluated very quickly when using count() but > of course it only returns an int. > >> > >> -----Original Message----- > >> From: Christian Grün [mailto:christian.gruen at gmail.com] > >> Sent: 05 December 2012 11:45 > >> To: Mayer, Jonathan > >> Cc: basex-talk at mailman.uni-konstanz.de > >> Subject: Re: [basex-talk] Query slow via PHP > >> > >>> An export of the Links.xml, by the way, shows that it's a 4.4meg file, > so it's not small, but it's all localhost so it's not a network issue as > far as I'm aware. > >> > >> Good to know; so it seems that the PHP API isn't very good at > retrieving data (and I was too careless claiming that the API to be used > does not matter). Out of interest: I guess that your query will be > evaluated much faster when wrapping it with "count(...)" ? > >> > >> count( db:open('project', 'Links.xml') ) > >> > >> I'm no PHP expert, but I looked into the PHP client, and I saw/remember > it uses some buffering: > >> > >> > https://github.com/BaseXdb/basex-api/blob/master/src/main/php/BaseXClient.php > >> > >> Maybe someone else on the list has some idea how the API could be > improved, or if there's any other reason for the delay? > >> > >> Christian > >> _______________________________________________ > >> BaseX-Talk mailing list > >> BaseX-Talk at mailman.uni-konstanz.de > >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > -- > > Bill Beck, Web Development Specialist > > Massachusetts Historical Society > > 1154 Boylston Street, Boston, MA 02215 > > Tel: 617-646-0505, Fax: 617-859-0074 > > www.masshist.org - America's Oldest Historical Society - Founded 1791 > > > > > > In Death Lamented: The Tradition of Anglo-American Mourning Jewelry > opens on 28 September 2012 and runs through 31 January 2013. The exhibition > will be on display Monday through Saturday from 10 AM to 4 PM. More > information is available at www.masshist.org/events/. > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 7.3, 7.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery