xml - postgresql xpath integer index -


i wondering if there way create indexes based on type conversion of xpath results. integer index, can imagine date, floating points, etc. if experimental or coming in future version of postgres... or database. looked @ existdb looked far being production ready.

some test xml:

<?xml version="1.0"?> <book>     <isbn>1</isbn>     <title>goldfinger</title>     <author>ian fleming</author> </book> 

i able obtain satisfactory results table , index this.

                                             table "public.test"  column |  type   |                     modifiers                     | storage  | stats target | description --------+---------+---------------------------------------------------+----------+--------------+-------------  id     | integer | not null default nextval('test_id_seq'::regclass) | plain    |              |  num    | integer |                                                   | plain    |              |  data   | xml     |                                                   | extended |              | indexes:     "test_pkey" primary key, btree (id)     "test_title_index" btree (((xpath('/book/title/text()'::text, data))[1]::text)) 

for query such as:

select * test (xpath('/book/title/text()', data))[1]::text = 'goldfinger'; 

but there data in schemas non-text index make great deal more sense. example (i know not valid, illustrates point):

select * test (xpath('/book/isbn/text()', data))[1]::int between 5 , 10; 

a little background:

i experimenting storing xml documents in postgres have application primary data types in xml , need retrieved such. schemas can complex, splitting them database columns extremely time consuming, schemas evolve. mention because suspect logical reaction question going "break data out native columns".

you can create indexes on expressions want to. there's no cast directly xml integer, can go through text. db complained quite bit syntax creating index until went little nuts parentheses.

in end, got work:

create table books (id integer, data xml) create index books_isbn on books (((((xpath('/book/isbn/text()', data))[1])::text)::integer)); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -