Viewing 15 posts - 1 through 15 (of 17 total)
I should be silent in the mean time. I'm nothing close to an expert. I have way too many newb questions. I have reasons for not being affraid of algorithms...
September 26, 2011 at 1:40 am
Reply noted. I'll study as soon I've settled down a bit. Thanks for your effort in advance.
September 24, 2011 at 1:21 pm
Not a biggy. Thanks for the help. I think Jeff is still researching. So let's not close this case yet.
September 22, 2011 at 2:40 pm
No I didn't.
Like stated before, the inner join is not be removed. It represents a real life situation. I've only skinned it down for this forum. Call it respect 🙂
But...
September 22, 2011 at 12:42 pm
Ok, keeping the thread alive :).
It's not as easy it looks I think. My theory for now is that I need to accept the performance. I hope you'll come up...
September 22, 2011 at 10:40 am
September 21, 2011 at 8:07 am
What I have posted is a simplification of the real case. I can't post the real stuff as it owned by the company. But the real case isn't returning much...
September 21, 2011 at 7:31 am
Oki, so I added a where clause. The execution plan still shows 39% table scan on the Sales_City table.
The final query looks like this then:
select
Sold_To_Country,
sum(Sales_New_York) Sales_New_York,
sum(Sales_Detroit) Sales_Detroit,
sum(Sales_Los_Angeles) Sales_Los_Angeles,
sum(Sales_Paris) Sales_Paris,
sum(Sales_Lyon)...
September 21, 2011 at 7:10 am
Funny, has about the same execution speed as my original query. have to deal with the fact that implementing CASE/WHEN statements like this implies a serious performance hit. It forces...
September 21, 2011 at 2:59 am
CREATE TABLE [dbo].[CountriesInvolved](
[Sold_To_Country] [nvarchar](255) NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[Sales_City](
[Sold_To_Country] [nvarchar](255) NULL,
[ToCity] [nvarchar](255) NULL,
[SalesAmount] [float] NULL
) ON [PRIMARY]
September 19, 2011 at 10:39 am
Well I'll be dammed. The first query is faster then the more readable and shorter query...
I've tested it using 19 million records.
select
Sold_To_Country,
sum(Sales_New_York) Sales_New_York,
sum(Sales_Detroit) Sales_Detroit,
sum(Sales_Los_Angeles) Sales_Los_Angeles,
sum(Sales_Paris) Sales_Paris,
sum(Sales_Lyon) Sales_Lyon,
sum(Sales_Bonn) Sales_Bonn,
sum(Sales_Hamburg) Sales_Hamburg,
sum(Sales_Frankfurt)...
September 16, 2011 at 12:48 pm
Yes, they're in the Sales_City table! In the process of making screenies I forgot to post the answer.
September 16, 2011 at 10:35 am
Jeff Moden (9/15/2011)
...
September 15, 2011 at 11:35 pm
It's not the desired result. Here's the deal:
Using this query:
select
b.Sold_To_Country,
...
September 15, 2011 at 1:11 pm
Viewing 15 posts - 1 through 15 (of 17 total)