[XQZone General] announcing OscarsX

Ryan Grimm grimm at oreilly.com
Tue Mar 7 03:40:14 PST 2006


Hi Howard,
I'm having a good time playing with you're app and decided to try and 
find a workaround to the two problem queries you have.  Below is what 
I've cooked up.  I'm not 100% sure if the results are correct (I'm a 
movie fan, but not a big enough one to know without checking the data 
itself) but they seem to be right.

For the first one:

<five-or-more-acting-nominations>
{
     for $person in distinct-values( 
doc("oscars.xml")/oscars/*[local-name() = ("actor", "actorSupporting", 
"actress", "actressSupporting")]//person )
     let $count := count( doc("oscars.xml")/oscars/*[local-name() = 
("actor", "actorSupporting", "actress", "actressSupporting")]//person[. 
= $person] )
     where $count ge 5
     order by $count descending
     return
         <actor nominations="{$count}">{ $person }</actor>
}
</five-or-more-acting-nominations>, 
xdmp:query-meters()//*:elapsed-time/text()

And the second:

define function nominations( $num-noms as xs:integer )
{
     let $prefix :=
         if      ( $num-noms eq 1 ) then "one"
         else if ( $num-noms eq 2 ) then "two"
         else if ( $num-noms eq 3 ) then "three"
         else if ( $num-noms eq 4 ) then "four"
         else if ( $num-noms eq 5 ) then "five"
         else if ( $num-noms eq 6 ) then "six"
         else if ( $num-noms eq 7 ) then "seven"
         else if ( $num-noms eq 8 ) then "eight"
         else if ( $num-noms eq 9 ) then "nine"
         else "lots-of"
     return

     element { concat( $prefix, "-acting-nominations" ) }
     {
         for $person in distinct-values( 
doc("oscars.xml")/oscars/*[local-name() =
             ("actor", "actorSupporting", "actress", 
"actressSupporting")]//person )
         let $count := count( doc("oscars.xml")/oscars/*[local-name() =
             ("actor", "actorSupporting", "actress", 
"actressSupporting")]//person[. = $person] )
         where $count ge $num-noms
         order by $count descending, $person
         return

         <actor nominations="{$count}">{ $person }</actor>
     }
}

(: 9 or more nominations, just for the heck of it :)
nominations( 9 ), xdmp:query-meters()//*:elapsed-time/text()


These are also now pretty zippy.
I thought about taking a look at your other query that takes a min to 
run to see if we could get some more speed out of it but I'm getting 
tired.

Hope that helps.

--Ryan


On Mar 6, 2006, at 10:57 PM, Howard Katz wrote:

> I'm pleased to announce the release of my OscarsX site (" An XML 
> database
> for the Academy Awards") at www.fatdog.com/oscarsX. This site, powered 
> by a
> Mark Logic server on the back end, provides access to 78 years of 
> Oscars
> nomination data via a "raw" XQuery interface. I want to thank 
> everybody on
> this list who's helped me and answered questions along the way, both 
> online
> and privately.
>
> Interestingly enough, I just made a move from 3.0-1 to 3.0-5 so that 
> one of
> my queries would work correctly, which happily it now does
> (http://www.fatdog.com/oscarsX#TWO-ACTING-CATEGORIES-SAME-YEAR).
> Unfortunately two other queries, which were working correctly under 
> 3.0-1,
> now fail! These are http://www.fatdog.com/oscarsX#5-OR-MORE-ACTING and 
> the
> related http://www.fatdog.com/oscarsX#N-OR-MORE-ACTING. I've noted on 
> the
> site what the problems seem to be. I'll leave these incorrect queries 
> in
> place for the moment. If anybody at Mark Logic wants to see what the 
> correct
> results should be, email me or simply steal a copy of the database -- 
> it's
> easy to do -- and run it under 3.0-1.
>
> I've also noted somewhere on the site that I've apparently got my 
> content
> server somewhat misconfigured, since most, if not all of the queries 
> on the
> site execute faster on my desktop machine than they do on my ISP's 
> server
> (which I would expect to be somewhat peppier than my home machine, tho 
> I've
> yet to check this explicitly). I've checked the configuration files 
> but as
> far as I can tell, they're set the same on both. If anybody cares to 
> try and
> is able to achieve better results, performance-wise, on your own 
> machine
> than via the above server, I'd be interested in knowing what particular
> parameters you've tweaked.
>
> In the meantime, please enjoy.
> Best,
> Howard Katz
>
> _______________________________________________
> General mailing list
> General at xqzone.marklogic.com
> http://xqzone.com/mailman/listinfo/general
>




More information about the General mailing list