<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>(cc’ing dev@ instead)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>hstore supports GiST and GIN indexes and these support only the @>, ?, ?& and ?| operators. ?& and ?| are essentially equivalent to hstore ? 'a' AND hstore ? 'b' or the same with OR.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>If there is some hstore value that you use a lot for complicated queries where you need to use the -> operator it’s possible to index that specifically.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I have some more notes in pgsnapshot indexes that I should do up into a blog post or an email  but it is frequently worth doing EXPLAIN on queries to see if it’s using a sane plan.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Ian Dees [mailto:ian.dees@gmail.com] <br><b>Sent:</b> Wednesday, December 05, 2012 10:39 AM<br><b>To:</b> Martijn van Exel<br><b>Cc:</b> Paul Norman; Richard Welty; the Old Topo Depot; talk-us@openstreetmap.org Openstreetmap<br><b>Subject:</b> Re: [Talk-us] tools for analysis of road networks?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>These are the sorts of queries that jxapi does all the time.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>hstore's @> and ? operators use index, others don't.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>As far as metrics... an xapi query like [highway=*][ref|name=*][bbox=a,b,c,d] on jxapi was taking ~5-10 hours when it was using "exists(tags, 'highway')" (which doesn't use the index on hstore) while the exact same xapi query using the "tags ? 'highway'" takes about 20 minutes.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Dec 5, 2012 at 12:23 PM, Martijn van Exel <<a href="mailto:m@rtijn.org" target="_blank">m@rtijn.org</a>> wrote:<o:p></o:p></p><p class=MsoNormal>Interesting, I have been looking for a way to speed up those types of queries for a while, thanks!<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Do you have metrics on this?<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Wed, Dec 5, 2012 at 10:53 AM, Paul Norman <<a href="mailto:penorman@mac.com" target="_blank">penorman@mac.com</a>> wrote:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Something else is that tags->'highway' in ( 'motorway', 'primary', 'secondary' ) will NOT use indexes on tags.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>tags @> hstore('highway', 'motorway') OR tags @> hstore('highway', 'primary') OR tags @> hstore('highway', 'secondary') should be significantly faster with proper indexes.</span><o:p></o:p></p></div><p class=MsoNormal><br><br clear=all><o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><span class=hoenzb><span style='color:#888888'>-- </span></span><span style='color:#888888'><br><span class=hoenzb>Martijn van Exel</span><br><span class=hoenzb><a href="http://oegeo.wordpress.com/" target="_blank">http://oegeo.wordpress.com/</a></span><br><span class=hoenzb><a href="http://openstreetmap.us/" target="_blank">http://openstreetmap.us/</a></span></span><o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>Talk-us mailing list<br><a href="mailto:Talk-us@openstreetmap.org">Talk-us@openstreetmap.org</a><br><a href="http://lists.openstreetmap.org/listinfo/talk-us" target="_blank">http://lists.openstreetmap.org/listinfo/talk-us</a><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>