Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Partitioned view - execution plan

Author  Topic 

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-08-25 : 09:17:42
Hi all,

To improve the performance, I splitted the single heavy table in my db into two new tables and created a partitioned view on it. Following is an oversimplified example:

create table test_1
(
a int primary key check ( a between 1 and 10)
)
GO

create table test_2
(
a int primary key check ( a between 11 and 20)
)
GO

insert into test_1
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 union all
select 8 union all
select 9 union all
select 10

insert into test_2
select 11 union all
select 12 union all
select 13 union all
select 14 union all
select 15 union all
select 16 union all
select 17 union all
select 18 union all
select 19 union all
select 20
GO

create view vw_test
as
select * from test_1
union all
select * from test_2
Go

select * from vw_test where a between 1 and 5


When I execute the above query and see the execution plan, I see that both the tables are seen as a part of execution plan even though my WHERE clause is satisfied only by the first table, what is the reason behind this?

This does not happens when I use = or IN operators !

Can anybody please explain this behavior?

Thanks.

Harsh Athalye
India.
"Nothing is Impossible"

hrishi_des
Yak Posting Veteran

76 Posts

Posted - 2006-10-10 : 01:36:10
Hi Harsh,

Always Use SET STATISTICS IO ON to verify which tables are being accessed and not rely on Execution plan.

I tried that example it shows it is accessing proper table.

thanks,
Hrishikesh

quote:
Originally posted by harsh_athalye

Hi all,

To improve the performance, I splitted the single heavy table in my db into two new tables and created a partitioned view on it. Following is an oversimplified example:

create table test_1
(
a int primary key check ( a between 1 and 10)
)
GO

create table test_2
(
a int primary key check ( a between 11 and 20)
)
GO

insert into test_1
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 union all
select 8 union all
select 9 union all
select 10

insert into test_2
select 11 union all
select 12 union all
select 13 union all
select 14 union all
select 15 union all
select 16 union all
select 17 union all
select 18 union all
select 19 union all
select 20
GO

create view vw_test
as
select * from test_1
union all
select * from test_2
Go

select * from vw_test where a between 1 and 5


When I execute the above query and see the execution plan, I see that both the tables are seen as a part of execution plan even though my WHERE clause is satisfied only by the first table, what is the reason behind this?

This does not happens when I use = or IN operators !

Can anybody please explain this behavior?

Thanks.

Harsh Athalye
India.
"Nothing is Impossible"

Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-10-10 : 14:54:54
FYI, I have seen big differences between 2005 and 2000, on how they handle partitioned views.
I have seen the same as Harsh on 2000,
but the same data + same query on 2005 efficiently eliminates unwanted tables from the actual execution plan.

rockmoose
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-10-11 : 01:42:58
Just in case useful here's a list of pre-requistes (SQL2000, dunno what's changed for SQL2005)

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Requirements%20for%20Horizontal%20Partitions

Kristen
Go to Top of Page

hrishi_des
Yak Posting Veteran

76 Posts

Posted - 2006-11-14 : 02:03:38
yea i second rockmoose's opinion even i have seen different behaviour... it works ok. if primary key is absent in 2005!!!!
Go to Top of Page
   

- Advertisement -