Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Copy Between 2 and 3 billion rows from a heap table with no key to a new partioned table. Expand / Collapse
Author
Message
Posted Wednesday, January 9, 2013 6:44 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, May 7, 2014 3:26 PM
Points: 54, Visits: 195
Hello,

I need to copy Between 2 and 3 billion rows from a heap table with no identity to a new partioned table. The primary key is made up of a smallint value that represents a Month and BIGINT a loan_number.

--The partion key is a small int value.
--I have tried the approach of selecting by the partition key, but as you can imagine because of the amount of data each select can take quite some time.
--I also tried using an import\export task it started moving some data, but it is also extremly slow.
--The new table has 24 partitions. each partition represents 24 values of the partition key from 0 - 552

Here is the definition of the partitioned table. The heap table is the same except it does not have the identity column created_by\date attributes.

--Partitioned table
CREATE TABLE dbo.qc_partition
(
qc_partition_id BIGINT IDENTITY(1,1)
, pool_id CHAR(3) NOT NULL
, deal_no CHAR(5) NOT NULL
, group_no CHAR(3) NOT NULL
, servicer VARCHAR(4) NULL
, internal_loan_id CHAR(6) NOT NULL
, external_loan_id VARCHAR(18) NOT NULL
, last_int_p SMALLDATETIME NULL
, balance MONEY NULL
, int_rate NUMERIC(6, 3) NULL
, total_payment_due MONEY NULL
, sched_principal MONEY NULL
, sched_mnth_p MONEY NULL
, mba_stat VARCHAR(1) NULL
, ots_stat VARCHAR(1) NULL
, payment_hist VARCHAR(12) NULL
, exception VARCHAR(1) NULL
, start_date SMALLDATETIME NULL
, end_date SMALLDATETIME NULL
, fc_end_typ VARCHAR(1) NULL
, payoff_d SMALLDATETIME NULL
, payoff_r VARCHAR(1) NULL
, sell_date SMALLDATETIME NULL
, inv_bal MONEY NULL
, next_percent NUMERIC(6, 3) NULL
, loss_val MONEY NULL
, net_rate NUMERIC(7, 4) NULL
, period SMALLINT NOT NULL
, file_name CHAR(8) NOT NULL
, created_by VARCHAR(70) NOT NULL DEFAULT CURRENT_USER
, created_date DATETIME NOT NULL DEFAULT (GETDATE())
) ON partition_scheme_qc (period)


One more question about the indexing. I created the following index, but was wondering if anyone had better idea on that. Also, What would be the best way to create a clustered-index\primary key here.

CREATE NONCLUSTERED INDEX IX_period_external_loan_id
ON qc_partition (period, external_loan_id)
ON partition_scheme_qc (period)
GO


Does anyone have any ideas?

Thank you for your help
Post #1405111
Posted Thursday, January 10, 2013 6:02 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, July 21, 2014 4:52 PM
Points: 7,079, Visits: 12,569
Related post. Direct replies here:

http://www.sqlservercentral.com/Forums/Topic1405106-146-1.aspx


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1405371
Posted Thursday, January 10, 2013 7:35 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 11:19 PM
Points: 36,724, Visits: 31,173
This is a duplicate post. Posting the same question over and over isn't the thing to do here. All it does is split resources and tick people off.

Please don't post any answers on this thread... instead, post them where this seems to have started....
http://www.sqlservercentral.com/Forums/Topic1405106-146-1.aspx


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1405447
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse