Hi, No it's impossible to automatically sort index-scan results by something other than key value or ftindex-scan results by something other than PPSXptr order.
Note that in your query PPDDO (which is actually sorting by document order) takes 3 seconds, and since it's not really needed, it should be avoided (by using declare ordering unordered and sometimes adding extra for loops to get rid of PPSXptr which is also a sort). Also note that parsing dates takes 4 seconds. One of obvious ways of improving performance of such queries is to store data sorted by date, thus document order will be what you need, and PPDDO will be sufficient. This will eliminate order by and date parsing, but you'll need to modify updates so that they would maintain data ordered by date. On Tue, Mar 22, 2011 at 2:51 PM, giocondo sticca <giocondo.sti...@gmail.com> wrote: > Hi, > > there is a way to optimize this query ? > > Could you add a new feature to create pre-ordered full-text/standard indexes > in this way I can query them directly without must order at runtime? > > example: > > create index "myindex" on {path} by {path} as {type} ORDERED BY {path} > > or > > create full-text index "myftindex" on {path} type "xml" with options > "type=native" ORDERED BY {path} > > ---QUERY--- > > declare namespace s="http://www.schemata.it/lml/1.0"; > declare namespace l="http://www.schemata.it/lml/1.0/linker"; > > let $tmp := for $b in ftindex-scan("ft_body","legge","nosort") > let $date:=xs:date($b/../s:meta/s:info/s:date) > order by $date ascending > return $b > return subsequence($tmp,1,10) > & > > total time: 9.999 > > profile: > > <profile xmlns="http://www.modis.ispras.ru/sedna"> > <total-time>12.065</total-time> > </profile><prolog xmlns="http://www.modis.ispras.ru/sedna"> > <namespace prefix="l" uri="http://www.schemata.it/lml/1.0/linker"/> > <namespace prefix="s" uri="http://www.schemata.it/lml/1.0"/> > </prolog><query xmlns="http://www.modis.ispras.ru/sedna"> > <operation xmlns="" name="PPQueryRoot" time="12.065" calls="1"> > <operation name="PPLet" position="4:5" time="12.061" calls="11"> > <produces> > <variable descriptor="5" name="tmp"/> > </produces> > <operation name="PPReturn" position="4:13" time="12.061" calls="11"> > <produces> > <variable descriptor="3"/> > <variable descriptor="2"/> > </produces> > <operation name="PPOrderBy" stable="false" tuple-size="2" > position="6:1" time="12.061" calls="11"> > <modifiers> > <modifier type="ascending empty least"/> > </modifiers> > <operation name="PPReturn" position="4:17" time="8.599" > calls="391301"> > <produces> > <variable descriptor="0" name="b"/> > </produces> > <operation name="PPDDO" position="4:23" time="4.076" > calls="391301"> > <operation name="PPFtIndexScan" position="4:23" time="0.915" > calls="391301"> > <operation name="PPConst" type="xs:string" value="ft_body" > position="4:36" time="0.000" calls="2"/> > <operation name="PPConst" type="xs:string" value="legge" > position="4:46" time="0.000" calls="2"/> > <operation name="PPConst" type="xs:string" value="nosort" > position="4:54" time="0.000" calls="2"/> > </operation> > </operation> > <operation name="PPLet" position="5:5" time="4.332" > calls="782600"> > <produces> > <variable descriptor="1" name="date"/> > </produces> > <operation name="PPCast" type="xs:date?" position="5:12" > time="3.292" calls="782600"> > <operation name="PPAxisChild" step="child::element(s:date)" > position="5:40" time="2.600" calls="782600"> > <operation name="PPAxisChild" > step="child::element(s:info)" position="5:33" time="2.081" calls="782600"> > <operation name="PPAxisChild" > step="child::element(s:meta)" position="5:26" time="1.513" calls="782600"> > <operation name="PPAxisParent" step="parent::node()" > position="5:23" time="0.868" calls="782600"> > <operation name="PPSeqChecker" mode="node" > position="5:23" time="0.275" calls="782600"> > <operation name="PPVariable" descriptor="0" > variable-name="b" position="5:20" time="0.118" calls="782600"/> > </operation> > </operation> > </operation> > </operation> > </operation> > </operation> > <operation name="PPSTuple" position="6:1" time="4.086" > calls="782600"> > <operation name="PPVariable" descriptor="0" > variable-name="b" position="6:1" time="0.114" calls="782600"/> > <operation name="PPVariable" descriptor="1" > variable-name="date" position="6:1" time="3.537" calls="782600"/> > <operation name="PPVariable" descriptor="1" > variable-name="date" position="6:10" time="0.101" calls="782600"/> > </operation> > </operation> > </operation> > </operation> > <operation name="PPSLet" position="7:8" time="0.000" calls="21"> > <produces> > <variable descriptor="4"/> > </produces> > <operation name="PPVariable" descriptor="2" position="7:8" > time="0.000" calls="0"/> > <operation name="PPVariable" descriptor="3" position="7:8" > time="0.000" calls="21"/> > </operation> > </operation> > <operation name="PPFnSubsequence" position="8:8" time="12.061" > calls="11"> > <operation name="PPVariable" descriptor="5" variable-name="tmp" > position="8:20" time="12.061" calls="11"/> > <operation name="PPConst" type="xs:integer" value="1" > position="8:25" time="0.000" calls="2"/> > <operation name="PPConst" type="xs:integer" value="10" > position="8:27" time="0.000" calls="2"/> > </operation> > </operation> > </operation> > </query> > > > Many thanks. > > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Sedna-discussion mailing list > Sedna-discussion@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sedna-discussion > > ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Sedna-discussion mailing list Sedna-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sedna-discussion