Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Xml index


Xml index

Author
Message
IT researcher
 IT researcher
SSC Veteran
SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)

Group: General Forum Members
Points: 294 Visits: 1798
I have a table with following column.(I have directly give the create table command)
CREATE TABLE [dbo].[BalanceTable](
[AccountID] [int] NOT NULL,
[Type] [varchar](10) NULL,
[Date] [date] NOT NULL,
[Balance] [decimal](15, 2) NULL,
[TRansactionDr] [decimal](15, 2) NULL,
[TRansactionCr] [decimal](15, 2) NULL,
[daily_Balance] [xml] NULL,
CONSTRAINT [PK_BalanceTable] PRIMARY KEY CLUSTERED
(
[AccountID] ASC,
[Date] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

I have a xml query which updates this table. But it works slowly and take some seconds. I want to speed it up. So i was try to use xml index.So in this case which index i should use? Primary? secondary(in that i have path,value and property)? So which will be better to use which will reduce time required for execution.
Below is query

Update BalanceTable set [daily_balance].modify('replace value of (/Root/Row[date=''2011-03-23'']/Balance/text())[1] with (/Root/Row[date=''2011-03-23'']/ Balance)[1] +1') where [AccountID]=26 and [Date]='31-Mar-2011' and [daily_balance].exist('/Root/Row[date=''2011-03-23'']')=1;

Also here is sample of xml column

<Root>
<Row>
<Rowid>0</Rowid>
<date>2011-01-23</date>
<Balance>0.0E0</Balance>
<TRansactionDr>0.0E0</TRansactionDr>
<TRansactionCr>0.0E0</TRansactionCr>
</Row>
<Maxrowid>0</Maxrowid>
<Row>
<Rowid>0</Rowid>
<date>2011-01-31</date>
<Balance>123</Balance>
<TRansactionDr>123</TRansactionDr>
<TRansactionCr>0.0E0</TRansactionCr>
</Row>
</Root>

So please give me suggestions
Igor Micev
Igor Micev
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4170 Visits: 4849
Hi,

Because you use exist() you should create FOR PATH type xml index.

Regards
IgorMi


Igor Micev,
‌SQL Server developer at Seavus
www.seavus.com
IT researcher
 IT researcher
SSC Veteran
SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)

Group: General Forum Members
Points: 294 Visits: 1798
Ok. But while creating PATH type index is there needed to specify the path which i use?
I don't know much about xml indexing. But for other datatypes there is option of filtered index where i can specify the condition.
So is there any option in xml also? If not then for which path it will create index for xml column?
Igor Micev
Igor Micev
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4170 Visits: 4849
IT researcher (5/3/2013)
Ok. But while creating PATH type index is there needed to specify the path which i use?
I don't know much about xml indexing. But for other datatypes there is option of filtered index where i can specify the condition.
So is there any option in xml also? If not then for which path it will create index for xml column?


No, you don't need to specify any paths

Can you try this?

create primary xml index PXML_daily_Balance on BalanceTable(daily_Balance)
create xml index [SECXMl_daily_Balance_path] on BalanceTable(daily_Balance)
using xml index [PXML_daily_Balance] for path



Regards,
IgorMi


Igor Micev,
‌SQL Server developer at Seavus
www.seavus.com
IT researcher
 IT researcher
SSC Veteran
SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)

Group: General Forum Members
Points: 294 Visits: 1798
Whether i can use selective xml index? Does it available in sql server 2008 r2 express?
Igor Micev
Igor Micev
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4170 Visits: 4849
IT researcher (5/3/2013)
Whether i can use selective xml index? Does it available in sql server 2008 r2 express?


It's available from sql server 2012.


Igor Micev,
‌SQL Server developer at Seavus
www.seavus.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search