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
 General SQL Server Forums
 New to SQL Server Programming
 Creating Index on View

Author  Topic 

rds207
Posting Yak Master

198 Posts

Posted - 2009-11-11 : 18:57:52
Hi

I have created a view based on two columns the join condition is some thing like this :
CHARINDEX(B.PHONE_BUILD + '_', A.JOB_NAME) > 0 OR
CHARINDEX(B.PHONE_BUILD + 'Blueprint', A.JOB_NAME) > 0 OR
B.PHONE_BUILD = A.JOB_NAME

This involves in lot of parsing of the huge data,

The problem is the performance of teh view is very low, the records are being retrived very slow , i heard from someone that creating an index would make the performance better,

could anyone please let me knwo how to create an index on view...


X002548
Not Just a Number

15586 Posts

Posted - 2009-11-11 : 19:09:34
hey, post the view DDL and maybe some sample data of what PHONE_BUILD and JOB_NAME look like



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

rds207
Posting Yak Master

198 Posts

Posted - 2009-11-11 : 19:15:55
Sample Data:

Phone_Build Job_name

M76XXTFGCHNAAD1202 M76XXTFGCHNAAD1202_rel_31JUL2009_094725pm

M76XXCSDCBODAD35808P M76XXCSDCBODAD35808PBlueprint_30JUL2009

The whole objective of the view is to link phone build and jobname,the jobname is uniue , so may be i can create index on job_name..


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-11 : 19:30:58
Try this
FROM TABLEA JOIN TABLEB
ON LEN(JOB_NAME) <> LEN(REPLACE(JOB_NAME,PHONE_BUILD,''))

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

rds207
Posting Yak Master

198 Posts

Posted - 2009-11-12 : 12:49:12
thank you for the reply ...

Is this the syntax for creating index,?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-12 : 13:15:42
see, problem is, no index is going to help

You have a stage 2 predicate, and as such, it will alwys scan the tables

Your best bet is to create another column that has the data normalized, then worry about the join in the view



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -