RE: Faster search with xquery contains()
  Home FAQ Contact Sign in
microsoft.public.sqlserver.xml only
 
Advanced search
POPULAR GROUPS

more...

 Up
RE: Faster search with xquery contains()         

Group: microsoft.public.sqlserver.xml · Group Profile
Author: sqlextreme
Date: Sep 1, 2008 08:38

Bob
Maybe your xml is very short, test with some like this.



ukel1ele@mail.cl
Secure
2007-05-07T11:53:38.880
pepito
perez
pereira
1215121
M
Abogado
buenas peras sn
Santiago
santiago
chile
454879
15646545
4546546

1970-10-11T00:00:00
1970
10
11

S
3
espanol
S
nadie
1


ukel1ele@mail.cl
1


ukel1ele@mail.cl
1


ukel1ele@mail.cl
1


ukel1ele@mail.cl
1


ukel1ele@mail.cl
1
rthreht


ukel1ele@mail.cl
1
hola


ukel1ele@mail.cl
1


ukel1ele@mail.cl


ukel1ele@mail.cl


ukel1ele@mail.cl


ukel1ele@mail.cl
1


ukel1ele@mail.cl



What got time for your query?

bye

"Bob" wrote:
> I tested it out on a sample table, with 40,000 records I'd generated, and it
> wasn't slow, with out without clustered index.
>
> "sqlextreme" wrote:
>
>> Bob
>> Your query is more slow. In fact working with XML is very slow in SQL Server
>> 2005.
>>
>> In my experience, especially when you excute for example "select xmlcolumn
>> from MyTable" and the Xml Column is medium size, can will be very slow.
>>
>> "Bob" wrote:
>>
>>> I don't know if this will go any faster, but have you tried shredding the XML
>>> column and then querying it, eg
>>>
>>> SELECT *
>>> FROM
>>> (
>>> SELECT tbob_ObjData.value('(Usuario/mbUSR_Usuario/tbus_Email/text())[1]',
>>> 'VARCHAR(100)' )
>>> FROM proOBJ_Object
>>> ) x (email_address)
>>> WHERE email_address Like '%%c%%'
>>>
>>> It's not a very selective search you're doing, combined with the use of the
>>> wildcards, I'm not sure indexes are going to help much.
>>>
>>>
>>> "byteman" wrote:
>>>
>>>> Hi
>>>>
>>>> In our work we have a table with 37000 records (aprox). The table have a xml
>>>> column, with primary xml index and a secondary path index.
>>>> The xml structure is something like this:
>>>>
>>>>
>>>> ukel1ele@mail.cl
>>>> ....
>>>> ....
>>>>

>>>>

>>>>
>>>> I execute the following query to check if an XML value contains the letter
>>>> "c" in tbus_Email:
>>>>
>>>> select tbob_idObj
>>>> from proOBJ_Object
>>>> where
>>>> tbob_ObjData.exist('/Usuario/mbUSR_Usuario/tbus_Email[contains(text()[1],"c")]') = 1
>>>>
>>>> this query returns 2099 records in 47 seconds, which is too long for our
>>>> time requirements.
>>>>
>>>> We also tried combine full-text search with xml querying, trying to speed up
>>>> the response time:
>>>>
>>>> select tbob_idObj
>>>> from proOBJ_Object
>>>> where contains(tbob_ObjData,'c')
>>>> and
>>>> tbob_ObjData.exist('/Usuario/mbUSR_Usuario/tbus_Email[contains(text()[1],"c")]') = 1
>>>>
>>>> but the time of execution is near the same for the same results because
>>>> full-text CONTAINS() finds "c" in all records of the table and the
>>>> CONTAINS() not allow make more specific searches.
>>>>
>>>> Is there a way to improve these response times?
>>>>
>>>> I really appreciate your help.
>>>>
>>>>
>>>>
no comments
diggit! del.icio.us! reddit!