future development of xml capabilities

--_000_232B5217AD58584C87019E8933556D1101FEEC0353redmx2esric om_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello Postgres Gurus,

I am doing some research regarding the postgres native xml type, I found th=
at the xml type can not be indexed, I found some work arounds for it but, I=
was wondering if there were any plans to implement indexing on a xpath exp=
ression in future releases on Postges like Postgres 9?

Thank you,
Sncerely,
Kasia

------------------------------------------------------------ ---------------=
------------------------------------------------------------ --------------8=
..3 has integrated xpath function. There is gap in XML support, because XML =
type isn't supported with GIST or GIN index. So xpath function returns arra=
y of xml values. But we can write custom casting to int array:

CREATE OR REPLACE FUNCTION xml_list_to_int(xml[])
RETURNS int[] AS $$
SELECT ARRAY(SELECT to_number(($1[i])::text,'999999.99')::int
FROM generate_series(1, array_upper($1,1)) g(i))
$$ LANGUAGE SQL IMMUTABLE;

CREATE CAST (xml[] AS int[]) WITH FUNCTION xml_list_to_int(xml[]);

-- array of integers are supported with GIST
CREATE INDEX fx ON foo USING
GIN((xpath('//id/text()',order_in_xml)::int[]));
8.13.3. Accessing XML Values
The xml data type is unusual in that it does not provide any comparison ope=
rators. This is because there is no well-defined and universally useful com=
parison algorithm for XML data. One consequence of this is that you cannot =
retrieve rows by comparing an xml column against a search value. XML values=
should therefore typically be accompanied by a separate key field such as =
an ID. An alternative solution for comparing XML values is to convert them =
to character strings first, but note that character string comparison has l=
ittle to do with a useful XML comparison method.
Since there are no comparison operators for the xml data type, it is not po=
ssible to create an index directly on a column of this type. If speedy sear=
ches in XML data are desired, possible workarounds include casting the expr=
ession to a character string type and indexing that, or indexing an XPath e=
xpression. Of course, the actual query would have to be adjusted to search =
by the indexed expression.
The text-search functionality in PostgreSQL can also be used to speed up fu=
ll-document searches of XML data. The necessary preprocessing support is, h=
owever, not yet available in the PostgreSQL distribution.


--_000_232B5217AD58584C87019E8933556D1101FEEC0353redmx2esric om_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" xmlns:p=3D"urn:schemas-m=
icrosoft-com:office:powerpoint" xmlns:a=3D"urn:schemas-microsoft-com:office=
:access" xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s=3D"=
uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs=3D"urn:schemas-microsof=
t-com:rowset" xmlns:z=3D"#RowsetSchema" xmlns:b=3D"urn:schemas-microsoft-co=
m:office:publisher" xmlns:ss=3D"urn:schemas-microsoft-com:office:spreadshee=
t" xmlns:c=3D"urn:schemas-microsoft-com:office:component:spread sheet" xmlns=
:odc=3D"urn:schemas-microsoft-com:office:odc" xmlns:oa=3D"urn:schemas-micro=
soft-com:office:activation" xmlns:html=3D"http://www.w3.org/TR/REC-html40" =
xmlns:q=3D"http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc=3D"http://m=
icrosoft.com/officenet/conferencing" xmlns:D=3D"DAV:" xmlns:Repl=3D"http://=
schemas.microsoft.com/repl/" xmlns:mt=3D"http://schemas.microsoft.com/share=
point/soap/meetings/" xmlns:x2=3D"http://schemas.microsoft.com/office/excel=
/2003/xml" xmlns:ppda=3D"http://www.passport.com/NameSpace.xsd" xmlns:ois=
=3D"http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir=3D"http://=
schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds=3D"http://www.w3=
..org/2000/09/xmldsig#" xmlns:dsp=3D"http://schemas.microsoft.com/sharepoint=
/dsp" xmlns:udc=3D"http://schemas.microsoft.com/data/udc" xmlns:xsd=3D"http=
://www.w3.org/2001/XMLSchema" xmlns:sub=3D"http://schemas.microsoft.com/sha=
repoint/soap/2002/1/alerts/" xmlns:ec=3D"http://www.w3.org/2001/04/xmlenc#"=
xmlns:sp=3D"http://schemas.microsoft.com/sharepoint/" xmlns:sps=3D"http://=
schemas.microsoft.com/sharepoint/soap/" xmlns:xsi=3D"http://www.w3.org/2001=
/XMLSchema-instance" xmlns:udcs=3D"http://schemas.microsoft.com/data/udc/so=
ap" xmlns:udcxf=3D"http://schemas.microsoft.com/data/udc/xmlfile " xmlns:udc=
p2p=3D"http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf=3D"http:/=
/schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss=3D"http://sche=
mas.microsoft.com/office/2006/digsig-setup" xmlns:dssi=3D"http://schemas.mi=
crosoft.com/office/2006/digsig" xmlns:mdssi=3D"http://schemas.openxmlformat=
s.org/package/2006/digital-signature" xmlns:mver=3D"http://schemas.openxmlf=
ormats.org/markup-compatibility/2006" xmlns:m=3D"http://schemas.microsoft.c=
om/office/2004/12/omml" xmlns:mrels=3D"http://schemas.openxmlformats.org/pa=
ckage/2006/relationships" xmlns:spwp=3D"http://microsoft.com/sharepoint/web=
partpages" xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/service s/20=
06/types" xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/service s/200=
6/messages" xmlns:pptsl=3D"http://schemas.microsoft.com/sharepoint/soap/ Sli=
deLibrary/" xmlns:spsl=3D"http://microsoft.com/webservices/SharePointPor tal=
Server/PublishedLinksService" xmlns:Z=3D"urn:schemas-microsoft-com:" xmlns:=
st=3D"" xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
[at] font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-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.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
..MsoChpDefault
{mso-style-type:export-only;}
[at] page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal>Hello Postgres Gurus,<o:p></o:p></p>

<p class=3DMsoNormal><o:p> </o:p></p>

<p class=3DMsoNormal>I am doing some research regarding the postgres native=
xml
type, I found that the xml type can not be indexed, I found some work aroun=
ds
for it but, I was wondering if there were any plans to implement indexing o=
n a
xpath expression in future releases on Postges like Postgres 9?<o:p></o:p><=
/p>

<p class=3DMsoNormal><o:p> </o:p></p>

<p class=3DMsoNormal>Thank you, <o:p></o:p></p>

<p class=3DMsoNormal>Sncerely,<o:p></o:p></p>

<p class=3DMsoNormal>Kasia <o:p></o:p></p>

<p class=3DMsoNormal><o:p> </o:p></p>

<p class=3DMsoNormal>------------------------------------------------------=
------------------------------------------------------------ ---------------=
--------------------8.3
has integrated xpath function. There is gap in XML support, because XML typ=
e
isn't supported with GIST or GIN index. So xpath function returns array of =
xml
values. But we can write custom casting to int array:<o:p></o:p></p>

<p class=3DMsoNormal><o:p> </o:p></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>CREATE
OR REPLACE FUNCTION xml_list_to_int(xml[])<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>RETURNS
int[] AS $$<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>SELECT
ARRAY(SELECT to_number(($1[i])::text,'999999.99')::int<o:p></o:p></span></p=
>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>           &nbs=
p;   
FROM generate_series(1, array_upper($1,1)) g(i))<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>$$
LANGUAGE SQL IMMUTABLE;<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>CREATE
CAST (xml[] AS int[]) WITH FUNCTION xml_list_to_int(xml[]);<o:p></o:p></spa=
n></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>-- array
of integers are supported with GIST<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>CREATE
INDEX fx ON foo USING<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>GIN((xpath('//id/text()',order_in_xml)::int[]));<o:p></o:p></span></p>

<p class=3DMsoNormal style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt=
:auto'><a
name=3DAEN6767><b><span style=3D'font-size:18.0pt;font-family:"Times New Ro=
man","serif"'>8.13.3.
Accessing XML Values</span></b></a><b><span style=3D'font-size:18.0pt;font-=
family:
"Times New Roman","serif"'><o:p></o:p></span></b></p>

<p class=3DMsoNormal style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt=
:auto'><span
style=3D'font-size:12.0pt;font-family:"Times New Roman","serif"'>The </span=
><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>xml</span><span
style=3D'font-size:12.0pt;font-family:"Times New Roman","serif"'> data type=
is
unusual in that it does not provide any comparison operators. This is becau=
se there
is no well-defined and universally useful comparison algorithm for XML data=
..
One consequence of this is that you cannot retrieve rows by comparing an </=
span><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>xml</span><span
style=3D'font-size:12.0pt;font-family:"Times New Roman","serif"'> column ag=
ainst
a search value. XML values should therefore typically be accompanied by a
separate key field such as an ID. An alternative solution for comparing XML
values is to convert them to character strings first, but note that charact=
er
string comparison has little to do with a useful XML comparison method. <o:=
p></o:p></span></p>

<p class=3DMsoNormal style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt=
:auto'><span
style=3D'font-size:12.0pt;font-family:"Times New Roman","serif"'>Since ther=
e are
no comparison operators for the </span><span style=3D'font-size:10.0pt;
font-family:"Courier New"'>xml</span><span style=3D'font-size:12.0pt;font-f=
amily:
"Times New Roman","serif"'> data type, it is not possible to create an inde=
x
directly on a column of this type. If speedy searches in XML data are desir=
ed,
possible workarounds include casting the expression to a character string t=
ype
and indexing that, or indexing an XPath expression. Of course, the actual q=
uery
would have to be adjusted to search by the indexed expression. <o:p></o:p><=
/span></p>

<p class=3DMsoNormal style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt=
:auto'><span
style=3D'font-size:12.0pt;font-family:"Times New Roman","serif"'>The text-s=
earch
functionality in PostgreSQL can also be used to speed up full-document sear=
ches
of XML data. The necessary preprocessing support is, however, not yet avail=
able
in the PostgreSQL distribution. <o:p></o:p></span></p>

<p class=3DMsoNormal><o:p> </o:p></p>

</div>

</body>

</html>

--_000_232B5217AD58584C87019E8933556D1101FEEC0353redmx2esric om_--
Kasia Tuszynska [ Mi, 26 Mai 2010 17:45 ] [ ID #2042065 ]

Re: future development of xml capabilities

Kasia Tuszynska <ktuszynska [at] esri.com> wrote:

> I was wondering if there were any plans to implement indexing on a
> xpath expression in future releases on Postges like Postgres 9?

I wouldn't be surprised if that eventually gets added, but I don't
recall seeing any discussion of doing so anytime soon. To see the
list of XML work which has made it to the TODO list, look here:

http://wiki.postgresql.org/wiki/Todo#XML

-Kevin

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Kevin Grittner [ Do, 27 Mai 2010 16:47 ] [ ID #2042118 ]
Datenbanken » gmane.comp.db.postgresql.admin » future development of xml capabilities

Vorheriges Thema: command tag logging
Nächstes Thema: Corrupted database - how to recover