Hi ,
I must say firstly, my design is a little stupid but It has to like that,
So , I have a table named XX with 98 columns and 230.000 records , it is old
data source and I can't cut into pieces it.
and I have already new datas with new design , I did new view named YY
similiar with XX, and I wanna to merge two structures,
my union query is like that
SELECT column1, column2, .... column98 FROM YY WHERE column5='aaaaaaaa'
UNION
SELECT column1, column2, .... column98 FROM XX WHERE column5='aaaaaaaa'
this query works slowly for me , how can I make more effiency that
structure?
sorry If I couldn't explain very well.
Thanks for helps
Best Regards
Serkan KARAAssuming the design is not open for discussion:
First step is to determine whether you need to remove duplicated after the U
NION is performed. If
no, change to UNION ALL.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"scorpion" <ss@.ss.com> wrote in message news:%23OI3I0UBFHA.2580@.TK2MSFTNGP10.phx.gbl...[col
or=darkred]
> Hi ,
> I must say firstly, my design is a little stupid but It has to like that,
> So , I have a table named XX with 98 columns and 230.000 records , it is o
ld
> data source and I can't cut into pieces it.
> and I have already new datas with new design , I did new view named YY
> similiar with XX, and I wanna to merge two structures,
> my union query is like that
> SELECT column1, column2, .... column98 FROM YY WHERE column5='aaaaaaaa'
> UNION
> SELECT column1, column2, .... column98 FROM XX WHERE column5='aaaaaaaa'
> this query works slowly for me , how can I make more effiency that
> structure?
> sorry If I couldn't explain very well.
> Thanks for helps
> Best Regards
> Serkan KARA
>[/color]|||Change UNION to UNION ALL.
Run the query and check the plan. Look to see if you have indexes. How
many rows to you expect to return, lots, or very few? Can you index the
view (check in books online, or just try.) Is this going to be executed a
lot? And by slow, do you mean oppressively slow, or just kind of slow.
First step though is to check the plan and look for major trouble spots.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"scorpion" <ss@.ss.com> wrote in message
news:%23OI3I0UBFHA.2580@.TK2MSFTNGP10.phx.gbl...
> Hi ,
> I must say firstly, my design is a little stupid but It has to like that,
> So , I have a table named XX with 98 columns and 230.000 records , it is
> old
> data source and I can't cut into pieces it.
> and I have already new datas with new design , I did new view named YY
> similiar with XX, and I wanna to merge two structures,
> my union query is like that
> SELECT column1, column2, .... column98 FROM YY WHERE column5='aaaaaaaa'
> UNION
> SELECT column1, column2, .... column98 FROM XX WHERE column5='aaaaaaaa'
> this query works slowly for me , how can I make more effiency that
> structure?
> sorry If I couldn't explain very well.
> Thanks for helps
> Best Regards
> Serkan KARA
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment