Showing posts with label rows. Show all posts
Showing posts with label rows. Show all posts

Thursday, March 29, 2012

Advice on Partitioning and Processing

I'd appreciate some advice on the following:

I'm building a cube which is based on data in a SQL 2000 DB. There are around 1.2 billion rows of fact data in 26 tables. Each table uses approx 6 Gig. There are 4 Dimensions, 3 dimensions have less than a 1000 members with the 4th having 65000. For convenience I am creating 26 Cube partitions aligned to the DB tables, each partition will have around 50 million rows. Does this sound like a reasonable proposal? The reason I ask is that I am seeing very poor performance whilst calling ProcessData. I have processed various numbers of partitions in parallel and cannot achieve the same times that I can get on the existing AS2000 rig using the Parallel Processing Utility.

I have tested the data read by writing a .net application to execute the same DB queries in parallel that the partitions use (achieving 200 million rows in 20 minutes) and there are no issues related to network, disk or the DB server.

Processing seems to start well but around a minute in the Network utilisation drops down to 10 percent and CPU utilisation to 30%. It then goes back up to 100% for a short period and then drops again. This is repeated continually until processing is finished. At current speeds it will take 26 hours to complete as opposed to 10 hours on AS2000. The box is a 64-bit 4way hyperthreaded with 32 GB of RAM. AS2005 is Enterprise with SP1.

Any suggestions would be appreciated as I'm running out of ideas!

Rob.

You should check yourself against best practices you would find the project REAL implemetation http://www.microsoft.com/sql/solutions/bi/projectreal.mspx

I would say the partition size is a bit big. You should try and partition some more for and split a single partition in two. But that doesnt look like a major problem.

Question for you: in AS2005 you processing partitions in parallel. How many? Is the pattern the same for any number of partitions?

What OLEDB provider you are using to read data from SQL Server?


The reading rates looks to be slow. See where the bottleneck is. In your test application, the fair comparison not only when you execute SQL query, but you also retrevie all the data returned by the query.

Edward Melomed.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

Tuesday, March 27, 2012

Advice on indexes

I have a table (detail) with 4 columns and over 30 million rows .
Say the columns are called ColA, ColB, ColC, ColD

ColA and ColB form a foreign key as this table is a 'detail' table for another master table in the database (master). The master table uses these two columns as its primary key.
To speed up joins between the two tables I have created an index over ColA and ColB

I frequently need to join the two tables together and so most of my queries are of the form:

SELECT master.*, detail.ColC, detail.ColD FROM master JOIN detail
ON master.ColA = detail.ColA and master.ColB = detail.ColB
WHERE master.ColA = @.valA
ORDER BY master.ColB, detail.ColC

This could return up to 60000 rows for a specific value of @.valA.
This is usually a sub-query that feeds directly into another query or a temporary table.

However, I also quite often need to filter the details further by ColC so I have queries like

SELECT master.*, detail.ColC, detail.ColD FROM master JOIN detail

ON master.ColA = detail.ColA and master.ColB = detail.ColB

WHERE master.ColA = @.valA AND detail.ColC = @.valC

ORDER BY master.ColB

The results set from this could be just a few hundred rows depending on @.valC

I clearly have a requirement to have an index across ColA, and ColB, presumably as the clustered index.

My question is how to speed up queries that involve ColC.
Do I create another index across ColA, ColB and ColC or just ColC by itself?
Will an index just on ColC make use of the the clustered index on the other columns?
Should I make the clustered index cover ColA, ColB and ColC instead ? etc ..

I am using SQL Express and am approaching the 4GB limit and this table and another one similar to it account for 96% of the database size.
The four columns in the detail table are all integer types and so don't take up much space per row. I am worried that a wide index will significantly add to the storage space per row and therefore significantly reduce the amount of data I can store in the database.

Any advice would be appreciated.

You defintely do not ever want to create one index that is a subset of another as you asked, ie. do not create two indexes on

ColA, ColB

ColA, ColB, ColC

The one on ColA, ColB, ColC does everything that the first one does, so it is all you need.

In your case it sounds like a clustered index on ColA, ColB, ColC should be all you need. Leaving out one column won't make much difference to the size. The size will be affected by the fillfactor and the fragmentation level of the index, so you should rebuild the index from time to time (how often depends on the nature of your updates) with a fillfactor of 100%, although a high fillfactor will increase the possibility that some updates will be slower.

|||Thanks for that.

I have done as you have said and created an index across all three columns and I am happy with both the speed of the queries and the size of the database.sql

Advice on database volume

Hi all,
I'm new to datawarehousing. I've built a DW with two fact tables, each one
will be added with more than 5 to 10 millions rows each day. Do you think
that this volume is compatible with Analysis Services 2005 or do I have to
change the model I use, by creating a fact table for each customer I have
(for instance).
Second question: if the awnser of the previous question is that I can keep
the model I've built, will I have to investigate cube partition ?
thank's.
Jerome
You can work with this volume of data in Analysis Services 2005 without
changing your schema (and I strongly suggest you to not change your
schema!).
You can use partitions to handle this volume of data without having a
single big partition that is hard to process if for whatever reasons
you need to full process your cube.
Be careful with aggregation design - you really need preaggregations on
this volume of data.
Marco Russo
http://www.sqlbi.eu
http://www.sqljunkies.com/weblog/sqlbi
Jerome wrote:
> Hi all,
> I'm new to datawarehousing. I've built a DW with two fact tables, each one
> will be added with more than 5 to 10 millions rows each day. Do you think
> that this volume is compatible with Analysis Services 2005 or do I have to
> change the model I use, by creating a fact table for each customer I have
> (for instance).
> Second question: if the awnser of the previous question is that I can keep
> the model I've built, will I have to investigate cube partition ?
> thank's.
> Jerome
|||Hi Marco,
What do you mean exactly by "aggregation design"?
What is exactly preaggregation? Do you know some references on the web?
Thanks
Jerome
"Marco Russo" wrote:

> You can work with this volume of data in Analysis Services 2005 without
> changing your schema (and I strongly suggest you to not change your
> schema!).
> You can use partitions to handle this volume of data without having a
> single big partition that is hard to process if for whatever reasons
> you need to full process your cube.
> Be careful with aggregation design - you really need preaggregations on
> this volume of data.
> Marco Russo
> http://www.sqlbi.eu
> http://www.sqljunkies.com/weblog/sqlbi
>
> Jerome wrote:
>
|||yeah aggregation % in Analysis Services
-Susie
Jerome wrote:[vbcol=seagreen]
> Hi Marco,
> What do you mean exactly by "aggregation design"?
> What is exactly preaggregation? Do you know some references on the web?
> Thanks
> Jerome
>
> "Marco Russo" wrote:
|||yeah % aggregation in analysis services
Jerome wrote:[vbcol=seagreen]
> Hi Marco,
> What do you mean exactly by "aggregation design"?
> What is exactly preaggregation? Do you know some references on the web?
> Thanks
> Jerome
>
> "Marco Russo" wrote:

Advice on database volume

Hi all,
I'm new to datawarehousing. I've built a DW with two fact tables, each one
will be added with more than 5 to 10 millions rows each day. Do you think
that this volume is compatible with Analysis Services 2005 or do I have to
change the model I use, by creating a fact table for each customer I have
(for instance).
Second question: if the awnser of the previous question is that I can keep
the model I've built, will I have to investigate cube partition ?
thank's.
JeromeYou can work with this volume of data in Analysis Services 2005 without
changing your schema (and I strongly suggest you to not change your
schema!).
You can use partitions to handle this volume of data without having a
single big partition that is hard to process if for whatever reasons
you need to full process your cube.
Be careful with aggregation design - you really need preaggregations on
this volume of data.
Marco Russo
http://www.sqlbi.eu
http://www.sqljunkies.com/weblog/sqlbi
Jerome wrote:
> Hi all,
> I'm new to datawarehousing. I've built a DW with two fact tables, each one
> will be added with more than 5 to 10 millions rows each day. Do you think
> that this volume is compatible with Analysis Services 2005 or do I have to
> change the model I use, by creating a fact table for each customer I have
> (for instance).
> Second question: if the awnser of the previous question is that I can keep
> the model I've built, will I have to investigate cube partition ?
> thank's.
> Jerome|||Hi Marco,
What do you mean exactly by "aggregation design"?
What is exactly preaggregation? Do you know some references on the web?
Thanks
Jerome
"Marco Russo" wrote:

> You can work with this volume of data in Analysis Services 2005 without
> changing your schema (and I strongly suggest you to not change your
> schema!).
> You can use partitions to handle this volume of data without having a
> single big partition that is hard to process if for whatever reasons
> you need to full process your cube.
> Be careful with aggregation design - you really need preaggregations on
> this volume of data.
> Marco Russo
> http://www.sqlbi.eu
> http://www.sqljunkies.com/weblog/sqlbi
>
> Jerome wrote:
>|||yeah aggregation % in Analysis Services
-Susie
Jerome wrote:[vbcol=seagreen]
> Hi Marco,
> What do you mean exactly by "aggregation design"?
> What is exactly preaggregation? Do you know some references on the web?
> Thanks
> Jerome
>
> "Marco Russo" wrote:
>|||yeah % aggregation in analysis services
Jerome wrote:[vbcol=seagreen]
> Hi Marco,
> What do you mean exactly by "aggregation design"?
> What is exactly preaggregation? Do you know some references on the web?
> Thanks
> Jerome
>
> "Marco Russo" wrote:
>sql

Sunday, March 25, 2012

Advice

Hi,
Nightly I am importing 8000 rows of data into a table with 3 billion rows.
The table has one clustered index. Should I disable the clustered index
before importing? If so where do I find info on disabling and enabling
clustered index on a column?
ThanksYou can't "disable" a clustered index, you would have to drop it and
recreate it. And doing that would be very costly with 3 billion rows. So,
you do not want to do that.
Tom
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:85B9A949-CDC1-410C-90C3-CC3502C055D3@.microsoft.com...
> Hi,
> Nightly I am importing 8000 rows of data into a table with 3 billion rows.
> The table has one clustered index. Should I disable the clustered index
> before importing? If so where do I find info on disabling and enabling
> clustered index on a column?
> Thanks

Tuesday, March 20, 2012

Advantages?

I would welcome opinions on whether FTS would help in our scenario.
The table has about 28 million rows and has about 10,000 rows added every
morning in an intensive batch process. Then another batch query process is
run that looks for partial name matches.
Eight of the fields we query against are char or varchar, all with single
words.
Sample query: SELECT casenumber FROM table WHERE fname LIKE 'j%' AND lname
LIKE 'smi%'. Rreturns 55,874 rows in 7 seconds in QA.
I am also concerned about time to populate FT index every day.
Machine is dual Xeon 3.2 with 4GB ram, OS on RAID1 & SQL data on RAID5. Win
2003 Server and SQL2000, with SQL2005 later this year.
Thanks much!
Wow! That's fantastic speed for a like. I'd try change tracking. IIRC on a
similar machine I was able to hit 2000 rows per minute with SQL 2000.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Bil Click" <BilClick@.discussions.microsoft.com> wrote in message
news:FFF888F6-8310-4B1F-83B0-399830C17F53@.microsoft.com...
>I would welcome opinions on whether FTS would help in our scenario.
> The table has about 28 million rows and has about 10,000 rows added every
> morning in an intensive batch process. Then another batch query process is
> run that looks for partial name matches.
> Eight of the fields we query against are char or varchar, all with single
> words.
> Sample query: SELECT casenumber FROM table WHERE fname LIKE 'j%' AND lname
> LIKE 'smi%'. Rreturns 55,874 rows in 7 seconds in QA.
> I am also concerned about time to populate FT index every day.
> Machine is dual Xeon 3.2 with 4GB ram, OS on RAID1 & SQL data on RAID5.
> Win
> 2003 Server and SQL2000, with SQL2005 later this year.
> Thanks much!
|||Thanks Hilary, but do you think a Full Text search would be faster searching
on single words?
"Hilary Cotter" wrote:

> Wow! That's fantastic speed for a like. I'd try change tracking. IIRC on a
> similar machine I was able to hit 2000 rows per minute with SQL 2000.
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Bil Click" <BilClick@.discussions.microsoft.com> wrote in message
> news:FFF888F6-8310-4B1F-83B0-399830C17F53@.microsoft.com...
>
>
|||It will be for larger tables. I am not sure where the cut off it - i.e.
20,000 rows or 2 million.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Bil Click" <BilClick@.discussions.microsoft.com> wrote in message
news:FDFBA954-00ED-4444-A7EF-2B5547510343@.microsoft.com...[vbcol=seagreen]
> Thanks Hilary, but do you think a Full Text search would be faster
> searching
> on single words?
> "Hilary Cotter" wrote:

Monday, March 19, 2012

Advanced SQL HELP: transform rows to columns

I have a table of 1000+ rows with 100+ different items with each Id having max 10 items

Id item
1 a
1 b
2 c
2 a
2 d
3 b
3 z

each item has an order in a different lookup table
item item_seq
a 1
b 2
c 3
d 4

The item columns (below) need to use the item order from lookup table, so the output table is as follows

Id item item2 item3
1 a b
2 a c d
3 b z

PLEASE HELP !!!Hello,
I am a little bit confused about your target but what I can catch is that you are asking how to make an output table like the one you demonstrated at the end. If it is so, I think that the table design itself is not correct and what you need is to make a one to many relation ship table composed of 2 fields that looks like the following

Id Item
1 a
1 b
2 a
2 c
2 d
3 b
3 Z
and so on

and by this way you can insert as many as items as you like with each Id

Thanks|||Thanks vm for replying Rasha.

To make matters simpler, I exclude the item order table since I found a way of doing that.
So basically the input table is
Id Item
1 a
1 b
2 a
2 c
2 d
3 b
3 Z

and the output table I need to come up with should be like

Id Item1 Item2 Item3
1 a b
2 a c d
3 b z

The CASE statement is diffucilt to use since there are 100+ different items (and new ones are added all the time) and each id can have 1 to 9 items, so columns Item1 to Item9 per id are needed.

Any ideas ?

Originally posted by rasha
Hello,
I am a little bit confused about your target but what I can catch is that you are asking how to make an output table like the one you demonstrated at the end. If it is so, I think that the table design itself is not correct and what you need is to make a one to many relation ship table composed of 2 fields that looks like the following

Id Item
1 a
1 b
2 a
2 c
2 d
3 b
3 Z
and so on

and by this way you can insert as many as items as you like with each Id

Thanks|||What you are asking for is called a cross tab query. The pivot is best handled on the client if at all possible, but it can also be done in SQL when you can't do it on the client.

-PatP|||Hi, I do not know much about Cross tab query but I think the following dissccusion may help you:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=19008|||Assuming that your item values are sortable for each id (that there aren't any NULL values and no duplicates), you can use:CREATE TABLE dbo.table00 (
id INT NOT NULL
, item CHAR(1) NOT NULL
)

INSERT INTO dbo.table00 (id, item)
SELECT 1, 'a'
UNION ALL SELECT 1, 'b'
UNION ALL SELECT 2, 'a'
UNION ALL SELECT 2, 'c'
UNION ALL SELECT 2, 'd'
UNION ALL SELECT 3, 'b'
UNION ALL SELECT 3, 'z'

SELECT a.id, Min(a.item)
+ Coalesce(', ' + Min(b.item), '')
+ Coalesce(', ' + Min(c.item), '')
FROM dbo.table00 AS a
LEFT JOIN dbo.table00 AS b
ON (b.id = a.id
AND a.item < b.item)
LEFT JOIN dbo.table00 AS c
ON (c.id = a.id
AND b.item < c.item)
GROUP BY a.id
ORDER BY a.id

DROP TABLE dbo.table00-PatP|||Thanks very much for your reply PAT.

I have to say your approach with the LEFT join and item> comparisons
is simple and clever.
However bearing in mind that there are 100+ different items, doing 100+ left joins...I don't how efficient will that be...
Thanks very much anyway.|||Originally posted by dim2000
However bearing in mind that there are 100+ different items, doing 100+ left joins...I don't how efficient will that be... Try it. You might be shocked (I know that I was).

A cross tab is still better handled on the client when that is possible, but the server does a better job than I thought that it would.

-PatP|||Thanks for your reply Pat.

The left joins worked quite fast actually, on the server that is not the client.

Do you know if I could use the Case or ISNULL statements for this.

e.g. CASE when item='a' THEN item1 ELSE 'None' END AS 'MCQ Raw',

I used the case statement before but only for amounts that needed to be summed up, when I tried to use it with text fields I could not get it to work,
Any ideas?

Friday, February 24, 2012

ADO.NET or OLEDB connection/recordset?

My package needs to be a High Performance (target: 150,000 rows in 30 minutes) ETL solution. We are using all MS technologies - SSIS, SQL 2005, BIDS, etc. I need to loop the recordset executed by a Stored Proc in a Execute SQL Task in a Source Script Component.

If I use an ADO.NET Connection Manager, here is the code in the Source Script Component Public Overrides Sub CreateNewOutputRows()

Code 1

Dim sqlAdapter As New SqlDataAdapter

Dim dataRow As Data.DataRow

Dim ds As DataSet = CType(Me.Variables.rsSomeResultset, DataSet)

sqlAdapter.Fill(ds)

Iget: Error: System.InvalidCastException: Unable to cast object of type 'System.Object' to type 'System.Data.DataSet'.

Code 2

Dim oledbAdapter As New OleDb.OleDbDataAdapter

Dim dataTable As DataTable

oledbAdapter.Fill(dataTable, Me.Variables.rsSomeResultset)

Error: System.ArgumentException: Object is not an ADODB.RecordSet or an ADODB.Record. Parameter name: adodb

It works all right when I use an OLEDB Connection Manager with the second code sample.

Question: In order to extract the maximum performance, wouldn't it be preferred to use ADO.NET with SqlClient Provider in an all SQL Server 2005 environment? Or will an OLEDB Connection provide comparable or equal performance?

If so, what code can I use? Since the recordset returned by the Stored Proc (in the Execute SQL Task) can only be captured in a System.Object variable and you can only use the overload of the Fill() method of the OleDbDataAdapter to accept an ADO Recordset or Record object.

There was a post recently that compared some of the connection types, but thanks to the lovely search functionality, I can't find it. If anyone else has it, please post it to this thread.

In general, I don't think you are going to see a significant performance difference between ADO.NET and OLEDB against SQL Server.

That being said, if you want to do some further research into the problem, try adding a message box to your script to display the type of the variable.

Code Snippet

System.Windows.Forms.MessageBox.Show(Me.Variables.rsSomeResultset.ToString())

|||You Code 1 snippet doesn't look right for ADO.NET. You shouldn't be trying to call sqlAdapter.Fill(ds). Try Dim dataTable as DataTable = ds.Tables(0) instead. I'd guess that OLE DB would be faster. Please post your findings.
|||

Do you mean this discussion?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1985034&SiteID=1

ADO.NET or OLEDB connection/recordset?

My package needs to be a High Performance (target: 150,000 rows in 30 minutes) ETL solution. We are using all MS technologies - SSIS, SQL 2005, BIDS, etc. I need to loop the recordset executed by a Stored Proc in a Execute SQL Task in a Source Script Component.

If I use an ADO.NET Connection Manager, here is the code in the Source Script Component Public Overrides Sub CreateNewOutputRows()

Code 1

Dim sqlAdapter As New SqlDataAdapter

Dim dataRow As Data.DataRow

Dim ds As DataSet = CType(Me.Variables.rsSomeResultset, DataSet)

sqlAdapter.Fill(ds)

Iget: Error: System.InvalidCastException: Unable to cast object of type 'System.Object' to type 'System.Data.DataSet'.

Code 2

Dim oledbAdapter As New OleDb.OleDbDataAdapter

Dim dataTable As DataTable

oledbAdapter.Fill(dataTable, Me.Variables.rsSomeResultset)

Error: System.ArgumentException: Object is not an ADODB.RecordSet or an ADODB.Record. Parameter name: adodb

It works all right when I use an OLEDB Connection Manager with the second code sample.

Question: In order to extract the maximum performance, wouldn't it be preferred to use ADO.NET with SqlClient Provider in an all SQL Server 2005 environment? Or will an OLEDB Connection provide comparable or equal performance?

If so, what code can I use? Since the recordset returned by the Stored Proc (in the Execute SQL Task) can only be captured in a System.Object variable and you can only use the overload of the Fill() method of the OleDbDataAdapter to accept an ADO Recordset or Record object.

There was a post recently that compared some of the connection types, but thanks to the lovely search functionality, I can't find it. If anyone else has it, please post it to this thread.

In general, I don't think you are going to see a significant performance difference between ADO.NET and OLEDB against SQL Server.

That being said, if you want to do some further research into the problem, try adding a message box to your script to display the type of the variable.

Code Snippet

System.Windows.Forms.MessageBox.Show(Me.Variables.rsSomeResultset.ToString())

|||You Code 1 snippet doesn't look right for ADO.NET. You shouldn't be trying to call sqlAdapter.Fill(ds). Try Dim dataTable as DataTable = ds.Tables(0) instead. I'd guess that OLE DB would be faster. Please post your findings.
|||

Do you mean this discussion?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1985034&SiteID=1

Sunday, February 19, 2012

ADO MaxRecords and table variables

It appears that when I specify the MaxRecords property in ADO to something other than 0, not only does SQL Server 2000 limit the number of rows that are being returned from a stored procedure, it also limits the number of "select into"s within the stored proecudre (I'm inserting into table variables within the proc).

Here's a scenario of why this is a problem. Suppose I have a proc that needs to perform calculations on all employees in my system (10,000 of them). The calculation is performed by selecting these employees into a table variable with some calculated values being inserted as well. When the processing is complete, I need to select the top 1500 employees from the table.

If I specify MaxRecords in ADO, the "select into" statement that populates my table variable appears to limit the number of rows to 1500. This is a problem if I'm expecting an employee outside of the first 1500 to be considered for the calculations I'm performing.

Is there some way of indicating that MaxRecords should be ignored when selecting into table variables or temporary tables within a stored proc?

Thanks,
TerenceI know I could simply use "top" in the last select statement of the stored procedure to get around this problem, however, this is not an option on the system I'm currently developing (for design reasons (possibly poor design reasons now that I think about it ;) ))

Thanks again,
Terence